Jump to content

Recommended Posts

hello,

 

When i try and update the database table 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 'desc='My name is ***** and I\'m a 17-yr. old junior. I play electric ba' at line 1

 

 

what i am doing is having the user fill in a large text area and saving it to a database. So i think the problem could possibly be that they are using ' and " in textarea to mess it up?

 

here is the form:

echo " <form name=\"myForm\" method=\"post\" action=\"$PHP_SELF\">
  					Name:<br /> 
				 	<input name='name' type='text' value='$bioName' size='50' />
  					<br />
  					<br />
  					About:
  					<br />
  					<textarea name='desc' cols='65' rows='10'>$bioDesc</textarea>
  					<br />
					</label><br />
				<input type=\"hidden\" name=\"action\" value=\"bioEditDone\">
				<input type=\"hidden\" name=\"bioId\" value=\"$bioId\">\n
				<input type=\"submit\" name=\"bioSubmit\" value=\"Submit\">
				</form>";

 

and here is the update code:

 

if((count($_POST)>0) && ($_POST['action'] == "bioEditDone")){
	$id = $_POST['id'];
	$name = $_POST['name'];
	$desc = $_POST['desc'];


	$query = "UPDATE family set name='$name', desc='$desc' where id=$id";
	mysql_query($query) or die("Error, upate query failed <br />".mysql_error()." <br />$sql");
	$action = "viewAll";
}

 

 

Thanks for the help ^_^

ok, that cleared up that error. Now i am getting an error but the error feedback is not really helping me at all.

 

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 '' at line 1

 

here is the update mysql part again. I changed the variable and the name in the table

 

if((count($_POST)>0) && ($_POST['action'] == "bioEditDone")){
	$id = $_POST['id'];
	$name = $_POST['name'];
	$descr = $_POST['descr'];


	$query = "UPDATE family SET name = '$name', descr = '$descr' WHERE id = $id";
	mysql_query($query) or die("Error, upate query failed <br />".mysql_error()." <br />$sql");
	$action = "viewAll";
}

 

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.