Jump to content

Recommended Posts

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");

Link to comment
https://forums.phpfreaks.com/topic/70214-solved-error/
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/70214-solved-error/#findComment-352681
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/70214-solved-error/#findComment-352710
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.