473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Variable after WHERE

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
3 1332
mainul
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
use

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

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

Similar topics

134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
3
by: Anders Borum | last post by:
Hello! I've come across a strange error that occurs, when you try to return a nodelist from a variable with a choose/where/otherwise statement. I'm not quite sure whether it's a bug or simply...
7
by: Richard Hollenbeck | last post by:
Help! I don't know why this isn't working: Private Sub Combo9_Change() Dim UsersCourseSelection As String UsersCourseSelection = Me("Combo9").Value Combo13.Visible = True 'the following...
9
by: Shapper | last post by:
Hello, I am declaring a variable in my aspx.vb code as follows: Public Class catalogue Public productid As String Private Sub Page_Load ... I have an image button where I call the...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
4
by: Phillip Vong | last post by:
I'm a newbie using VS2005 to learn and test. I'm testing against the Northwind DB. I created a simple variable called "myVariable" and I assigned it the character "c". I want my SQL query to use...
5
by: strawberry | last post by:
In the function below, I'd like to extend the scope of the $table variable such that, once assigned it would become available to other parts of the function. I thought 'global $table;' would solve...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
2
by: Looch | last post by:
All, I'm trying to output but I can only get (brackets for clarity) when using the code below. How can I "break" into the query variable in the InsertName method to add the name parameter to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.