Almost.

$myVar = $myVar == '' ? 'NULL' : "'" . mysql_escape_string($myVar) .
"'";

$query = "INSERT INTO mytable (myvariable) VALUES ($myVar)";

This takes care of the case where $myVar contains apostrophes...


--- Adrian Madrid <[EMAIL PROTECTED]> wrote:
> Not sure but I know this will work:
> 
> $myVariable = $myVariable == '' ? 'NULL' :
> "'$myVariable'";
> $query = "INSERT INTO MYTABLE (MYVARIABLE) VALUES
> ($myVariable)";


=====
PGP Key ID: 071B173D
Fingerprint: ED30 B048 6833 56B4 28C0 CE52 F12B 884A 071B 173D

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to