Zoud Posted January 15, 2007 Share Posted January 15, 2007 [quote]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 'from) VALUES ('blah blah','blah blah','Zoud')' at line 1[/quote]Here's the page with the error:[code]<?php require("../../includes/layout_top.php"); ?><?php$con = mysql_connect("-","-","-");if (!$con) { die('Error: ' . mysql_error()); }mysql_select_db("news", $con);if(isset($_POST[submit])) {$sql="INSERT INTO sitenews (title, info, from) VALUES ('$_POST[title]','$_POST[info]','$_POST[from]')";if (!mysql_query($sql,$con)) { die('Update was not sent. The error message below was recieved.<br /><br />Error: ' . mysql_error()); } echo "Update has been sent."; } else { echo "Post update below.<br />"; echo "<form action='newspost_home.php' method='post'>"; echo "<br />Username: <input type='text' name='from' />"; echo "<br />Title: <input type='text' name='title' />"; echo "<br />Information: <textarea name='info'></textarea>"; echo "<br /><input type='submit' name='submit' value='Post News!' />"; echo "</form>"; }mysql_close($con)?><?php require("../../includes/layout_bot.php"); ?>[/code]I have a similar script that enters users into a diffrent DB and it works perfectly. Infact I just copy and pasted the script from that one and altered it into this one. The only diffrences are changes in the form and I added one more row in the INSERT INTO & VALUES. Link to comment https://forums.phpfreaks.com/topic/34300-ahhh-errors/ Share on other sites More sharing options...
paul2463 Posted January 15, 2007 Share Posted January 15, 2007 [code]<?php$sql="INSERT INTO sitenews (title, info, `from`) VALUES ('$_POST[title]','$_POST[info]','$_POST[from]')";?>[/code]from is a reserved word in SQL try what I have typed with the backticks on the word `from` so it uses it as a word not a commandPaul Link to comment https://forums.phpfreaks.com/topic/34300-ahhh-errors/#findComment-161381 Share on other sites More sharing options...
paul2463 Posted January 15, 2007 Share Posted January 15, 2007 Here is a list of the <a href="http://developer.mimer.com/validator/sql-reserved-words.tml">Reserved Words</a> Link to comment https://forums.phpfreaks.com/topic/34300-ahhh-errors/#findComment-161385 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.