Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,155,055 members, 7,825,359 topics. Date: Sunday, 12 May 2024 at 12:25 PM

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

Nairaland Forum / Science/Technology / Programming / PHP Help: Problem With Database Output Display (1236 Views)

Help!!! Problem Installing Netbeans Ide / [Help Request] Help With Database Connectivity Error / Help With Database Development. (2) (3) (4)

(1) (Reply) (Go Down)

PHP Help: Problem With Database Output Display by kok(m): 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(m): 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.


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(m): 10:43am On Oct 04, 2012
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)

How Do I Write Andriod Applications? / What's The Largest Indigenous ICT Firm In Lagos / Programming Goddess

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.