Jump to content

T_string error!! plz help


shashank543

Recommended Posts

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

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";
}

?>

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";
}
?>

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

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']);

lol  :D

 

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";
}
?>

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.