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)
Did you know?Explore Trending and Topic pages for more stories like this.
{
$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

Accessing Infotype data in dialog program
Hi All
In Dialog programs attributes I didn't see any logical database field. How can I access

Implementing Single Sign-On using SAML 1.1, x.509, LDAP in C#.net
Hi, I got a requirement from the client i.e implementing single sing on using SAML 1.1( LDAP &

Dynamic memory problem
Hey,

At the beginning of my code, I have this line:

Shape* gShape = 0;

sapgui f4 help last search
I know this has to be simople. One user (maybe more) does not have the "last search saved" from the

issues verifying if user is logged in
I am having issues when a user logs in via asp Login control, the IsAuthenticated still seems to com

how can i make a .gif images for my site
Dear Friends ,

Pls solve my problem , I am starting making new site but i dont know how can i

Content-Disposition: attachment; filename=... not working as i thought it should
taken the following code from the php.net site the script is not working.

what is not happeni

Basic Forum Tutorial
Hi, I'm new to PHP. I want to build a basic forum for my site using PHP and MySQL. I've searched t

How do I replace any number of character occurences with one occurrence?
How do I replace any number of character occurences with one occurrence?

Let's say I have:

Display thumbnails as square while retaining aspect ratio
I am trying to figure out a way to make an image display as a square, for example 80x80 pixels, when

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