Jump to content

mysql_num_rows(): error please help


phphelp!

Recommended Posts

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 ); 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.