Re: [PHP] Driving me nuts, need one second of your time
On Friday, March 15, 2002, at 06:14 PM, cosmin laslau wrote: Thanks in advance for whoever sees what I am sure is a glaring and obvious flaw in the coding. I've been looking at it for an hours and just can't get anything from where I'm standing, maybe a different perpective will help. You're declaring your connection parameter as a string db and you probably want it to be a variable $db. Make sure this variable contains a database connection pointer. Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Driving me nuts, need one second of your time
It's not absurd at all. What is absurd is that you're coding without checking for any error conditions :-) As a rule of thumb, if a function returns a success flag, check it. it'll immediately cut out about 90% of all weird errors. cosmin laslau wrote: ? $query = SELECT * from mytable; $result = mysql_db_query(db, $query); while ($myarray = mysql_fetch_array($result)) { $title = $myarray[title]; echo $titlebr; } ? Can someone PLEASE tell me why the coding above gives the following error: Warning: Supplied argument is not a valid MySQL result resource in /var/web/somesite.com/html/index.php on line 5 It's absurd. It's driving me nuts. I'm about to introduce my computer to the pavement 40 feet below. Thanks in advance for whoever sees what I am sure is a glaring and obvious flaw in the coding. I've been looking at it for an hours and just can't get anything from where I'm standing, maybe a different perpective will help. _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Driving me nuts, need one second of your time
Good day, You get this message because the mysql_db_query statement failed, and that your code didn't check to see that it did or not before proceeding to the next statement. And, this statement fails because you have not even connected to the database yet. At the risk of sounding condescending, I would request that you look at PHP's documentation on how to use the MySQL wrapper functions ( http://www.php.net/manual/en/ref.mysql.php ). There you can find good documentation and a number of useful examples (the two best things a coder could ask for). Your error message is also in PHPs FAQ list. http://www.php.net/manual/en/faq.databases.php . Hope this helps, Darren Gamble Planner, Regional Services Shaw Cablesystems GP 630 - 3rd Avenue SW Calgary, Alberta, Canada T2P 4L4 (403) 781-4948 -Original Message- From: cosmin laslau [mailto:[EMAIL PROTECTED]] Sent: Friday, March 15, 2002 4:14 PM To: [EMAIL PROTECTED] Subject: [PHP] Driving me nuts, need one second of your time ? $query = SELECT * from mytable; $result = mysql_db_query(db, $query); while ($myarray = mysql_fetch_array($result)) { $title = $myarray[title]; echo $titlebr; } ? Can someone PLEASE tell me why the coding above gives the following error: Warning: Supplied argument is not a valid MySQL result resource in /var/web/somesite.com/html/index.php on line 5 It's absurd. It's driving me nuts. I'm about to introduce my computer to the pavement 40 feet below. Thanks in advance for whoever sees what I am sure is a glaring and obvious flaw in the coding. I've been looking at it for an hours and just can't get anything from where I'm standing, maybe a different perpective will help. _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Driving me nuts, need one second of your time
It looks like your sql query failed, so the result is invalid. Assuming that this is really the whole script, then you're counting on the mysql_db_query function to open a connection to the database db using the default connection values which (according to the manual) are host: localhost, user: (whatever user is running the script, probably 'www', 'apache', or 'nobody' depending on your system), and password: (blank). Do you really have your mysql database setup to allow access with these defaults? I'd recommend trying mysql_connect() first, then if that works continue on to the mysql_query(). At least you'll know better which aspect failed. -Steve On Friday, March 15, 2002, at 05:14 PM, cosmin laslau wrote: ? $query = SELECT * from mytable; $result = mysql_db_query(db, $query); while ($myarray = mysql_fetch_array($result)) { $title = $myarray[title]; echo $titlebr; } ? Can someone PLEASE tell me why the coding above gives the following error: Warning: Supplied argument is not a valid MySQL result resource in /var/web/somesite.com/html/index.php on line 5 It's absurd. It's driving me nuts. I'm about to introduce my computer to the pavement 40 feet below. Thanks in advance for whoever sees what I am sure is a glaring and obvious flaw in the coding. I've been looking at it for an hours and just can't get anything from where I'm standing, maybe a different perpective will help. _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php