Problem after moving code to new server

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
loxer420
Forum Newbie
Posts: 1
Joined: Wed Oct 06, 2004 3:43 pm

Problem after moving code to new server

Post by loxer420 »

I have recently moved my web application to a shared hosting server running Apache and MySQL from my local Windows 2000 IIS/PHP/MySQL machine. After the move, most of my application works fine, but I am receiving the following message.

Code: Select all

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/website/public_html/webapp/reports_laborerweeklydetail.php on line 23
(line 23 is "while($row_hour...")


Below is my code:

-------> Included file for connection

Code: Select all

<?
session_start();
$db="database_name";
$link = mysql_connect("localhost", "webuser", password") or die ("Could not connect");

mysql_select_db("database_name",$link)
?>
-------> File where error occurs

Code: Select all

$GLOBALS[rowflag] = "ON";
   $sqlquery = "SELECT workdate,description,hours FROM HS00001 WHERE rowid=(".$GLOBALS[rowid].")";
   $result = mysql_query($sqlquery,$link);
   while($row_hour=mysql_fetch_array($result))
{ DO STUFF }

I just don't understand because the versions of PHP are very similar and the rest of the application runs perfectly. This code is included inside of another main reports.php file which runs a case statement to pull this report file.

Anyone have any ideas what environment variables I can look at?


feyd | added

Code: Select all

and

Code: Select all

tags[/color]
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

first thing i saw is your missing a double quote in your mysql_conenct,
use

Code: Select all

tags to make php code apears with colors.
easier to read, more ppl will help..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/size]

you have an error in your query.. I'd bet you need quotes around your $GLOBALS call.. and quote string literals darnit.

Code: Select all

$result = mysql_query($sqlquery, $link) or die(mysql_error());
will tell you more information.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Up your error reporting to E_ALL, read the second link in my sig.

Mac
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

echo

Post by phpScott »

echo your query out, that error message usually means that you are not getting a result back so there is nothing to fetch.

after you get your query run it directly agianst the db to see what the result might be.
Post Reply