Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
adbinc
Forum Newbie
Posts: 1 Joined: Mon Apr 14, 2008 6:47 am
Post
by adbinc » Mon Apr 14, 2008 6:54 am
i am workin wid my college project of airline reservation system.i made a form which insert details in my databse..but when iam retriving details ..it is giving error!
Code: Select all
<?php
include("conf.php");
$server = $_SESSION['server'];
$db_user= $_SESSION['db_user'];
$db_pass = $_SESSION['db_pass'];
$db_name = "adbinc_bookings";
$cxn = mysql_connect($server,$db_user,$db_pass,$db_name)
or die ("User name or password is wrong.");
$query = "SELECT * FROM $table ORDER BY rid ASC LIMIT 0,30";
$result = mysql_query($cxn,$query) or die ("Couldnt execute query.");
$num = mysql_num_rows($result);
echo "<b><center>Database Output</center></b><br><br>";
while ($row = mysql_fetch_assoc($result)){
echo "<b> " . $row['fname'] . " " . $row['lname'] . " </b><br>" . $row['fno']
.
"<br>" . $row['src'] . "<br>" . $row['dest'] . "" . $row['rid'] .
"<hr><br>\n";
}
?> :crazy:
aceconcepts
DevNet Resident
Posts: 1424 Joined: Mon Feb 06, 2006 11:26 am
Location: London
Post
by aceconcepts » Mon Apr 14, 2008 8:12 am
You are using a variable as the table name.
Either use a table name that exists or enclose your variable with single quotes:
Code: Select all
$table=tblName;
$query = "SELECT * FROM '$table' ORDER BY rid ASC LIMIT 0,30";
onion2k
Jedi Mod
Posts: 5263 Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com
Post
by onion2k » Mon Apr 14, 2008 8:26 am
There's really nothing anyone can do to help without knowing what the error it's giving is.