nightcrawler Posted April 13, 2007 Share Posted April 13, 2007 $q = "INSERT INTO downloads (sub, title, name, email, link, date, description, pic) VALUES ('$c', '$t', '$n', '$e', '$l', 'NOW()', '$d', 'NULL')"; $addinfo = mysql_query($q); Does that look right? I don't have many resources for php and mysql. Link to comment https://forums.phpfreaks.com/topic/46804-php-mysql-insert-syntax/ Share on other sites More sharing options...
btherl Posted April 13, 2007 Share Posted April 13, 2007 Looks ok, except now() and null should not be quoted. Try "echo $q" also so you can see the final query. And it's good to have a check like this: $addinfo = mysql_query($q) or die("Error in $q: " . mysql_error()); Link to comment https://forums.phpfreaks.com/topic/46804-php-mysql-insert-syntax/#findComment-228112 Share on other sites More sharing options...
nightcrawler Posted April 13, 2007 Author Share Posted April 13, 2007 lol, thanks. I did have a check, but it said: ... or die("This sucks"); So I thought I'd leave it out. I'll try removing the quotes. Thanks. Link to comment https://forums.phpfreaks.com/topic/46804-php-mysql-insert-syntax/#findComment-228119 Share on other sites More sharing options...
btherl Posted April 13, 2007 Share Posted April 13, 2007 Try the check I posted.. it'll tell you not just that the query failed, but also the reason why it failed. Plus it will show you the query, which will show you if one of the input variables was not what you expected it to be. It can save a lot of debugging time Link to comment https://forums.phpfreaks.com/topic/46804-php-mysql-insert-syntax/#findComment-228122 Share on other sites More sharing options...
nightcrawler Posted April 13, 2007 Author Share Posted April 13, 2007 The syntax fixed it quick. I've seen that mysql_error() used often for dies in error checking. Thanks for the tip. Link to comment https://forums.phpfreaks.com/topic/46804-php-mysql-insert-syntax/#findComment-228130 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.