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

how to get values from $_Post with onchange="form.submit();"?
Hi, I have a form that submit to itself with a file upload field and two other hidden field values.<

Get value from Select menu
Hi!

Have tried to find the solution on the web. Don't know if there is an easy one. A descrip

Delete all files in folder except with certain name
I have a script that I want to delete all files in a folder (taken from a database) except for one n

Echo Tweaking help!
HI. I would like to have the output of the entered variables repeat forever, but it's stopping at th

How to grab certain words ??
I am working with this API

Returns JSON.
curl http://letsbetrends.com/api/current_trends

ASP.NET 2.0 - Enter Key - Default Submit Button
Hi,One of the most annoying things in developing web pages is handling the "Enter key" for form subm

Onclick problem in Firefox
Hi,
I am using a . It doesn't seem to

if php cookie set, show code...
Hi all.. I need to figure out this little snippet right quick.. seems like it should be easy enough

how make 2 column in table with data tybe long row
hi every one

I want make in my table 2 column with data tybe long raw

how thi

Creating a custom API
I'm creating a site, and I need to create a basic API. Unfortunately I have no idea where to start.

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