Saturday, April 25, 2009

MySQL - Resolved null issue in query.

We have faced strange issue with MySql old version (version 4).

Our php file will pass a querystring variable "id". It can have a value or it can be empty in some situation.

Initially, we used below code,

$sql="select school_name from school_table where id=$id";

It was working fine if the $id is assinged with a value.
It showed syntax error if $id is not having any value.

Below workaround resolved the issue.

Added below code above the query.
if ($id=="")
More Articles...

No comments:

Thanks for visiting our blog

twitterlinkedin YouTube subscribe

Subscribe via email

Enter your email address: