Not sure but I know this will work:

$myVariable = $myVariable == '' ? 'NULL' :
"'$myVariable'";
$query = "INSERT INTO MYTABLE (MYVARIABLE) VALUES
($myVariable)";

--- Michael Ryan Byrd <[EMAIL PROTECTED]> wrote:
> > $query = "INSERT INTO MYTABLE (MYVARIABLE)
> > VALUES(NULL)";
> 
> Right-o, but I really want to assign a variable
> something in PHP. I guess my
> real question is this-- is a php NULL the same as a
> MySQL NULL? or is a php
> empty string '' the same as a MySQL NULL?
> 
> > 
> > 
> > --- Michael Ryan Byrd <[EMAIL PROTECTED]> wrote:
> > > So I want to insert a NULL value into a column
> of a
> > > MySQL table from my PHP
> > > script:
> > > 
> > > Do I 
> > > 
> > > $myVariable=NULL;
> > > 
> > > or
> > > 
> > > $myVariable='';
> > > 
> > > (or either?)
> > > 
> > > $query = "INSERT INTO MYTABLE (MYVARIABLE)
> > > VALUES('$myVariable')";
> > > $result=mysql_query($query) or die ("oops!");
> > > 
> > > 
> > > Ideas?
> > > 
> > > 
> > > ____________________
> > > BYU Unix Users Group 
> > > http://uug.byu.edu/ 
> > >
> >
>
___________________________________________________________________
> > > List Info:
> >
> http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
> > 
> > 
> > =====
> > -----------------------------
> > Adrian Esteban Madrid
> > HyperXMedia, Developer
> > ================
> > 
> > ____________________
> > BYU Unix Users Group 
> > http://uug.byu.edu/ 
> >
>
___________________________________________________________________
> > List Info:
> http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
> 
> 
> ____________________
> BYU Unix Users Group 
> http://uug.byu.edu/ 
>
___________________________________________________________________
> List Info:
http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list


=====
-----------------------------
Adrian Esteban Madrid
HyperXMedia, Developer
================

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

Reply via email to