a simple WHERE = question I think

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

a simple WHERE = question I think

Post by hward »

how can you do this

Code: Select all

WHERE $adv_picture = '/images/$adv_username.jpg'
stored picture path is always /members/XXXX.jpg

XXXX matches adv_username
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Code: Select all

where adv_picture = concat('/images/',adv_username,'.jpg');
Did I get it right?
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

Post by hward »

won't execute
zenabi
Forum Commoner
Posts: 84
Joined: Mon Sep 08, 2003 5:26 am
Location: UK

Post by zenabi »

It might be clearer to make a variable for the path to your image first, for example:

Code: Select all

$image_path = "members/".$adv_username.".jpg";

//and then add that to your sql statement:
$sql = "SELECT * FROM tablename WHERE fieldname=$image_path";
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

Post by hward »

Code: Select all

WHERE adv_picture = concat('/images/',adv_username,'.jpg')
query executes but no returns
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

Post by hward »

Code: Select all

$image_path = "members/".$adv_username.".jpg"; 

//and then add that to your sql statement: 
$sql = "SELECT * FROM tablename WHERE fieldname=$image_path";
Couldn't execute query.
zenabi
Forum Commoner
Posts: 84
Joined: Mon Sep 08, 2003 5:26 am
Location: UK

Post by zenabi »

It may help if you post the code to your page.
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

Post by hward »

Code: Select all

where adv_picture = concat('/members/',adv_username,'.jpg')
works fine

my bad it was members not images
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

do all path's stored in the table have /members/ in them? If so, then what's the point of storing that? The script can automatically tack that on, freeing up potentially many many bytes of stored redundant data.
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

Post by hward »

no if some no photo is uploaded a generic photo is added and i didn't want those to return
Post Reply