unidox Posted September 21, 2007 Share Posted September 21, 2007 The 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 ''div') VALUES ('')' at line 1 The line of code: if ($_REQUEST['m'] == "16") { $div = remslash($_POST['div']); MYSQL_QUERY("INSERT INTO $mysql_table ('div') VALUES ('$div')") or die (mysql_error()); header ("Location: index.php?page=admin_roster"); Quote Link to comment https://forums.phpfreaks.com/topic/70214-solved-error/ Share on other sites More sharing options...
smashbugs Posted September 21, 2007 Share Posted September 21, 2007 No quotes around the column names... ('div') should be (div). Also, I'm sure you know this, but your $div variable needs to be in double quotes (or no quotes) to carry through into the query. The single quotes take it as literal. Quote Link to comment https://forums.phpfreaks.com/topic/70214-solved-error/#findComment-352660 Share on other sites More sharing options...
BlueSkyIS Posted September 21, 2007 Share Posted September 21, 2007 Also, I'm sure you know this, but your $div variable needs to be in double quotes (or no quotes) to carry through into the query. The single quotes take it as literal. Incorrect. Single quotes are not interpreted literally within double quotes. $var = "hello"; $str1 = "This is a string containing '$var' and more text"; echo $str1; // Output is This is a string containing 'hello' and more text Quote Link to comment https://forums.phpfreaks.com/topic/70214-solved-error/#findComment-352681 Share on other sites More sharing options...
smashbugs Posted September 21, 2007 Share Posted September 21, 2007 Sorry, that's not what I meant. I meant that the variable $div in single quotes will actually print '$div' (minus the quotes), instead of the variable's value as in double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/70214-solved-error/#findComment-352699 Share on other sites More sharing options...
unidox Posted September 22, 2007 Author Share Posted September 22, 2007 so what do I change? Quote Link to comment https://forums.phpfreaks.com/topic/70214-solved-error/#findComment-352706 Share on other sites More sharing options...
darkfreaks Posted September 22, 2007 Share Posted September 22, 2007 put ($div) Quote Link to comment https://forums.phpfreaks.com/topic/70214-solved-error/#findComment-352707 Share on other sites More sharing options...
unidox Posted September 22, 2007 Author Share Posted September 22, 2007 Well, I made a new page, heres the code: if ($_REQUEST['m'] == "1") { getHeader(); createJSValid($checkfields,$errors); createForm($titles,$fields,$type,$size,$maxlength,'2'); } if ($_REQUEST['m'] == "2") {; $div = remslash($_POST['div']); $image = remslash($_POST['image']); $check = MYSQL_QUERY("SELECT * FROM $mysql_table WHERE div='$div' || image='$image'") or die (mysql_error()); $rows = mysql_num_rows($check); if ($rows != 0) { showError('This division already exists!'); } else { MYSQL_QUERY("INSERT INTO $mysql_table (div,image) VALUES ('$div','$image')") or die (mysql_error()); showSuccess('Link Added'); header ("Location: index.php?page=admin_divisions"); } I am getting 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 'div='cs' || image='cs'' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/70214-solved-error/#findComment-352710 Share on other sites More sharing options...
smashbugs Posted September 22, 2007 Share Posted September 22, 2007 "SELECT * FROM $mysql_table WHERE div='$div' OR image='$image'" OR not || Quote Link to comment https://forums.phpfreaks.com/topic/70214-solved-error/#findComment-352806 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.