BioStatic Posted June 30, 2009 Share Posted June 30, 2009 Here is what I am getting when I installed something, I don't quite understand.. Can someone please help me out? I have my MySQL username, pass and database name setup in the config.php file, so I'm not quite sure what I am doing wrong here.. Here is the (website) http://www.canadianguy.net/images/index.php Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/canadid0/public_html/images/index.php on line 21 Top Ten Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/canadid0/public_html/images/inc/function.php on line 11 the index.php on line 21 I get while($r = mysql_fetch_array($q)) Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/ Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 Post the query, it's failing. You can add or die temporarily to see the error. Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-866713 Share on other sites More sharing options...
BioStatic Posted July 1, 2009 Author Share Posted July 1, 2009 I am such a newb. I'm not exactly sure what you mean. I can open this up in dreamweaver, can I turn it on to see the error there somehow? Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-866867 Share on other sites More sharing options...
Maq Posted July 1, 2009 Share Posted July 1, 2009 Post the code from line 21 and above (lines 1-21), I will explain. Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-866871 Share on other sites More sharing options...
BioStatic Posted July 1, 2009 Author Share Posted July 1, 2009 Oh great, thanks a lot <html> <head> <title>Hotwebtools.com - Rating System Script</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="css/index.css" rel="stylesheet" type="text/css"> </head> <body> <div align="center"> <?php /* This script is developed by David Ausman Hotwebtools.com You may use or redistribute it freely as long as you retain my copyright and does not resell it. Please respect my time & effort implemented on this project. Enjoy */ include 'inc/config.php'; include 'inc/conn.php'; if(empty($cid)) { $q = mysql_query("select min(id) from image"); while($r = mysql_fetch_array($q)) Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-866890 Share on other sites More sharing options...
Maq Posted July 1, 2009 Share Posted July 1, 2009 The error is implying that your actual query isn't valid. Which is this: select min(id) from image Although it looks valid to me, try changing this line: $q = mysql_query("select min(id) from image"); to this: $q = mysql_query("select min(id) from image") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-867083 Share on other sites More sharing options...
BioStatic Posted July 1, 2009 Author Share Posted July 1, 2009 Hmm, I changed that, then I got this on my page. No database selected Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-867185 Share on other sites More sharing options...
Maq Posted July 1, 2009 Share Posted July 1, 2009 Do you have mysql_select_db in your include 'inc/conn.php';? Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-867189 Share on other sites More sharing options...
BioStatic Posted July 1, 2009 Author Share Posted July 1, 2009 This is whats in there. <?php $conn = mysql_connect($host, $username, $password); mysql_select_db($db); ?> Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-867193 Share on other sites More sharing options...
Maq Posted July 1, 2009 Share Posted July 1, 2009 You don't give a value to '$db', which should be your database you want to use. Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-867195 Share on other sites More sharing options...
BioStatic Posted July 2, 2009 Author Share Posted July 2, 2009 So I need to make mysql_select_db($db); into just ($db); ?? Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-867578 Share on other sites More sharing options...
fenway Posted July 2, 2009 Share Posted July 2, 2009 What do you think? Where do you define the value of $db? Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-867587 Share on other sites More sharing options...
BioStatic Posted July 2, 2009 Author Share Posted July 2, 2009 Database name? Something like mysql_select_db('dbname', $dbname); Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-867596 Share on other sites More sharing options...
BioStatic Posted July 2, 2009 Author Share Posted July 2, 2009 Or is it dbname, dblink? Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-867966 Share on other sites More sharing options...
Maq Posted July 2, 2009 Share Posted July 2, 2009 See this code here? $conn = mysql_connect($host, $username, $password); mysql_select_db($db); ?> What is in '$db'? You never assign a value to '$db' so how is mysql_select_db suppose to know what database to select? Same with the parameters in mysql_connect, I fail to see where you assign those values as well. I'm not sure why you didn't receive errors for that first. Quote Link to comment https://forums.phpfreaks.com/topic/164300-warning-mysql_fetch_array/#findComment-867990 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.