MDanz Posted July 5, 2010 Share Posted July 5, 2010 i get this 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 's',0,'',0)' at line 1 i don't see what i've done wrong. mysql_connect("localhost", "Master", "pword"); mysql_select_db("db"); $id = $_GET['id']; $keywords = $_GET['search']; $totalid = $id-1; $id = mysql_real_escape_string($id)or die (mysql_error()); ## always do this!!!! $result = mysql_query("SELECT * FROM Stacks WHERE origin=$totalid and keywords='$keywords'")or die (mysql_error()); while ($row = mysql_fetch_array($result)) { $name = $row['reply']; $image = $row['image']; } $username1 = $_SESSION['username']; $ip = $_SERVER['REMOTE_ADDR']; $query = "INSERT INTO suscribed"; $query .= "(`username`,`ip`,`name`,`topicid`,`image`,`origin`) VALUES ('$username1','$ip','$name',$totalid,'$image',$totalid)"; $results = mysql_query($query)or die (mysql_error()); if($query){ print "<br><font color=white>You have suscribed. <FORM><INPUT TYPE='button' VALUE='Return' onClick='history.go(-1);return true;'> </FORM>"; } else { print "No image selected/uploaded"; } Link to comment https://forums.phpfreaks.com/topic/206819-error-in-sql-syntaxline-1/ Share on other sites More sharing options...
therelelogo Posted July 5, 2010 Share Posted July 5, 2010 ...might sound silly, but did you remember your <?php ?> tags? Link to comment https://forums.phpfreaks.com/topic/206819-error-in-sql-syntaxline-1/#findComment-1081627 Share on other sites More sharing options...
MDanz Posted July 5, 2010 Author Share Posted July 5, 2010 lol yes.. any idea why it isn't working? it looks perfect.. Link to comment https://forums.phpfreaks.com/topic/206819-error-in-sql-syntaxline-1/#findComment-1081630 Share on other sites More sharing options...
trq Posted July 5, 2010 Share Posted July 5, 2010 You need to run all user inputted data through mysql_real_escape_string. Link to comment https://forums.phpfreaks.com/topic/206819-error-in-sql-syntaxline-1/#findComment-1081631 Share on other sites More sharing options...
MDanz Posted July 5, 2010 Author Share Posted July 5, 2010 thanks, got it working. Link to comment https://forums.phpfreaks.com/topic/206819-error-in-sql-syntaxline-1/#findComment-1081634 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.