Jump to content

MYSQL and PHP Problem


jay_bo

Recommended Posts

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

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()

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.