Re: newbie questions
| From: | David Robley | Date: | Mon, 04 Sep 2000 02:20:25 +0000 |
| Subject: | Re: newbie questions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-15035@lists.php.net to get a copy of this message | ||
On 31 Aug, Colleen R Dick wrote:
> I did a mysql_query put the answer into $result. I checked for
> errors. There aren't any. (When I do this same query from telnet it
> returns the expected nonempty data.) In my program then want to
> access the data from this dataset, so I do the following:
>
> if(!($r=mysql_fetch_array($result))) {
> $err=mysql_error($db);
Try outputting the error regardless...
$r=mysql_fetch_array($result);
$err = mysql_error(); // No argument needed
> print "Error $err fetch array from user_list<br>.\n";
> } else {
> #process this data.....
>
> }
>
> It prints "Error fetch array....."
> and there is no error string and I have absolutely no idea what went
> wrong, especially since in this case I know for a fact that there
> SHOULD be a valid data set pointed to. Does this indicate that
> everything was OK and I just had null data in my original $result or
> what?
>
> OK and another question: The following query causes PARSE errors when
> I feed it to mysql_query. I have gotten other queries kind of like it
> to work. Do I have to encode it or escape it or something? or would
> it just mess up if $uid was undefined?
>
> Here is the line from the code:
>
> $sql = "SELECT h_count from pagehits where u_id=$uid AND
> h_pagename='$page'";
>
> The variable $uid is supposed to be a numeric, and $page is always
> just a string of letters.
>
>
> Thanks for helping a newbie.
Again, use mysql_error to get the error message that mysql passes back;
you could also echo the completed $sql and see if there is anything
obvious there.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA