StirCrazy Posted July 24, 2006 Share Posted July 24, 2006 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 blahAny ideas?Thanks guys :) Link to comment https://forums.phpfreaks.com/topic/15452-sql-my_query/ Share on other sites More sharing options...
cunoodle2 Posted July 24, 2006 Share Posted July 24, 2006 Try this..."' and g.id=o.gift_id and site='".$site_prefix."'); Link to comment https://forums.phpfreaks.com/topic/15452-sql-my_query/#findComment-62671 Share on other sites More sharing options...
Barand Posted July 24, 2006 Share Posted July 24, 2006 TIPInstead of $sql = mysql_query ("SELECT blah "), use[code]$query = "SELECT blah";$sql = mysql_query($query);[/code]Then if you have problems you canecho $query;to see if the submitted query looks OK. Link to comment https://forums.phpfreaks.com/topic/15452-sql-my_query/#findComment-62673 Share on other sites More sharing options...
StirCrazy Posted July 24, 2006 Author Share Posted July 24, 2006 cheers guys ~ it always turns out to be summit real simple doesn't it :Djust forgot the [b][color=red]o.[/color][/b]site='$site_prefix'");DOH!W.> Link to comment https://forums.phpfreaks.com/topic/15452-sql-my_query/#findComment-62675 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.