Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error " Resource id #13"

Status
Not open for further replies.

brownfox

Programmer
Joined
Jan 5, 2003
Messages
173
Location
GB
I'm doing a simple INSERT INTO table using the output of a form. All of the fields go in apart from one which says "Resource id #13"?
The code:
$username="*******";
$password="*******";
$database="*******";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="INSERT INTO table (handle,email,sex,passwrd) VALUES ('$handle','$email','$sex',','$password')";
$result=mysql_query($query) or die (mysql_error());
 
The offender is handle. I'm calling the form var $handle. Can you explain to me how to do this:
"Have you tried outputting your SQL query to see what your concatenation produces"
 
Got my code wrong in the initial post. It should read:
The code:
$username="*******";
$password="*******";
$database="*******";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="INSERT INTO table (handle,email,sex,passwrd) VALUES ('$handle','$email','$sex','$passwrd')";
$result=mysql_query($query) or die (mysql_error());
 
I don't know if your SQL is just an example. If not, it is not a great choice to call your table 'table'.

$query="INSERT INTO table (handle,email,sex,passwrd)...

TABLE is a reserved word in MySQL. If you intend to use it as the table name, enclose it in backticks:
`table`

However, it is best to stay away from reserved words for database, table, or column names.

 
No it's not that, but your right it wouldn't be a good idea to call a table 'table'. I just used it as an example to show that it's a INSERT command. I discovered the problem. I was inserting into a table. Then selecting the table (just to check the insert went ok) on the same page and there were conflicting $vars. When I renamed the $handle to $handle1 in the send form it was ok. Thanks anyway
 
brownfox,

This makes a good case for posting actual code. How can anyone find an error in something that is not the real offender?

;)
 
Ok that's a fair criticism, however my code was long and had bits in that were not necessary, so I edited it. In future I will include it all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top