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, &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
$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*/ > } > } > } |
|
|||
|
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*/ >> } >> } >> } > |
|
|||
|
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*/ >>> } >>> } >>> } |
|
|||
|
:) 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*/ > >>> } > >>> } > >>> } |