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; On 20 Dec 2006 22:23:11 -0800, "jay2006" <tigersta@iinet.net.au> wrote: >Hi, &...


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

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

On 20 Dec 2006 22:23:11 -0800, "jay2006" <tigersta@iinet.net.au> wrote:

>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*/
> }
> }
>}





If you are going to use an array variable inside a select query must be enclosed with
curly brackets {} and don't think you need that $link at the end

$sql = mysql_query("SELECT C_USER_NAME FROM CUSTOMER where C_USER_NAME = '{$cus[8]}' ");
or
$sql = mysql_query("SELECT C_USER_NAME FROM CUSTOMER where C_USER_NAME = ' ".$cus[8]." ' ");


also mysql connections are automatically closed when a page is finsihed processing.

mysql_close() closes the non-persistent connection to the MySQL server that's associated with the
specified link identifier. If link_identifier isn't specified, the last opened link is used.

Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed
at the end of the script's execution.


Reply With Quote
  #12 (permalink)  
Old 12-25-2006
hackajar@gmail.com
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

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

Replace above with this:
$query = "SELECT C_USER_NAME FROM CUSTOMER where
C_USER_NAME = '".$cus[8]."';"; //NOTE: brack out of quotes when
referencing Array hash elemets ;)
$result = mysql_query($query) or die(mysql_error());

-Hackajar
jay2006 wrote:
> 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
  #13 (permalink)  
Old 12-25-2006
Ric
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

hackajar@gmail.com schrieb:
> $sql = mysql_query("SELECT C_USER_NAME FROM CUSTOMER where
> C_USER_NAME = '$cus[8]'", $link);
>
> Replace above with this:
> $query = "SELECT C_USER_NAME FROM CUSTOMER where
> C_USER_NAME = '".$cus[8]."';"; //NOTE: brack out of quotes when
> referencing Array hash elemets ;)



--> '".$cus[8]."'

I think you meant: '"' .$cus[8]. '"'






> $result = mysql_query($query) or die(mysql_error());
>
> -Hackajar
> jay2006 wrote:
>> 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
  #14 (permalink)  
Old 12-25-2006
Ric
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

Ric schrieb:
> hackajar@gmail.com schrieb:
>> $sql = mysql_query("SELECT C_USER_NAME FROM CUSTOMER where
>> C_USER_NAME = '$cus[8]'", $link);
>>
>> Replace above with this:
>> $query = "SELECT C_USER_NAME FROM CUSTOMER where
>> C_USER_NAME = '".$cus[8]."';"; //NOTE: brack out of quotes when
>> referencing Array hash elemets ;)

>
>
> --> '".$cus[8]."'
>
> I think you meant: '"' .$cus[8]. '"'


Ah no your sql staement should be correct, I was just thinking about:


$query = 'SELECT C_USER_NAME FROM CUSTOMER where
C_USER_NAME = "' .$cus[8]. '";' ;


>
>
>
>
>
>
>> $result = mysql_query($query) or die(mysql_error());
>>
>> -Hackajar
>> jay2006 wrote:
>>> 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
  #15 (permalink)  
Old 12-26-2006
hackajar@gmail.com
 
Posts: n/a
Default Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

:) cought you off guard ;)

Hackajar
Ric wrote:
> Ric schrieb:
> > hackajar@gmail.com schrieb:
> >> $sql = mysql_query("SELECT C_USER_NAME FROM CUSTOMER where
> >> C_USER_NAME = '$cus[8]'", $link);
> >>
> >> Replace above with this:
> >> $query = "SELECT C_USER_NAME FROM CUSTOMER where
> >> C_USER_NAME = '".$cus[8]."';"; //NOTE: brack out of quotes when
> >> referencing Array hash elemets ;)

> >
> >
> > --> '".$cus[8]."'
> >
> > I think you meant: '"' .$cus[8]. '"'

>
> Ah no your sql staement should be correct, I was just thinking about:
>
>
> $query = 'SELECT C_USER_NAME FROM CUSTOMER where
> C_USER_NAME = "' .$cus[8]. '";' ;
>
>
> >
> >
> >
> >
> >
> >
> >> $result = mysql_query($query) or die(mysql_error());
> >>
> >> -Hackajar
> >> jay2006 wrote:
> >>> 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
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 11:55 AM.


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