Board index   FAQ   Search  
Register  Login
Board index php forum :: PHP and MySQL Security PHP & MySQL Security

pulling info from 2 tables

Security issues related to php and mysql usage. How to make your code secure? Security measures and configurations? It's all in here!

Moderators: macek, egami, gesf

pulling info from 2 tables

Postby dhammond » Fri May 21, 2004 7:22 am

Noob here.
I'm trying to pull info from 2 tables that have a same id reference.


I've tried many different query statements....(not at the same time...)

Code: Select all
$query="SELECT emp_no, first_name, last_name, email, sup_id FROM tbl_users, tbl_sups WHERE tbl_users.emp_no=$emp_no && tbl_users.sup_id=tbl_sups.sup_id";

Code: Select all
$query="Select * from tbl_users.emp_no, tbl_users.first_name, tbl_users.last_name,, tbl_users.sup_id, tbl_sups.sup_id, tbl_sups.sup_name, tbl_sups.sup_email where tbl_users.emp_no=$emp_no and tbl_users.sup_id = tbl_sups.sup_id";

Code: Select all
$query="Select tbl_users.first_name, tbl_users.last_name,,, tbl_sups.sup_id, tbl_sups.sup_name, tbl_sups.sup_email from tbl_users, tbl_sups where emp_no=$emp_no and tbl_users.sup_id = tbl_sups.sup_id";

The emp_no is called from a $_POST.

I could use some direction here. Thanks
New php-forum User
New php-forum User
Posts: 2
Joined: Fri May 21, 2004 7:09 am

Postby Alex » Thu Jun 10, 2004 3:41 am

Well, for two tables use 2 different queries and then deal with the results...
ps I hope that you check for the $_post['emp'], because if its emty, you are screwed.
but do use 2 queries.
New php-forum User
New php-forum User
Posts: 180
Joined: Fri Mar 07, 2003 4:59 pm

Postby zodiak_bg » Mon Sep 27, 2004 12:31 pm

Try this:

Code: Select all
SELECT t1.f1, t2.f2 FROM t1,t2 WHERE

t1,t2 -> table names
f1,f2 -> field names
id -> id field

try echoing the query and see if there is something wrong with it.
the syntax seem to be working
User avatar
New php-forum User
New php-forum User
Posts: 10
Joined: Sun Aug 15, 2004 8:07 am

Return to PHP & MySQL Security

Who is online

Users browsing this forum: No registered users and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.