problem in mysql_query

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

Post Reply
newbie123
Forum Newbie
Posts: 1
Joined: Thu Feb 09, 2012 7:12 am

problem in mysql_query

Post by newbie123 »

<?php
ob_start();
session_start();
if(!isset($_SESSION['Username'])){
header("Location: login.php");
}
else{
$username=$_SESSION['Username'];

include ('database_connection.php');
$connection = mysql_query("SELECT `Balance`, `Nick_name`, `Activation`, `Email`, `Memberid` FROM `members` WHERE `Username`=$username");
list($Balance, $Nick_name, $Activation, $Email, $Memberid) = mysql_fetch_row($connection);
}
?>

here i am using echo $Balance but its not printing. _SESSION['Username'] printing correctly.
Is there any problem with mysql_query.
Please help
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: problem in mysql_query

Post by Celauran »

And if you put single quotes around $username in your query?
Post Reply