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

Calling a Procedure with IN & OUT Parameters
Hello,

I usually call my procedures using the following way

declare variable e

delete comma
HI,

How to delete "," at the end of the string.
Code: $match = 2009/02/03/a2corr

New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understan

how to validate date using javascript
I need to validate date in textbox using javascript..
The date is must be not greater than TODAY

check if string contain only a-z/A-Z
Is where any way to check if string contains only a-z/A-Z, without writing an array with all possibl

array_combine() trouble w/csv file
I have a problem with a piece of code I wrote to import some records from a csv file into mysql. I h

Help with page encoding issue and weird characters
I'm trying to write a screen scraper and when I pull out the lines of the html file that I'm interes

Change image filetype on upload?
Hi,
I've got a form which uploads an image to the server.
Is it possible to change the image t

how to easy edit text, with box? Help.
Hi.
I have a little problem. I'm doing a webpage for my aunt and I would like to make it as easy

with clause
hi all, i have a big query that usually access the same table more than once. for example, i have s

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