[PHP] MySQL error... but it works!!??
Does anyone have any idea why this is giving me a "Warning: Supplied argument is not a valid MySQL result resource in..." error? The funny thing is that apart from that error message it works perfectly!! --- $crdate = date("Y-m-d"); $result = mysql_query("SELECT * FROM sites WHERE creation_date = '$crdate' AND status = 'T'"); while ($sitedata = mysql_fetch_array($result)) { echo $sitedata['name'] . ""; } --- Cheers Simon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySQL error... but it works!!??
> Does anyone have any idea why this is giving me a "Warning: Supplied > argument is not a valid MySQL result resource in..." error? You'll have to give more code, which line you get that error from, etc., to give us a better idea why it's "not working." However, a quick tip: > $crdate = date("Y-m-d"); > $result = mysql_query("SELECT * FROM sites WHERE creation_date = '$crdate' > AND status = 'T'"); These two lines can be condensed since MySQL has a built-in function to get the current time/date: SELECT * FROM sites WHERE creation_date = NOW() AND status = 'T' -Adam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Fw: [PHP] MySQL error... but it works!!??
- Original Message - From: "Bas van Rooijen" <[EMAIL PROTECTED]> To: "Adam Baratz" <[EMAIL PROTECTED]> Sent: Saturday, January 05, 2002 4:39 PM Subject: Re: [PHP] MySQL error... but it works!!?? > > maybe try: > > if (!$result) > { >echo(mysql_error()); > } > > bvr. > On Sat, 5 Jan 2002 15:55:39 -0500, Adam Baratz wrote: > > >> Does anyone have any idea why this is giving me a "Warning: Supplied > >> argument is not a valid MySQL result resource in..." error? > > > >You'll have to give more code, which line you get that error from, etc., to > >give us a better idea why it's "not working." > > > >However, a quick tip: > > > >> $crdate = date("Y-m-d"); > >> $result = mysql_query("SELECT * FROM sites WHERE creation_date = '$crdate' > >> AND status = 'T'"); > > > >These two lines can be condensed since MySQL has a built-in function to get > >the current time/date: > > > >SELECT * FROM sites WHERE creation_date = NOW() AND status = 'T' > > > >-Adam > > > > > >-- > >PHP General Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySQL error... but it works!!??
Hi, So far the best way to troubleshoot mysql+php for me has been to add an "or die" after the sql exec. $crdate = date("Y-m-d"); $result = mysql_query("SELECT * FROM sites WHERE creation_date = '$crdate' AND status = 'T'") or die ('CAN NOT EXEC SQL'); Or you can do $sql = "SELECT * FROM sites WHERE creation_date = '$crdate' AND status = 'T'"; echo $sql; $result = mysql_query($sql) or die .; and try to run your sql against mysql directly to make sure your sql is fine. one thing to always check is your connection to the database. did you connect? Simon Kimber <[EMAIL PROTECTED]> wrote: Does anyone have any idea why this is giving me a "Warning: Supplied argument is not a valid MySQL result resource in..." error? The funny thing is that apart from that error message it works perfectly!! --- $crdate = date("Y-m-d"); $result = mysql_query("SELECT * FROM sites WHERE creation_date = '$crdate' AND status = 'T'"); while ($sitedata = mysql_fetch_array($result)) { echo $sitedata['name'] . " "; } --- Cheers Simon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] Mehmet Erisen http://www.erisen.com - Do You Yahoo!? Send FREE video emails in Yahoo! Mail.