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


Posted on 16th Feb 2014 07:03 pm by admin

Code: <?

## 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!!

No comments posted yet

Your Answer:

Login to answer
95 Like 32 Dislike
Previous forums Next forums
Other forums

batch file not building to webapps folder
Hello. I just started running Vista :P and can't seem to get my projects deployed. I found out how

The page should be expire when cilck back button
hi,
i'm new to php world.
i create user registration page.
when i submit it,data goes to my

Dump with added_funcion cl_salv_table
Hi there, I'm having some troubles adding a self defined function to an ALV in fullscreen. The thing

DYNPRO_FIELD_CONVERSION
Hi gurus,

I got a dump when I run one of my program. the dump is described below:

Save cookie to DB
I'm working on a pixel tracking script for an incentive website and I need to use an ASP script to s

Perplexing problem showing a .jpg
Please disregard..........I figured it out

foreach and array need help combining
Hi guys.

Here's the code

Code: array(
'tag' => 'code',<

Pagination
Hi All,

I think I'm finally getting somewhere with pagination!

I can now submit a quer

Displaying pictures
i have worked my way through storing images in directory and storing the location in mySQL db.Now i

newbie question
Hi out thereIm totaly new in this forum and to .net and vb so here is a totaly newbie question.I wan

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash