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 . Quote Link to comment Share on other sites More sharing options...
rarebit Posted September 23, 2007 Share Posted September 23, 2007 No! Quote Link to comment 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. Quote Link to comment 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')"; Quote Link to comment 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()? Quote Link to comment 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 ? Quote Link to comment 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? Quote Link to comment 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')"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.