₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,074 members, 8,420,178 topics. Date: Thursday, 04 June 2026 at 12:55 PM

Toggle theme

PHP Help: Problem With Database Output Display - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingPHP Help: Problem With Database Output Display (1312 Views)

1 Reply (Go Down)

PHP Help: Problem With Database Output Display by kok(op): 9:49am On Oct 03, 2012
Hello pals,I need some help on the codes below. I am trying to display a user db data upon signed-in,but it keep showing blank. Kindly help me check what I might av done wrong.
Regards.
<?php
session_start();

include_once "images/connect_to_mysql.php";

if (isset($_SESSION['id'])) {

$sql = mysql_query("SELECT * FROM vault WHERE id='$id' LIMIT 1"wink;
while($row = mysql_fetch_array($sql)){
$username = $row["username"];
$email = $row["email"];
$desc = $row["desc"];
$dep_type = $row["dep_type"];
$consg_code = $row["consg_code"];
$depositor = $row["depositor"];
$officer = $row["officer"];
$contact = $row["contact"];
$delivery = $row["delivery"];
$destination = $row["destination"];
}
}
?>
Re: PHP Help: Problem With Database Output Display by spikesC(m): 10:09am On Oct 03, 2012
where did the variable, $id, come from?

If it is a development server, pls turn on all your error reporting and display. Also, run your mysql queries with a mysql administrative application to test it if it doesn't work as intended.
Re: PHP Help: Problem With Database Output Display by kok(op): 10:20am On Oct 03, 2012
I av a column on the db named 'id' ,and i used it to save the session on the login page.
Re: PHP Help: Problem With Database Output Display by Nobody: 10:26am On Oct 03, 2012
kok: I av a column on the db named 'id' ,and i used it to save the session on the login page.
huh

What do you really want to do?
Re: PHP Help: Problem With Database Output Display by spikesC(m): 10:59am On Oct 03, 2012
kok: I av a column on the db named 'id' ,and i used it to save the session on the login page.
From what i saw in your code, you're getting information from your database based on the $_SESSION['id']. Therefore, the variable $id should be declared with the value of $_SESSION['id']. Pls, turn your error reporting and display ON. You'll get the info am talking about.
Re: PHP Help: Problem With Database Output Display by Nobody: 11:06am On Oct 03, 2012
<?php
session_start();

include_once "images/connect_to_mysql.php";

if (isset($_SESSION['id'])) {

$id = $_SESSION['id'];

$sql = mysql_query("SELECT * FROM vault WHERE id='$id' LIMIT 1"wink;
while($row = mysql_fetch_array($sql)){
$username = $row["username"];
$email = $row["email"];
$desc = $row["desc"];
$dep_type = $row["dep_type"];
$consg_code = $row["consg_code"];
$depositor = $row["depositor"];
$officer = $row["officer"];
$contact = $row["contact"];
$delivery = $row["delivery"];
$destination = $row["destination"];
}
}
?>
Re: PHP Help: Problem With Database Output Display by kok(op):
Thanks to u guys. Much apology for reporting late.
I found my way thru it using
if (isset($_GET['id'])) {
$sql = mysql_query("SELECT * FROM vault WHERE id='$id' LIMIT 1"wink ;

But it still does not display output. I realize that wen I run a num row count to check user existence on db if (existCount = mysql_num_rows($sql);
if ($existCount == 0) {
header("location: index.php?msg=user_doesnt_exist"wink;
exit();
}

it keep affirming "user_doesnt_exist",even when i manually enter data to the db. Any idea plz?
1 Reply

Help!!! Problem Installing Netbeans Ide[Help Request] Help With Database Connectivity ErrorHelp With Database Development.234

We need programming projects to mess with and provide solutionsPlease Vote For My Software Smart CBTNational Developer Survey