By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Variable after WHERE

P: 8
I've got a piece of script that works that looks like this:
__________________________________________________ _________

$username="daedalus_admin";
$password="test";
$database="daedalus_db";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM user WHERE username='daedalus";
$result=mysql_query($query);

$num=mysql_numrows($result);
__________________________________________________ _________

I want to change it to this so that I can use a variable from a session at a later date:
__________________________________________________ _________

$schque="daedalus"

$username="daedalus_admin";
$password="test";
$database="daedalus_db";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM user WHERE username='$schque";
$result=mysql_query($query);

$num=mysql_numrows($result);
__________________________________________________ _________

But as soon as I change the criteria of the WHERE to $schque the page stops working and comes up blank, i've tried it without the ' round it but it still doesn't work, I'm really confused any help would be appriecated.
Mar 1 '07 #1
Share this Question
Share on Google+
3 Replies


P: 51
I've got a piece of script that works that looks like this:
__________________________________________________ _________

$username="daedalus_admin";
$password="test";
$database="daedalus_db";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM user WHERE username='daedalus";
$result=mysql_query($query);

$num=mysql_numrows($result);
__________________________________________________ _________

I want to change it to this so that I can use a variable from a session at a later date:
__________________________________________________ _________

$schque="daedalus"

$username="daedalus_admin";
$password="test";
$database="daedalus_db";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM user WHERE username='$schque";
$result=mysql_query($query);

$num=mysql_numrows($result);
__________________________________________________ _________

But as soon as I change the criteria of the WHERE to $schque the page stops working and comes up blank, i've tried it without the ' round it but it still doesn't work, I'm really confused any help would be appriecated.

use

$a=$_REQUEST['$schque'];
$query="SELECT * FROM user WHERE username='$a'";
Mar 1 '07 #2

P: 8
use

$a=$_REQUEST['$schque'];
$query="SELECT * FROM user WHERE username='$a'";
Thanks this works perfectly, I owe you one.
Mar 1 '07 #3

P: 51
You are welcome.
Mar 3 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.