Re: [PHPLIB] 0 is not? From: James K. Wiggs (wiggs <email protected>)
Date: 01/13/00

On Thu, 13 Jan 2000, Damien Moody wrote:

> The code leading up to the warning is:
>
> if($id)
> {
> if($submit)
> {
> //Update database
> $sql = "update user set
> firstname='$firstname',middlename='$middlename',lastname='$lastname' where
> id=$id";
> $result = mysql_query($sql);
> echo "Information has been updated.\n";
> }
> else
> {
> //Query database
> $sql = "select from user where id=$id";
> $result = mysql_query($sql);
> $myrow = mysql_fetch_row($result);
>
>
> with the last line being "line 32".

   I suspect that the problem here is that you have no single quotes ''
around the $id variable in your query. If the $id variable is not a
numeric variable, this may (probably will) give you problems.

   If this is not the case, try looking to be *sure* that those table
entries really are named "firstname", "middlename", "lastname". If it was
me, I'd put a space after the commas in that query, as well. Can't recall
if MySQL requires them or not, but the source that comes out from a
mysqldump call always has them, so I use them.

> I was also wondering if it has to do with the table I'm trying to query.
> There is an auto_increment int primary key. When I "select * from table" the
> first number is always "1" even though I set the default to '0'. How do I
> resolve this?

   I'm afraid that on this one I can't be much help. It sounds to me like
the auto_increment is doing its thing, incrementing with every entry.
What if you set the default to -1?

regards,
Jim Wiggs

> Thanks,
> Damien
>
> > From: Philip Strnad <pdstrnad <email protected>>
> > Date: Thu, 13 Jan 2000 13:19:57 -0500
> > To: Damien Moody <damienm <email protected>>
> > Subject: Re: [PHPLIB] 0 is not?
> >
> > Usually it means that you're trying to do something with a result set
> > from a MySQL query, but the result index doesn't exist because of an
> > error in the code.
> >
> > What does the code look like?
> >
> > -Philip
> >
> > Damien Moody wrote:
> >>
> >> I get the following:
> >>
> >> Warning: 0 is not a MySQL result index in
> >> /home/httpd/html/damien/ENTERDATA.PHP3 on line 32
> >>
> >> I'm trying to set up a simple add/edit/remove your name from a list script.
> >> What does this warning mean and how do I fix it?
> >>
> >> -
> >> PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
> >> To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
> >> the body, not the subject, of your message.
>
> -
> PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
> To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
> the body, not the subject, of your message.
>

-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.