Re: [PHP] Re: can a session be used in a query?



On Wed, Jan 7, 2009 at 3:33 PM, Frank Stanovcak <blindspotpro@xxxxxxxxxxx>wrote:


One other thought. If you are getting a blank page with no errors or out
put at all, I've noticed that I somtimes have to get the page to load
successfully before the web server will dish out the error.

What I normally do is upload a blank php page with the same name as the one
I am working on, load it up, and then upload the page with all the code and
refresh.

I never really looked into why this was, but it's not that big of a hassle
for me. *shrug*

Frank

""Terion Miller"" <webdev.terion@xxxxxxxxx> wrote in message
news:37405f850901071146i11d33987ga747ef2e4932fb7d@xxxxxxxxxxxxxxxxx
I am still struggling with getting my sessions and logins to pull just the
allotted data that each user is allowed...
I have the session working, and can echo it to see that .. what I'm
having
problems with is this : I want to pull the data specific to each user
..right... so far I either get all data regardless of user privileges or
I
get nothing.. a blank page, I have tried so many ways but never one that
works: here are a few I have worked with----

This one pulls all data regardless of user level:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
session_start();
include("inc/dbconn_open.php");


if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] <> 'True'
){
header ("Location: LogOut.php");
}


$query = "SELECT * FROM admin WHERE AdminID = AdminID";
$result = mysql_query ($query);
$row = mysql_fetch_object ($result);
?>

From there I tried:

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
session_start();
include("inc/dbconn_open.php");


if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){
header ("Location: LogOut.php");
}


$query =
"SELECT * FROM `admin` WHERE `UserName` = `{$_SESSION['user']}";
$result = mysql_query ($query);
$row = mysql_fetch_assoc($result);
?>

this one didn't work with the if $row -> statements that are used to
select
what menu items to load.

Now I have this one which loads nothing, nil a blank page:

$query = "SELECT * FROM admin WHERE UserName = "$_SESSION['user']"
";
$result=mysql_query($query) or die('Queryproblem: ' . mysql_error() .
'<br />Executed query: ' . $query);
if (mysql_num_rows($result) >= '1'){
while ($row = mysql_fetch_assoc($result)){
echo $row['AddEditAdmin']; //to print out the value of column
'var1' for each record
}
}else{
echo 'No records found.';
}
?>

anyone have ideas for me, the session user is working, and I need to use
it
in the query to pull only that users data I also on the login page where
I
set that session all set it to = $UserName but when I try and use that in
the query UserName = $UserName I get an undefined variable error...

Really trying but not quite getting it...




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Well I am def. further along, the query is working, I can echo fields in
the $row and get the results but when I try and use this:

<?php
if ($row['AddEditAdmin'] == 'YES') {
?>
to sort out what menu items to load it just doesn't do its job.


Relevant Pages

  • Speeding up MySQL query
    ... I am reusing the results of a MySQL query on a PHP page. ... page load more quickly. ... At the top of the page I am running the query with the following code. ... HTML ...
    (php.general)
  • Re: [PHP] PHP Performance and System Load
    ... General performance tip do not include more than 10 files a page load. ... Uses php Adodb ... At the moment I am trying to lower the number of filesystem calls as ... over a symlink placed in every webspace directory. ...
    (php.general)
  • Re: High Scores
    ... If you want to view High scores it returns Could Not load scores ... here is the PHP script ... Edit the game Flash file to point to this file on your server ... >> And the PHP script is here ...
    (alt.php)
  • Re: about structure.
    ... Of course if you want to use a load of checkboxes, it works too, just modify ... I thought about using a database... ... "I thought about using php... ... server needs to call upon php... ...
    (alt.php)
  • Re: Loading png images into a mysql table/database
    ... I have decided to use PHP and MySQL. ... I can load jpeg files into the table ... I do a select from the database, and then echo the image (with ... header(Content Type: image/jpeg) ...
    (comp.lang.php)