Jump to content

MySQL error


Matpatnik

Recommended Posts

Hi guys,Is there a way to do something like this or maybe I did a mistake:

if ($action == "edit") {		$actionsql = "WHERE type_id=" . $_GET['id'];	} else {		$actionsql = "ORDER BY type_id";	}	$sql = "SELECT type_id, type_name " .		   "FROM type '" . $actionsql . "'";	$result = mysql_query($sql) or die("<font color=\"#FF0000\">Query Error</font>" . mysql_error());	while ($row = mysql_fetch_array($result)) {		$type_name = $row['type_name'];?>

It was just a test and it failed :) it give me this error message

Query 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 ''WHERE type_id=3'' at line 1
Thank you for your help
Link to comment
Share on other sites

You've got the WHERE or ORDER clause between quotes:

'" . $actionsql . "'

Will be:

FROM type 'WHERE type_id=3'

Must be:

FROM type WHERE type_id=3

So remove the quotes (').

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...