phphelp! Posted March 10, 2010 Share Posted March 10, 2010 Hello, I am very new to php so please bare with me. I am getting an error of: "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/home/www.xxx.com/xxx/xxx/online.php on line 176" The code is: $content.= $s; } } function showAll(){ global $PATHTO_IMAGES, $DB_ONLINEPUB, $content; $mysqlDataAllPub = mysql_query( "SELECT * FROM $DB_ONLINEPUB WHERE `publish` = '1' ORDER BY `name` ASC"); $dataLengthAllPub = mysql_num_rows($mysqlDataAllPub); //echo "HELLO DATALENGTH=" .$dataLengthAllPub; $count = 0; $s=''; for ($i=0; $i< $dataLengthAllPub; $i++ ) { $online_pubID = mysql_result( $mysqlDataAllPub , $i, pubID ); $online_name = mysql_result( $mysqlDataAllPub , $i, name ); $online_orderID = mysql_result( $mysqlDataAllPub , $i, orderID ); $s.= '<li > <div id="showallmod"> <div class="con">' .showAllIssues($online_pubID). '</div> </div> </li>'; } $content= $s; } I'm not sure even where to begin troubleshooting this. I thank you in advance for your help Quote Link to comment Share on other sites More sharing options...
schilly Posted March 10, 2010 Share Posted March 10, 2010 start with this: $mysqlDataAllPub = mysql_query( "SELECT * FROM $DB_ONLINEPUB WHERE `publish` = '1' ORDER BY `name` ASC") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
phphelp! Posted March 10, 2010 Author Share Posted March 10, 2010 thank you Schilly, Like I said I am very new to this. I am guessing that you want the message after I replaced the code. it is: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `publish` = '1' ORDER BY `name` ASC' at line 1 Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 10, 2010 Share Posted March 10, 2010 Where is the variable $DB_ONLINEPUB defined. Looks like your query is not being populated properly. To check your query is formatted correctly change $mysqlDataAllPub = mysql_query( "SELECT * FROM $DB_ONLINEPUB WHERE `publish` = '1' ORDER BY `name` ASC") or die(mysql_error()); to $mysqlDataAllPubSQL = "SELECT * FROM $DB_ONLINEPUB WHERE `publish` = '1' ORDER BY `name` ASC"; $mysqlDataAllPub = mysql_query( $mysqlDataAllPubSQL ) or die(mysql_error() . '<br />QUERY: ' . $mysqlDataAllPubSQL ); Quote Link to comment Share on other sites More sharing options...
phphelp! Posted March 10, 2010 Author Share Posted March 10, 2010 I then get a message of: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `publish` = '1' ORDER BY `name` ASC' at line 1 QUERY: SELECT * FROM WHERE `publish` = '1' ORDER BY `name` ASC Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 10, 2010 Share Posted March 10, 2010 Yeah, The variable $DB_ONLINEPUB is not being passed to your showAll() function. Where is this variable defined? Quote Link to comment Share on other sites More sharing options...
phphelp! Posted March 10, 2010 Author Share Posted March 10, 2010 Hey Thank you much wildteen88 I believe that where the variable defined is: if($pubID=="" && $issueID=="" || $task == "showall"){ $task="showall"; showAll(); } if($task=="" && $issueID){ fetchIssueItem(); fetchPages($issueID); } if($task=="fetchissues"){ fetchPubItem(); } if($task=="detail"){ fetchIssueItem(); fetchPages($issueID); } function displayListPubMenu(){ global $PATHTO_IMAGES, $DB_ONLINEPUB; $mysqlDataListPub = mysql_query( "SELECT * FROM $DB_ONLINEPUB WHERE `publish` = '1' ORDER BY `name` ASC"); //SELECT * FROM $DB_WALLPAPER where id!=$id ORDER BY $order_by" ); $dataLengthPub = mysql_num_rows($mysqlDataListPub); $s=''; for ($i=0; $i< $dataLengthPub; $i++ ) { $online_pubID = mysql_result( $mysqlDataListPub, $i, pubID ); $online_name = mysql_result( $mysqlDataListPub, $i, name ); $online_orderID = mysql_result( $mysqlDataListPub, $i, orderID ); $s.= '<li><a href="online.php?task=fetchissues&pubID='.$online_pubID.'" target="_self">'. $online_name . '</a></li>'; } return $s; Quote Link to comment Share on other sites More sharing options...
phphelp! Posted March 11, 2010 Author Share Posted March 11, 2010 Hello, I was wondering if it looks correct, or really what should be changed. Is my variable defined incorrectly? Any help or guidance would be wonderful. Thank you all Quote Link to comment 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.