MrMagooba Posted June 17, 2007 Share Posted June 17, 2007 I just can't figure out why it isn't sending the data to the table, I've check the names over and over, all the info is parsed correctly, but it falls flat at: $result = mysql_query($sql); Can anyone help please? You can see it not working here if you want, code is attached to this post. Any help is greatly appreciated. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/55905-insert-data-to-a-table-i-cant-see-why-it-doesnt-work/ Share on other sites More sharing options...
pocobueno1388 Posted June 17, 2007 Share Posted June 17, 2007 Add some error checking at the end of your query and see what it tells you. Change this: $result = mysql_query($sql); To: $result = mysql_query($sql) or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/55905-insert-data-to-a-table-i-cant-see-why-it-doesnt-work/#findComment-276146 Share on other sites More sharing options...
sasa Posted June 17, 2007 Share Posted June 17, 2007 change $sql = "INSERT INTO topicstarter ('posttitle', 'postdate', 'poster', 'message') VALUES ('$posttitle','$postdate','$poster','$message')"; to $sql = "INSERT INTO topicstarter (posttitle, postdate, poster, message) VALUES ('$posttitle','$postdate','$poster','$message')"; or $sql = "INSERT INTO topicstarter (`posttitle`, `postdate`, `poster`, `message`) VALUES ('$posttitle','$postdate','$poster','$message')"; Quote Link to comment https://forums.phpfreaks.com/topic/55905-insert-data-to-a-table-i-cant-see-why-it-doesnt-work/#findComment-276162 Share on other sites More sharing options...
MrMagooba Posted June 17, 2007 Author Share Posted June 17, 2007 Thanks for your help peeps. Adding die (mysql_error()) changed the error code to brought up the following error: 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 'prefix'>th Jun 2007: 12:00','Your name...','Type away... Turns out it was part of the form that was bottoming it out. If I remove the ''s from: <input type="hidden" name="postdate" value="<?php echo date('j') ."<span class='prefix'>" .date('S') ."</span> " .date('M Y') .": " .date('H:i');?>"> it works fine. I don't see why that would cause a problem though, I mean it looks like this when parsed: <input type="hidden" name="postdate" value="17<span class='prefix'>th</span> Jun 2007: 11:58"> Unless I have forgotten something, or being dumb, so if someone could enlighten me I would be very grateful. I have just remembered to put \ infront of the ' (ie class=\'prefix\') before posting, which also works, but I forget why I remember the awnser but not the reasoning, please help me understand again. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/55905-insert-data-to-a-table-i-cant-see-why-it-doesnt-work/#findComment-276242 Share on other sites More sharing options...
AndyB Posted June 17, 2007 Share Posted June 17, 2007 value="17<span class='prefix'>th</span> Jun 2007: 11:58" The value you're passing is everything between the consecutive double quotes. A more rational approach would be to pass the date time as yyyy-mm-dd h:ia and then prettify it when you retrieve and display it. Quote Link to comment https://forums.phpfreaks.com/topic/55905-insert-data-to-a-table-i-cant-see-why-it-doesnt-work/#findComment-276244 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.