Jump to content

mysql error...


digitalgod

Recommended Posts

hey guys,

I keep getting a mysql error but I can't seem to find what it is...

here's my query

mysql_query("INSERT INTO " . $prefix . "news (headline,content,thumb,website1,website2,website3,desc1,desc2,desc3,date,when,where,type) VALUES('$headline','$content','$names[0]','$web1','$web2','$web3','$desc1','$desc2','$desc3','$today','$when','$where','$type')") or die(mysql_error());

and here's the error I'm getting when inserting values

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'when,where,type) VALUES('just testing','this is just a test','cercle.jpg','','' at line 1

Link to comment
Share on other sites

See if wrapping backticks (`) around your field names in your query. MySQL might be getting confused as your have used MySQL keywords as your field names in your news table. The following are mysql keywords:
- date
- where

So change the lower part of your query to this:
`date`, when, `where`, `type`
Link to comment
Share on other sites

here you go

mysql_query("INSERT INTO " . $prefix . "news (headline,content,thumb,website1,website2,website3,desc1,desc2,desc3,`date`, when, `where`, `type`) VALUES('$headline','$content','$names[0]','$web1','$web2','$web3','$desc1','$desc2','$desc3','$today','$when','$where','$type')") or die(mysql_error());
Link to comment
Share on other sites

Alright... you might need to print out your query for debugging. What does this output?

[code=php:0]
$sql = "INSERT INTO " . $prefix . "news (headline,content,thumb,website1,website2,website3,desc1,desc2,desc3,`date`, when, `where`, `type`) VALUES ('$headline','$content','$names[0]','$web1','$web2','$web3','$desc1','$desc2','$desc3','$today','$when','$where','$type')";
mysql_query($sql) or die(mysql_error()."SQL = ".$sql);
[/code]
Link to comment
Share on other sites

Hi Thorpe

here's the ouput

SQL = INSERT INTO mtl_news (headline,content,thumb,website1,website2,website3,desc1,desc2,desc3,`date`, when, `where`, `type`) VALUES ('we\'re testing','this is just a test','cercle.jpg','','','','','','','2006-11-01','','','both')

I don't understand why it doesn't work. The table exists and all the rows as well
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.