Jump to content

syntax error after adding else statement


jeff5656

Recommended Posts

I want to sort by column which works, however I want to make the default sort colum "rm_loc"

However, when I add the else statement, I get

 

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

 

$query = "SELECT * FROM `icu` WHERE `signoff_status` = 'a' AND `pod` = '". $pod ."' ";

$column_name=$_GET['column_name'];

if(isset($column_name) and strlen($column_name)>0){
$query = $query . " order by $column_name ";
} 
else {
$query = $query . " order by $rm_loc ";
}

 

 

1.  They do contain something.  But if they didn't would it give me a syntax error>?

2.  The ticks are not the problem.  Like I said, the syntax error came about AFTER I added the last three lines of the else statement.  Everything above works.

 

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.