If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL Newbie Getting Errors with PHP to MySQL script.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-21-03, 19:57
AccessDenied AccessDenied is offline
Registered User
 
Join Date: Dec 2003
Posts: 2
MySQL Newbie Getting Errors with PHP to MySQL script.

Hello,

I have a script which is supposed to add a number (inputed into a HTML form, and passed to a PHP script) to a MySQL database. The field in the database says this:
PHP Code:
Namenumber
Type
INT
Legenth
3
Attributes
Blank
Null
not null
Default: 5
Extra
Blank 
The PHP script looks like this:
PHP Code:
<?php
$housename 
gryffindor
$number=$_POST['number'];//get the number from POST 
settype($number"integer");//make sure it's a number not a string .. 
$conn mysql_connect ("localhost""PUTDATABASEUSERNAMEHERE""PUTDATABASEPASSWORDHERE"); 
mysql_select_db ("PUTDATABASENAMEHERE",$conn); 
$sql "INSERT INTO $housename values ('', number=number+$number)"
if (
mysql_query($sql$conn)) { 
echo 
"record added!"
} else { 
    echo 
"something went wrong"

?>

On my test machine, all it says is "Something Went Wrong". Why is that?

Also, on my main server, I get a MySQL "Seeking" error. I've never heard of that. What does it mean?
Reply With Quote
  #2 (permalink)  
Old 12-22-03, 06:05
omiossec omiossec is offline
Registered User
 
Join Date: Jan 2003
Location: Paris, France
Posts: 320
You forget to tell mysql which field to use

insert into table (col, col ...) values ('xx', 'xx', ...)
__________________
Olivier Miossec
--
http://www.lasso-developpeur.net/
--
Reply With Quote
  #3 (permalink)  
Old 12-22-03, 21:20
AccessDenied AccessDenied is offline
Registered User
 
Join Date: Dec 2003
Posts: 2
Quote:
Originally posted by omiossec
You forget to tell mysql which field to use

insert into table (col, col ...) values ('xx', 'xx', ...)

So if the table was named "gryffindor" and the field was named "number", how would that look?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On