neridaj Posted April 19, 2008 Share Posted April 19, 2008 Hello, I'm getting this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in output_fns.php on line 416 Here are the two functions involved: function get_user_info($username) { // connect to db $conn = db_connect(); // query user info $result = $conn->query("select first_name, last_name, email from user where username='$username'"); if (!$result) return false; else return $result; } function display_folders() { $userinforesult = get_user_info($username); if(!$userinforesult) echo 'nothing'; else while ($row = mysql_fetch_array($result, MYSQL_NUM)) { // line 416 printf("Last Name: %s Last Name: %s Email: %s", $row[0], $row[1], $row[2]); } echo '<a href="logout.php">Logout</a>'; $userfolder = $_SESSION['valid_user'] . '/'; echo '<table align="center" border="1" cellpadding="5"><tr><th></th></tr><tr>'; $dir = 'members/' . $userfolder; $files = scandir($dir); foreach($files as $value) { if(!in_array($value, array('.', '..'))) { // check for folders if(is_dir($dir.DIRECTORY_SEPARATOR.$value)) { printf('<td><a href="preview.php?pa=%s">'. '<img src="'. $dir . $value .'.jpg" width=75" height="75" />'. '<br />%s<a/></td>', $value, $value); } } } echo '</tr></table>'; } Is it because I'm not using mysql_query? I tried that and I just got connection errors so I reverted back to: $result = $conn->query(), which at least connects and returns something. Is there an alternative to mysql_fetch_array() that I should be using instead? Thanks for any help, Jason Link to comment https://forums.phpfreaks.com/topic/101874-invalid-mysql-result-resource/ Share on other sites More sharing options...
phpretard Posted April 19, 2008 Share Posted April 19, 2008 I would look more into the connection error. Link to comment https://forums.phpfreaks.com/topic/101874-invalid-mysql-result-resource/#findComment-521376 Share on other sites More sharing options...
joinx Posted April 29, 2008 Share Posted April 29, 2008 me too i'm getting same error...here is my code <?php mysql_select_db($database_JaceyConn, $JaceyConn); $sql = "SELECT product_name, product_price, product_status from FROM product WHERE product_id = $productId;"; $result = mysql_query($sql, $JaceyConn); while ($row_result = mysql_fetch_array($result)) { echo $row_result['product_name']; } ?> where is the error? Link to comment https://forums.phpfreaks.com/topic/101874-invalid-mysql-result-resource/#findComment-529842 Share on other sites More sharing options...
moselkady Posted April 29, 2008 Share Posted April 29, 2008 Try to print mysql_error() after your mysql_query(..) statement to check for errors in it Link to comment https://forums.phpfreaks.com/topic/101874-invalid-mysql-result-resource/#findComment-529855 Share on other sites More sharing options...
joinx Posted April 29, 2008 Share Posted April 29, 2008 ok thnx...there was an unknow field... problem solved.. Link to comment https://forums.phpfreaks.com/topic/101874-invalid-mysql-result-resource/#findComment-529862 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.