running 2 SQL queries error!... help needed!
Posted: Fri Dec 17, 2004 5:36 am
Hi, basically i'm trying to run this script which looks at a mysql database, looking up student records to display the student's balance and transaction history, (script below) problem is i'm getting a parse error when trying to run the second SQL query, which I'm guessing is the problem (running two querys). Any ideas, help will be much appriciated as I don't have long to get this all done (5 hours ish) and my system seems to be falling into an abyss of chaos!!! 
Simon.
Simon.
Code: Select all
<?php
$username = $_POST['username'];
$self = $_SERVER['PHP_SELF'];
$refer = $_SERVER['HTTP_REFERER'];
#connect to MYSQL
$conn = @mysql_connect( "linuxproj", "****", "*****" )
or die( "could not connect" );
#select the specified database
$rs = @mysql_select_db ( "db_sn202", $conn )
or die( "could not select database" );
#create the sql query
$sql="select accountbal from students where username="$username"";
#exercute the query
$rs = mysql_query( $sql, $conn )
or die( "could not exercute query" );
while( $row = mysql_fetch_array( $rs ) )
{
echo( "Balance: " . $row["balance"] ) ;
}
#create the sql query
$sql="SELECT transactions.*, students.studentno FROM transactions
JOIN users
ON transactions.studentno=students.studentno
WHERE students.studentno="$username""
#exercute the query
$rs = mysql_query( $sql, $conn )
or die( "could not exercute query" );
while( $row = mysql_fetch_array( $rs ) )
{
echo( "Balance: " . $row["balance"] ) ."<br>");
}
{ $msq = "Welcome $username to your account summary"; }
?>