Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
ThePiston
Worker
Worker



Joined: Dec 22, 2004
Posts: 135

PostPosted: Tue Sep 27, 2005 3:14 pm Reply with quote

I have this code in the beginning of my "edithome" function of "Your Account" index.php file
Code:
$sql = "select u.user_id, u.name, o.user_id, o.offname, o.add1, o.add2, o.city, o.state, o.zip, o.phone, o.fax FROM nuke_users u, offices o WHERE username='$check'";
Shouldn't that only pull those specific data points from the DB where username = "whoever the cookie is set to"? Right now, it pulls info from all members and not just the specific "username" from cookie. I tried to use WHERE userID='$check', but Igot an error.

PS - i know NOTHING about PHP, I am pretty much cutting and pasting my way around this problem and now I'm stuck....
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Tue Sep 27, 2005 6:32 pm Reply with quote

Not the way it is written. This has nothing at all to do with PHP. It is an SQL issue. When you join 2 tables and you do not cross reference the two tables by a common column, you wil get what is called a Cartesian join, or all members from both tables that match any of the criteria. You are matching the username to $check but I can't see where you are matching the users table to the office table. You need to do something like

where u.username='$check' and u.SOMEFIELD=o.SOME_OTHERFIELD;
 
View user's profile Send private message
ThePiston







PostPosted: Tue Sep 27, 2005 8:30 pm Reply with quote

d***! i knew this would be harder than I thought. What's the best "SQL and PHP for dummies" book?
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Tue Sep 27, 2005 8:40 pm Reply with quote

I have had great luck with the "Bible" series of books such as "The Javascript Bible" and "PHP and mySQL Bible", etc... never had a bad book from this series.

Regards,
montego

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
ThePiston







PostPosted: Wed Sep 28, 2005 9:21 am Reply with quote

I havn't learned code since Apple II... it's addictive and I have a new bidness and a new baby on the way... could be trouble.
 
montego







PostPosted: Wed Sep 28, 2005 7:50 pm Reply with quote

Yup, you are in trouble! I can say that from experience, however, I've been coding in one form or the other for over 20 years... and, yes, it is very addictive!

Don't worry, the Baby and wife will "help" you with the priorities... Laughing

montego
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©