You are here: Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL « PHP Language « IT news, forums, messages
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL

Posted by Gleep on 12/21/06 20:10

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация