Jump to content

Archived

This topic is now archived and is closed to further replies.

StirCrazy

$sql = my_query("

Recommended Posts

Hi Folks,

I'm back to pick your brains again (or bug the hell outa you with my constant novice questions).

This is the current sql query i'm using:-

  $sql = my_query("select g.name, o.date from orders o, gifts g where
  o.user_id = '" . mysql_real_escape_string($_SESSION['offers_user']) . "' and g.id=o.gift_id");


I now want it to only pick out the data from the orders tbl where site='$site_prefix' (simply adding it on the end doesn't work)


  $sql = my_query("select g.name, o.date from orders o, gifts g where
  o.user_id = '" . mysql_real_escape_string($_SESSION['offers_user']) . "' and g.id=o.gift_id [b]and site='$site_prefix'[/b]");

while (list....blah blah blah


Any ideas?


Thanks guys :)

Share this post


Link to post
Share on other sites
TIP

Instead of $sql = mysql_query ("SELECT blah "), use
[code]
$query = "SELECT blah";
$sql = mysql_query($query);
[/code]

Then if you have problems you can

echo $query;

to see if the submitted query looks OK.

Share this post


Link to post
Share on other sites
cheers guys ~ it always turns out to be summit real simple doesn't it  :D

just forgot the  [b][color=red]o.[/color][/b]site='$site_prefix'");

DOH!

W.>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.