annoying syntax problem (i think)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

this line is PHP

Code: Select all

$query = "SELECT password from ".$tablename." WHERE username = '".$_SESSION['username']."'";
All you are doing is building a query as a string in PHP.

When you echo that query, it is still PHP.

So basically, PHP is not doing its job by parsing the variables to build the query before you pass it to the mysql_db_query() function to query the database.

Mark
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

yeah, i understand that its PHP, its in the ?php tags obviously, im not that much of a newb

what im saying is that it cannot b a installation problem when it is perfectly capable of creating and retrieving server vars when i ask it to but not able to read the var inside a SQL query

does anyone have any idea a possible cause/fix to this problem?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

okay, run this this code in a new php file and post the results

Code: Select all

<?

//Run this script AS IS and post the results on the forum

$test_variable = "Yes I printed";

echo $test_variable;
echo "<br>";
echo $test_variable." with this concat on the end";
echo "<br>";
echo "Concat begining ".$test_variable;
echo "<br>";
echo "Concat begining ".$test_variable." concat end";

?>
Mark
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

i cant do it now im not @ home :(
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

do it when you can and post the results then :)

Mark
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

thanks bech

its much appreciated

:wink:
Post Reply