Warning: mysql_num_rows(): supplied argument is not a valid MySQL

This is a discussion on Warning: mysql_num_rows(): supplied argument is not a valid MySQL within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I keep getting this error after registration, does anyone know the fix? Thanks. Warning: mysql_num_rows(): supplied argument is not ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-21-2006
jay2006
 
Posts: n/a
Default Warning: mysql_num_rows(): supplied argument is not a valid MySQL

Hi,

I keep getting this error after registration, does anyone know the fix?
Thanks.


Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in /insert.php on line 117

Warning: Cannot modify header information - headers already sent by
(output started at /insert.php:117)
in /insert.php on line 128

Warning: Cannot modify header information - headers already sent by
(output started at /insert.php:117)
in /insert.php on line 129


if($num3 != 0)
{
$msg = ("<b>Email Already Registered:</b><br>We are sorry but the
email you have entered has already been registered, please use another
or try to recover your previous account.");
mysql_close($link);
}
else
{
$sql = mysql_query("SELECT C_USER_NAME FROM CUSTOMER where
C_USER_NAME = '$cus[8]'", $link);
line 117>>> $num = mysql_num_rows($sql);

if($num != 0)
{
$msg = ("<b>Username Already In Use:</b><br>We are sorry but the
username you have chosen has already been taken. Please go back and try
another or add numbers to make it unique.");
mysql_close($link);
}
else
{
mysql_query("INSERT INTO customer (C_TITLE, C_FNAME, C_SNAME,
C_ADDRESS, C_ADDRESS2, C_TOWN, C_COUNTY, C_PCODE, C_TEL_NUM, C_EMAIL,
C_PWORD, C_USER_NAME, C_KEY, C_SECRET_A, C_SECRET_Q, C_MAIL_TYPE)
values
(UPPER('$cus[0]'),UPPER('$cus[1]'),UPPER('$cus[2]'),UPPER('$cus[3]'),UPPER('$add2'),UPPER('$cus[4]'),UPPER('$cus[5]'),UPPER('$cus[6]'),'$cus[7]',LOWER('$email'),'$pword','$cus[8]','$cUsername','$cus[10]','$cus[9]','$type')",
$link);
mysql_close($link);
setcookie("key:", $cUsername, time()+300); // sets cookie
header("Location: activate.php"); // directs to activation script*/
}
}
}

Reply With Quote
  #2 (permalink)  
Old 12-21-2006
Geoff Berrow
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

Message-ID: <1166682191.046574.280090@f1g2000cwa.googlegroups. com> from
jay2006 contained the following:

>Warning: mysql_num_rows(): supplied argument is not a valid MySQL
>result resource in /insert.php on line 117


Your query is failing
>
>Warning: Cannot modify header information - headers already sent by
>(output started at /insert.php:117)
>in /insert.php on line 128
>
>Warning: Cannot modify header information - headers already sent by
>(output started at /insert.php:117)
>in /insert.php on line 129


These are created because php has echoed a warning before your header
call
>
>
> if($num3 != 0)
> {
> $msg = ("<b>Email Already Registered:</b><br>We are sorry but the
>email you have entered has already been registered, please use another
>or try to recover your previous account.");
> mysql_close($link);
> }
> else
> {
> $sql = mysql_query("SELECT C_USER_NAME FROM CUSTOMER where
>C_USER_NAME = '$cus[8]'", $link);
>line 117>>> $num = mysql_num_rows($sql);



Do this:
$s=SELECT C_USER_NAME FROM CUSTOMER where C_USER_NAME = '$cus[8]'";
$sql = mysql_query($s, $link);

That way your can debug the SQL statement by doing
echo $s;

Also you can do this which gives you more info
$sql = mysql_query($s, $link) or die(mysql_error());

You haven't shown your database connection section. Is that ok, did you
remember to include it?


--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Reply With Quote
  #3 (permalink)  
Old 12-21-2006
jay2006
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

Oops, sorry, I thought to just add the error parts. I'll give what you
said a go and will let you know how it goes.

Thanks



Geoff Berrow wrote:
> Message-ID: <1166682191.046574.280090@f1g2000cwa.googlegroups. com> from
> jay2006 contained the following:
>
> >Warning: mysql_num_rows(): supplied argument is not a valid MySQL
> >result resource in /insert.php on line 117

>
> Your query is failing
> >
> >Warning: Cannot modify header information - headers already sent by
> >(output started at /insert.php:117)
> >in /insert.php on line 128
> >
> >Warning: Cannot modify header information - headers already sent by
> >(output started at /insert.php:117)
> >in /insert.php on line 129

>
> These are created because php has echoed a warning before your header
> call
> >
> >
> > if($num3 != 0)
> > {
> > $msg = ("<b>Email Already Registered:</b><br>We are sorry but the
> >email you have entered has already been registered, please use another
> >or try to recover your previous account.");
> > mysql_close($link);
> > }
> > else
> > {
> > $sql = mysql_query("SELECT C_USER_NAME FROM CUSTOMER where
> >C_USER_NAME = '$cus[8]'", $link);
> >line 117>>> $num = mysql_num_rows($sql);

>
>
> Do this:
> $s=SELECT C_USER_NAME FROM CUSTOMER where C_USER_NAME = '$cus[8]'";
> $sql = mysql_query($s, $link);
>
> That way your can debug the SQL statement by doing
> echo $s;
>
> Also you can do this which gives you more info
> $sql = mysql_query($s, $link) or die(mysql_error());
>
> You haven't shown your database connection section. Is that ok, did you
> remember to include it?
>
>
> --
> Geoff Berrow 0110001001101100010000000110
> 001101101011011001000110111101100111001011
> 100110001101101111001011100111010101101011


Reply With Quote
  #4 (permalink)  
Old 12-21-2006
jay2006
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

I added:


$s=SELECT C_USER_NAME FROM CUSTOMER where C_USER_NAME = '$cus[8]'";
$sql = mysql_query($s, $link);


Then tried to register and got the following error:


Parse error: syntax error, unexpected T_STRING in
/home/squirt/public_html/mature/files/insert.php on line 116




jay2006 wrote:
> Oops, sorry, I thought to just add the error parts. I'll give what you
> said a go and will let you know how it goes.
>
> Thanks
>
>
>
> Geoff Berrow wrote:
> > Message-ID: <1166682191.046574.280090@f1g2000cwa.googlegroups. com> from
> > jay2006 contained the following:
> >
> > >Warning: mysql_num_rows(): supplied argument is not a valid MySQL
> > >result resource in /insert.php on line 117

> >
> > Your query is failing
> > >
> > >Warning: Cannot modify header information - headers already sent by
> > >(output started at /insert.php:117)
> > >in /insert.php on line 128
> > >
> > >Warning: Cannot modify header information - headers already sent by
> > >(output started at /insert.php:117)
> > >in /insert.php on line 129

> >
> > These are created because php has echoed a warning before your header
> > call
> > >
> > >
> > > if($num3 != 0)
> > > {
> > > $msg = ("<b>Email Already Registered:</b><br>We are sorry but the
> > >email you have entered has already been registered, please use another
> > >or try to recover your previous account.");
> > > mysql_close($link);
> > > }
> > > else
> > > {
> > > $sql = mysql_query("SELECT C_USER_NAME FROM CUSTOMER where
> > >C_USER_NAME = '$cus[8]'", $link);
> > >line 117>>> $num = mysql_num_rows($sql);

> >
> >
> > Do this:
> > $s=SELECT C_USER_NAME FROM CUSTOMER where C_USER_NAME = '$cus[8]'";
> > $sql = mysql_query($s, $link);
> >
> > That way your can debug the SQL statement by doing
> > echo $s;
> >
> > Also you can do this which gives you more info
> > $sql = mysql_query($s, $link) or die(mysql_error());
> >
> > You haven't shown your database connection section. Is that ok, did you
> > remember to include it?
> >
> >
> > --
> > Geoff Berrow 0110001001101100010000000110
> > 001101101011011001000110111101100111001011
> > 100110001101101111001011100111010101101011


Reply With Quote
  #5 (permalink)  
Old 12-21-2006
-Lost
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

"jay2006" <tigersta@iinet.net.au> wrote in message
news:1166685440.527064.274260@i12g2000cwa.googlegr oups.com...
>I added:
>
>
> $s=SELECT C_USER_NAME FROM CUSTOMER where C_USER_NAME = '$cus[8]'";
> $sql = mysql_query($s, $link);
>
>
> Then tried to register and got the following error:
>
>
> Parse error: syntax error, unexpected T_STRING in
> /home/squirt/public_html/mature/files/insert.php on line 116


You both forgot the first quote around the $s variable.

$s = "SELECT C_USER_NAME FROM CUSTOMER WHERE C_USER_NAME = '$cus[8]'"

-Lost


Reply With Quote
  #6 (permalink)  
Old 12-21-2006
jay2006
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

OK, i tried it with the quote in, and got this error:

Parse error: syntax error, unexpected T_VARIABLE in
/home/squirt/public_html/mature/files/insert.php on line 117



$s = "SELECT C_USER_NAME FROM CUSTOMER WHERE C_USER_NAME = '$cus[8]'"
line 117 >>>> $sql = mysql_query($s, $link);


-Lost wrote:
> "jay2006" <tigersta@iinet.net.au> wrote in message
> news:1166685440.527064.274260@i12g2000cwa.googlegr oups.com...
> >I added:
> >
> >
> > $s=SELECT C_USER_NAME FROM CUSTOMER where C_USER_NAME = '$cus[8]'";
> > $sql = mysql_query($s, $link);
> >
> >
> > Then tried to register and got the following error:
> >
> >
> > Parse error: syntax error, unexpected T_STRING in
> > /home/squirt/public_html/mature/files/insert.php on line 116

>
> You both forgot the first quote around the $s variable.
>
> $s = "SELECT C_USER_NAME FROM CUSTOMER WHERE C_USER_NAME = '$cus[8]'"
>
> -Lost


Reply With Quote
  #7 (permalink)  
Old 12-21-2006
Geoff Berrow
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

Message-ID: <1166695793.854577.17810@f1g2000cwa.googlegroups.c om> from
jay2006 contained the following:

>OK, i tried it with the quote in, and got this error:
>
>Parse error: syntax error, unexpected T_VARIABLE in
>/home/squirt/public_html/mature/files/insert.php on line 117
>
>
>
>$s = "SELECT C_USER_NAME FROM CUSTOMER WHERE C_USER_NAME = '$cus[8]'"
>line 117 >>>> $sql = mysql_query($s, $link);


Missing semi-colon

$s = "SELECT C_USER_NAME FROM CUSTOMER WHERE C_USER_NAME = '$cus[8]'";
$sql = mysql_query($s, $link);
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Reply With Quote
  #8 (permalink)  
Old 12-21-2006
jay2006
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

Yeah! thnx for your help guys!! It works now. Appreciate :)

Geoff Berrow wrote:
> Message-ID: <1166695793.854577.17810@f1g2000cwa.googlegroups.c om> from
> jay2006 contained the following:
>
> >OK, i tried it with the quote in, and got this error:
> >
> >Parse error: syntax error, unexpected T_VARIABLE in
> >/home/squirt/public_html/mature/files/insert.php on line 117
> >
> >
> >
> >$s = "SELECT C_USER_NAME FROM CUSTOMER WHERE C_USER_NAME = '$cus[8]'"
> >line 117 >>>> $sql = mysql_query($s, $link);

>
> Missing semi-colon
>
> $s = "SELECT C_USER_NAME FROM CUSTOMER WHERE C_USER_NAME = '$cus[8]'";
> $sql = mysql_query($s, $link);
> --
> Geoff Berrow 0110001001101100010000000110
> 001101101011011001000110111101100111001011
> 100110001101101111001011100111010101101011


Reply With Quote
  #9 (permalink)  
Old 12-21-2006
-Lost
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

"Geoff Berrow" <blthecat@ckdog.co.uk> wrote in message
news:ocoko2to3pavr6sh2k2skbok2eqs0fbme1@4ax.com...
> Message-ID: <1166695793.854577.17810@f1g2000cwa.googlegroups.c om>


> Missing semi-colon


HAHA! Maybe together we can make a somewhat literate programmer!

Be well, Geoff.

-Lost


Reply With Quote
  #10 (permalink)  
Old 12-21-2006
Geoff Berrow
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

Message-ID: <lISdnTU8k6Ew-BfYnZ2dnUVZ_smonZ2d@comcast.com> from -Lost
contained the following:

>
>> Missing semi-colon

>
>HAHA! Maybe together we can make a somewhat literate programmer!


Heh, but the semi-colon wasn't missing in the one you corrected. But
really the OP needs to learn to debug simple stuff like this. I used to
tell my beginner students that they will be glad to see parse errors
because it means that PHP is telling you something is wrong. Much worse
than that is when the program runs without error, but not as you expect.
>
>Be well, Geoff.


You too. I am fine, but my dog has been ill. Mail me if you want to
know more.

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:22 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0