doctor_james Posted September 23, 2007 Share Posted September 23, 2007 Hi guys . I have a Mysql table But anytime I post some data using mysql_query() nothing happens . but when I change fields' names it works . have you guys had this problem ? I think it's not with mysql for I can insert data through phpmyadmin . it's a boring job to change fields' names frequently . Link to comment https://forums.phpfreaks.com/topic/70387-is-it-with-php/ Share on other sites More sharing options...
rarebit Posted September 23, 2007 Share Posted September 23, 2007 No! Link to comment https://forums.phpfreaks.com/topic/70387-is-it-with-php/#findComment-353597 Share on other sites More sharing options...
Jessica Posted September 23, 2007 Share Posted September 23, 2007 The field names might be reserved words. Without seeing the code we can't help much. Link to comment https://forums.phpfreaks.com/topic/70387-is-it-with-php/#findComment-353599 Share on other sites More sharing options...
doctor_james Posted September 23, 2007 Author Share Posted September 23, 2007 thanks for your answers . I dont think they're reserved words since adding prefixes does not work ! Here's my code : $query="INSERT INTO ent(user,title,cat,summary,entire,source,pdf,photo,date,time,comment,status) VALUES ('$user','$title','$cats','$summary','$entire','$source','{$pdf['name']}','{$photo['name']}','$date','$time','$comment','$status')"; Link to comment https://forums.phpfreaks.com/topic/70387-is-it-with-php/#findComment-353609 Share on other sites More sharing options...
BlueSkyIS Posted September 23, 2007 Share Posted September 23, 2007 try an or die(mysql_error()) after your mysql_query()? Link to comment https://forums.phpfreaks.com/topic/70387-is-it-with-php/#findComment-353614 Share on other sites More sharing options...
doctor_james Posted September 23, 2007 Author Share Posted September 23, 2007 Thanks "BlueSkyIS" , I added mysql_error n got this error : error : Incorrect date value: '9' for column 'date' at row 1 !! how can I define default values for my fields ? Link to comment https://forums.phpfreaks.com/topic/70387-is-it-with-php/#findComment-353622 Share on other sites More sharing options...
BlueSkyIS Posted September 23, 2007 Share Posted September 23, 2007 first question: why are you trying to put a 9 into a date field? Link to comment https://forums.phpfreaks.com/topic/70387-is-it-with-php/#findComment-353630 Share on other sites More sharing options...
dbo Posted September 23, 2007 Share Posted September 23, 2007 A good way to take reserved words out of the equation is to escape your field names. I wrote a class that actually generates my query strings for me and does just this. Take notice of the backtick around field names. If you've ever used phpmyadmin you might have noticed that it does this too. $query="INSERT INTO ent(`user`,`title`,`cat`,`summary`,`entire`,`source`,`pdf`,`photo`,`date`,`time`,`comment`,`status`) VALUES ('$user','$title','$cats','$summary','$entire','$source','{$pdf['name']}','{$photo['name']}','$date','$time','$comment','$status')"; Link to comment https://forums.phpfreaks.com/topic/70387-is-it-with-php/#findComment-353638 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.