Jump to content

[SOLVED] php - update mysql database - syntax error


airete

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.