RE: [PHP-DB] i am lost (php warning)
Hi it means that the query did not produce a result - usually this is because of a problem with the query. $sql_query = mysql_query("SELECT * FROM cm_customer WHERE emial='$user'"); I am guessing you misspelt email and this should be $sql_query = mysql_query("SELECT * FROM cm_customer WHERE email='$user'"); if you add an error trap it makes this knd of thing easier to spot $sql_query = mysql_query("SELECT * FROM cm_customer WHERE email='$user'") or die(mysql_error()); HTH Peter > -Original Message- > From: Earl Clare [mailto:[EMAIL PROTECTED] > Sent: 18 January 2005 06:59 > To: php-db@lists.php.net > Subject: [PHP-DB] i am lost (php warning) > Importance: High > > > Hi ya'll, > > > > I am lost as to why I am getting this error in my script. Can > anyone kindly > explain why this is so. > > > > Warning: mysql_num_rows(): supplied argument is not a valid MySQL result > resource in /home/cm/public_html/cell/login.php > > > > -- > -- > --- > > My script > > -- > -- > --- > > > > > > if($_POST['submit'] == '>Log In') > > { > > $user=$_POST["email"]; > > $pass=$_POST["pass"]; > > $sql_query = mysql_query("SELECT * FROM cm_customer WHERE > emial='$user'"); > > $sql_query = mysql_num_rows($sql_query); > > > > if (($sql_query) >0) > > { > > $valid = $user; > > session_start(); > > session_register("valid"); > > } > > } > > > > if (session_is_registered("reg")) > > { > > echo "ok"; > > } > > > > else > > { > > echo "sorry"; > > } > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] i am lost (php warning)
it means mysql_query() filed. u must check it before using mysql_fetch_row() f.e. $query = "bla bla bla"; $result = mysql_query( $query ); if ( $result ){ while ( $row = mysql_fetch_row( $result ) ){ } } else { echo mysql_error( $db_connect ); exit; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] i am lost (php warning)
The mysql_num_rows function requires that the argument passed to it should be a valid MySQL result from a Select statement. Your script doesn't explicitly establish a connection with the database so you could be getting an error from that call, hence $sql_query would not be a valid MySQL result. Try adding the following: if (!$sql_query) { die('Invalid query: ' . mysql_error()); } graeme Earl Clare wrote: Hi ya'll, I am lost as to why I am getting this error in my script. Can anyone kindly explain why this is so. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/cm/public_html/cell/login.php --- My script --- if($_POST['submit'] == '>Log In') { $user=$_POST["email"]; $pass=$_POST["pass"]; $sql_query = mysql_query("SELECT * FROM cm_customer WHERE emial='$user'"); $sql_query = mysql_num_rows($sql_query); if (($sql_query) >0) { $valid = $user; session_start(); session_register("valid"); } } if (session_is_registered("reg")) { echo "ok"; } else { echo "sorry"; } -- Experience is a good teacher, but she sends in terrific bills. Minna Antrim
RE: [PHP-DB] i am lost (php warning)
Hey thanks guys, the email was the problem I had emial instead of email Thanks for the assistance. -Original Message- From: Peter Lovatt [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 18, 2005 1:45 AM To: Earl Clare; php-db@lists.php.net Subject: RE: [PHP-DB] i am lost (php warning) Hi it means that the query did not produce a result - usually this is because of a problem with the query. $sql_query = mysql_query("SELECT * FROM cm_customer WHERE emial='$user'"); I am guessing you misspelt email and this should be $sql_query = mysql_query("SELECT * FROM cm_customer WHERE email='$user'"); if you add an error trap it makes this knd of thing easier to spot $sql_query = mysql_query("SELECT * FROM cm_customer WHERE email='$user'") or die(mysql_error()); HTH Peter > -Original Message- > From: Earl Clare [mailto:[EMAIL PROTECTED] > Sent: 18 January 2005 06:59 > To: php-db@lists.php.net > Subject: [PHP-DB] i am lost (php warning) > Importance: High > > > Hi ya'll, > > > > I am lost as to why I am getting this error in my script. Can > anyone kindly > explain why this is so. > > > > Warning: mysql_num_rows(): supplied argument is not a valid MySQL result > resource in /home/cm/public_html/cell/login.php > > > > -- > -- > --- > > My script > > -- > -- > --- > > > > > > if($_POST['submit'] == '>Log In') > > { > > $user=$_POST["email"]; > > $pass=$_POST["pass"]; > > $sql_query = mysql_query("SELECT * FROM cm_customer WHERE > emial='$user'"); > > $sql_query = mysql_num_rows($sql_query); > > > > if (($sql_query) >0) > > { > > $valid = $user; > > session_start(); > > session_register("valid"); > > } > > } > > > > if (session_is_registered("reg")) > > { > > echo "ok"; > > } > > > > else > > { > > echo "sorry"; > > } > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php