Hey,
I do have it in a variable but I just choose to leave it out.
Ive tried so many different things with this and even what you gave me for
some reason didnt work. The variables are being set, if I echo
$_SESSION['user'] then right data is shown. However as soon as I put it in
the mysql_query it stops working. Im using it for a login script that I
include at the start of every page. Heres what I got:

<?php
session_start();
?>
<?php
$_SESSION['user'] = $_POST['user'];
$_SESSION['pass'] = $_POST['pass'];
?>
<?php
$db = mysql_connect("$host", "user", "pass");
mysql_select_db("$dtb",$db);
$result = mysql_query("select count(*) AS numfound from admins where
user='{$_SESSION['user']}' AND
pass='{$_SESSION['pass']}'",$db);
echo "".$_SESSION['user']." ".$_SESSION['pass']."";

$result_ar = mysql_fetch_array($result);
if ($result_ar['numfound'] < 1)
{
session_unset();
session_destroy();
include("error.php");
exit;
}
?>

I include that at the top of every page I want to protect.

Lee

"Jason Wong" <[EMAIL PROTECTED]> wrote in message
news:200211121537.49604.php-general@;gremlins.com.hk...
> On Tuesday 12 November 2002 15:05, conbud wrote:
> > Hey,
> > How would I insert $_SESSION['user'] and $_SESSION['pass']
> >
> > into this
> > mysql_query("select count(*) AS numfound from admins where user='$user'
AND
> > pass='$pass'",$db);
> >
> > right now I have
> > $_SESSION['user'] = $_POST['user']
> > $_SESSION['pass'] = $_POST['pass']
> >
> > and I need to put $_SESSION['user'] where the $user is in the above
> > statement and so one w/ $pass
>
> You mean like this?
>
> mysql_query("select count(*) AS numfound from admins where
> user='{$_SESSION['user']}' AND
> pass='{$_SESSION['pass']}'",$db);
>
> BTW, it is much better to assign your query to a variable, eg $qry, then
do
>
>  mysql_query($qry, $db) or die('Error in $qry ' . mysql_error());
>
> That way if your query doesn't work you'll at least know why.
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
>
> /*
> Perhaps the biggest disappointments were the ones you expected anyway.
> */
>



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

Reply via email to