Jump to content


Photo

$sql = my_query("


  • Please log in to reply
3 replies to this topic

#1 StirCrazy

StirCrazy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 24 July 2006 - 06:21 AM

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 and site='$site_prefix'");

while (list....blah blah blah


Any ideas?


Thanks guys :)

#2 cunoodle2

cunoodle2
  • Members
  • PipPipPip
  • Advanced Member
  • 602 posts

Posted 24 July 2006 - 06:35 AM

Try this...

"' and g.id=o.gift_id and site='".$site_prefix."');

If the code was working and now it's not, something changed. Did you change any code?

yeah, just a little bit, I am trying to start from beginning and trace my steps to see what i did wrong unless you see it.


#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 24 July 2006 - 06:43 AM

TIP

Instead of $sql = mysql_query ("SELECT blah "), use
$query = "SELECT blah";
$sql = mysql_query($query);

Then if you have problems you can

echo $query;

to see if the submitted query looks OK.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 StirCrazy

StirCrazy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 24 July 2006 - 06:56 AM

cheers guys ~ it always turns out to be summit real simple doesn't it  :D

just forgot the  o.site='$site_prefix'");

DOH!

W.>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users