Jump to content

Strange PHP/mySQL error ... am I just tired?


bsamson

Recommended Posts

<?

## CONNECT TO DB FUNCTION!
function ConnectTo($db2con)
{
$hostName = "localhost";
$dbName = "people_".$db2con;
$userName = "people_main";
$password = "normal123";
$link = mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");
mysql_select_db($dbName, $link) or die( "Unable to select database $dbName");
return $link;
}

$conn = ConnectTo("estore");

$query  = "SELECT * FROM CubeCart_inventory";
$result = mysql_query($query) or die(mysql_error());

$num = mysql_num_rows($result);

while ($row=mysql_fetch_array($result)) {

	$prod    = $row['productId'];		
	$cat 	 = $row['categories'];

}

?>

 

I have the above code ... EVERYTIME it runs I get this error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/people/public_html/code/xml/scripts/loadCatIDx.php

 

I do not understand this problem! I understand the error is implying my query returned an error, however when I add echo mysql_num_rows($result) it returns over 2700 records ...

 

Any help would be greatly appreciated!!

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.