Re: Making a Variable from different tables with Matching Dbfields?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Terion Miller wrote:
> Hi Again
>
> Here is the query and code I tried:
> $sql = "SELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM
> admin WHERE UserName = '"
> . mysql_real_escape_string($_SESSION['user']) . "')";
>
>
>       $result2 = mysql_query ($sql);
>       $row2 = mysql_fetch_assoc ($result2);
>        $printrow = print_r($row2);
>
>
>
> Here is my print variables--- Nothing printed with the print_r:
>
> $sql 	"SELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM
> admin WHERE UserName = 'tmiller')"
> $result2 	"Resource id #6"
> $row2 	""
> $printrow 	"1"
>
O.K., easy:

1. There is no UserName in admin that = $_SESSION['user']
2. Or, the AdminID that is returned for $_SESSION['user'] is not present
in workorders

That's why I suggested the 2 query approach the first time so that you
could echo out the AdminID after the first query and then go into the db
and make sure it exists in workorders.  Or, if none were returned, then
echo out $_SESSION['user'] and make sure it exists in admin.

-Shawn

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux