![]() |
| ||
| Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Hi There I'm a newcomer to php trying to develop a basic photo album. I have created a simple template in htm, and am trying to use php to show 15 thumbnails per page. However, I am experiencing the error message: "Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/fhlinux177/e/equinefocus.co.uk/user/htdocs/personal/gallery.php on line 26" $db = mysql_connect($hostname, $username, $password) or die ("Unable to connect to MySQL");
LINE 26 is while ($data = mysql_fetch_assoc($result)) { Can anyone point me in the right direction with this problem, please? What is causing it, and how can I correct it? |
| ||
| Re: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource I would use the following code: <?php |
| ||
| Re: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Also use "LIMIT 0,15" |
| ||
| Re: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Thanks for the prompt response. The code now looks like this: http://www.equinefocus.co.uk/personal/gallery.pdf I am getting the error message: Quote:
|
| ||
| Re: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Try using this code: while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) {
Just replace your while statment with the one above. Let me know how it goes!! Regards, Alex |
| ||
| Re: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Really sorry, it hasn't worked. Error message: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/fhlinux177/e/equinefocus.co.uk/user/htdocs/personal/gallery.php on line 25 |
| ||
| Re: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Your not selecting a database in your code. Try adding mysql_select_db('databasename'); |
| ||
| Re: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Be sure that your column names are correct, including capitalization, and that the table name is correct. You can also do a SELECT * FROM others; for testing until you figure out what the problem is. |
| ||
| Re: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Many thanks for your assistance - adding the line regarding the database removed the error message! Unfortunately, now, I have a blank page, not the photo gallery I was hoping for. Does anyone have any theories on this? http://www.equinefocus.co.uk/personal/gallery.pdf I appreciate your help, thank you. |
| ||
| Re: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource replace your while loop with this: while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) {
This should loop through the images and display them. Obviously edit the <IMG> tag to suit e.g width / height / border, etc. |
| All times are GMT -4. The time now is 8:34 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC