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