jay_bo Posted February 27, 2010 Share Posted February 27, 2010 Hey i keep geting a problem with my php script... this is the problem Warning: mysql_query() expects parameter 1 to be string, resource given in C:\xampp\htdocs\Sweet Explosion site2\forgotpassword_checklogin.php on line 15 Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xampp\htdocs\Sweet Explosion site2\forgotpassword_checklogin.php on line 18 Warning: mysql_fetch_row() expects parameter 1 to be resource, null given in C:\xampp\htdocs\Sweet Explosion site2\forgotpassword_checklogin.php on line 20 <?php include("dblogin.php");//Includes the database connection details $newpass1=$_POST["newpass1"]; $newpass2=$_POST["newpass2"]; if ($newpass1==$_POST["newpass2"] && $newpass2==$_POST["newpass1"]) { // username and password sent from form $myusername=$_POST["myusername"]; $mypassword=$_POST["mypassword"]; $newpass=md5($_POST["newpass1"]); $sql=mysql_query("SELECT * FROM temp_members WHERE username='$myusername' and password='$mypassword'"); $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row $rows = mysql_fetch_row($result); if($count==1){ $title=$rows['title']; $username=$rows['username']; $firstname=$rows['firstname']; $lastname=$rows['lastname']; $email=$rows['email']; $number=$rows['number']; $street=$rows['street']; $postcode=$rows['postcode']; $town=$rows['town']; $county=$rows['county']; $telephone=$rows['telephone']; $alternative_telephone=$rows['alternative_telephone']; } // Insert data that retrieves from "temp_members_db" into table "registered_members" $sql2="Update login SET title='$title', username='$username', password='$newpass', firstname='$firstname', lastname='$lastname', email='$email', number='$number', street='$street', postcode='$postcode', town='$town', county='$county', telephone='$telephone', alternative_telephone='$alternative_telephone'WHERE email='$email'"; $result2=mysql_query($sql2); } else { $_SESSION["error"]==true; header("location: forgotpassword_login.php?error=true");//Sends the user back to the login page due to incorrect details } ?> Link to comment https://forums.phpfreaks.com/topic/193563-mysql-and-php-problem/ Share on other sites More sharing options...
jl5501 Posted February 27, 2010 Share Posted February 27, 2010 you are calling mysql_query twice. $sql=mysql_query("SELECT * FROM temp_members WHERE username='$myusername' and password='$mypassword'"); $result=mysql_query($sql); so just change it to this $result=mysql_query("SELECT * FROM temp_members WHERE username='$myusername' and password='$mypassword'"); Next if you want to address your results as an associative array as you are doing, then use mysql_fetch_assoc() instead of mysql_fetch_row() Link to comment https://forums.phpfreaks.com/topic/193563-mysql-and-php-problem/#findComment-1018953 Share on other sites More sharing options...
jay_bo Posted February 27, 2010 Author Share Posted February 27, 2010 Thanks for your help, i just realised that. Link to comment https://forums.phpfreaks.com/topic/193563-mysql-and-php-problem/#findComment-1018957 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.