List:MySQL on Win32« Previous MessageNext Message »
From:Randy Clamons Date:July 23 2004 10:10pm
Subject:Re: Question about Insert Statement
View as plain text  
Danny,

Does DateStarted have a default value or is it timestamp column. Either way, leave
DateStarted out of your column list and leave the trailing comma off the value list.
Also, even though you probably defined Zip as numeric or integer, you should probably
enclose $leaZip in quotes also in the case an empty value is rec'd (mySQL handles the
data type conversion):

INSERT INTO $db_s_leagues (leaName, leaEmail, leaOwner, Address, City,State, Zip) 
VALUES('$leaName','','$leaOwner','$leaAddress','$leaCity','$leaState','$leaZip')

Randy Clamons
Systems Programming
Astro-auction.com

> ------------Original Message------------
> From: "Danny Willis" <danny.willis@stripped>
> To: <win32@stripped>
> Date: Fri, Jul-23-2004 2:34 PM
> Subject: Question about Insert Statement
> 
> My question/problem I am having is that there may be cases where I do not
> have all the fields full.  From my experimentation and interpretation of the
> documentation if the fields are full and I end up with a query looking like
> this:
> INSERT INTO $db_s_leagues (leaName, leaEmail, leaOwner, Address, City,
> State, Zip, DateStarted) 
> VALUES('$leaName','','$leaOwner','$leaAddress','$leaCity','$leaState',$leaZi
> p,)
> 
> The query fails due to the "''" and the ",)"
> 
> Is there a way to work around this issue so I don't have to code up some
> funky error checking in my php code to check and adjust for any empty data?
> 
> Here is the query I am working with:
> 
> INSERT INTO $db_s_leagues (leaName, leaEmail, leaOwner, Address, City,
> State, Zip, DateStarted) 
> VALUES('$leaName','$leaEmail','$leaOwner','$leaAddress','$leaCity','$leaStat
> e',$leaZip,$leaDateStarted)
> 
> Thanks,
> Dan               
> 
> 
> -- 
> MySQL Windows Mailing List
> For list archives: http://lists.mysql.com/win32
> To unsubscribe:    http://lists.mysql.com/win32?unsub=1
> 
> 
Thread
Using a Blob with the ByteFX data providerNick Randell16 Jul
  • RE: Using a Blob with the ByteFX data providerReggie Burnett19 Jul
    • RE: Using a Blob with the ByteFX data providerNick Randell20 Jul
      • Suggested settings for dual processor machine?East Bay Technologies20 Jul
      • RE: Using a Blob with the ByteFX data providerReggie Burnett20 Jul
      • Should I use myISAM or InnoDB??East Bay Technologies21 Jul
      • Should I use myISAM or InnoDB??East Bay Technologies23 Jul
      • Suggested settings for dual processor machine?East Bay Technologies23 Jul
RE: Should I use myISAM or InnoDB??PF: MySQL23 Jul
  • Question about Insert StatementDanny Willis23 Jul
    • Re: Question about Insert StatementTata Respecia24 Jul
      • Ignoring or filtering ' charCadbury30 Jul
        • Strange site error.Danny Willis30 Jul
        • Re: Ignoring or filtering ' charTiago Serafim30 Jul
          • Re: Ignoring or filtering ' charCadbury4 Aug
            • Re: Ignoring or filtering ' charTiago Serafim4 Aug
              • Re: Ignoring or filtering ' charCadbury5 Aug
        • Re: Ignoring or filtering ' charPetr Vileta30 Jul
          • Re: Ignoring or filtering ' charTiago Serafim30 Jul
Re: Question about Insert StatementRandy Clamons24 Jul