shashank543 Posted March 1, 2010 Share Posted March 1, 2010 here is my php code for this.. <?php //Database Information $dbhost = "localhost"; $dbname = "//"; $dbuser = "//"; $dbpass = "//"; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); session_start(); $username = $_POST[‘username’]; $password = md5($_POST[‘password’]); $query = “select * from users where username=’$username’ and password=’$password’”; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { $error = “Bad Login”; include “login.html”; } else { $_SESSION[‘username’] = “$username”; include “memberspage.php”; } ?> plz help guys Link to comment https://forums.phpfreaks.com/topic/193744-t_string-error-plz-help/ Share on other sites More sharing options...
inversesoft123 Posted March 1, 2010 Share Posted March 1, 2010 Need to change your quotes. Your current quotes are pushing different ASCII. <?php //Database Information $dbhost = "localhost"; $dbname = "//"; $dbuser = "//"; $dbpass = "//"; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); session_start(); $username = $_POST[‘username’]; $password = md5($_POST[‘password’]); $query = "select * from users where username='$username' and password='$password'"; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { $error = "Bad Login"; include "login.html"; } else { $_SESSION['username'] = "$username"; include "memberspage.php"; } ?> Link to comment https://forums.phpfreaks.com/topic/193744-t_string-error-plz-help/#findComment-1019726 Share on other sites More sharing options...
shashank543 Posted March 1, 2010 Author Share Posted March 1, 2010 i dint exactly get u.. could u please eloborate.. thanks in advance Link to comment https://forums.phpfreaks.com/topic/193744-t_string-error-plz-help/#findComment-1019747 Share on other sites More sharing options...
jl5501 Posted March 1, 2010 Share Posted March 1, 2010 You do not say on which line you are getting the error, but this code should work <?php //Database Information $dbhost = "localhost"; $dbname = "//"; $dbuser = "//"; $dbpass = "//"; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); session_start(); $username = $_POST[‘username’]; $password = md5($_POST[‘password’]); $query = "select * from users where username='$username' and password='$password'"; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { $error = "Bad Login"; include "login.html"; } else { $_SESSION['username'] = $username; include "memberspage.php"; } ?> Link to comment https://forums.phpfreaks.com/topic/193744-t_string-error-plz-help/#findComment-1019749 Share on other sites More sharing options...
inversesoft123 Posted March 1, 2010 Share Posted March 1, 2010 i dint exactly get u.. could u please eloborate.. thanks in advance there are diffrent type of single or doubble quotes. ‘password’ in this ‘ should be ' and “select * should be "select * It happens when you get or put code on wordpress blog;) Link to comment https://forums.phpfreaks.com/topic/193744-t_string-error-plz-help/#findComment-1019750 Share on other sites More sharing options...
inversesoft123 Posted March 1, 2010 Share Posted March 1, 2010 You do not say on which line you are getting the error, but this code should work still need to change $username = $_POST[‘username’]; $password = md5($_POST[‘password’]); to $username = $_POST['username']; $password = md5($_POST['password']); Link to comment https://forums.phpfreaks.com/topic/193744-t_string-error-plz-help/#findComment-1019751 Share on other sites More sharing options...
jl5501 Posted March 1, 2010 Share Posted March 1, 2010 I need glasses - did not see those 'smart' quotes in there. Of course should be $username = $_POST['username']; $password = md5($_POST['password']); Link to comment https://forums.phpfreaks.com/topic/193744-t_string-error-plz-help/#findComment-1019752 Share on other sites More sharing options...
inversesoft123 Posted March 1, 2010 Share Posted March 1, 2010 lol so this is the final code of you <?php //Database Information $dbhost = "localhost"; $dbname = "//"; $dbuser = "//"; $dbpass = "//"; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); session_start(); $username = $_POST['username']; $password = md5($_POST['password']); $query = "select * from users where username='$username' and password='$password'"; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { $error = "Bad Login"; include "login.html"; } else { $_SESSION['username'] = $username; include "memberspage.php"; } ?> Link to comment https://forums.phpfreaks.com/topic/193744-t_string-error-plz-help/#findComment-1019754 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.