hyipcharts Posted March 9, 2007 Share Posted March 9, 2007 Hey all and thanks in advance for any help.I am using mysql v5 running on localhost with wamp.I have rewritten this code many times and tried different syntax options. I am still getting the same error. Maybe I need another set of eyes.errorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'out) as tout from traffic where listing_id = 1 and date + interval 7 day > now()' at line 1code $row['avg_vote'] = $avg_vote; $row['cvotes'] = $votes_all; $q = 'select sum('in') as tin, sum('out') as tout from traffic where listing_id = '. $row['id'] . 'and date + interval . $settings['traffic_count_days'] . 'day > now()'; if (!($ssth = mysql_query ($q))) { exit (mysql_error ()); ; } $traffic = mysql_fetch_array ($ssth); $row['in'] = intval ($traffic['tin']); $row['out'] = intval ($traffic['tout']); $row['traffic_ratio'] = ($traffic['tout'] == 0 ? '0.0' : sprintf ('%.01f', $traffic['tin'] / $traffic['tout'])); array_push ($listings, $row);Thanks again for any help. Link to comment Share on other sites More sharing options...
vijay Posted March 9, 2007 Share Posted March 9, 2007 Hi.. use following query: suppose this will help you.. $q = "select sum(in) as tin, sum(out) as tout from traffic where listing_id = ".$row['id']. " and date + interval ".$settings['traffic_count_days']. " day > ".now(); Regards, Vijay Link to comment Share on other sites More sharing options...
hyipcharts Posted March 9, 2007 Author Share Posted March 9, 2007 Hi.. use following query: suppose this will help you.. $q = "select sum(in) as tin, sum(out) as tout from traffic where listing_id = ".$row['id']. " and date + interval ".$settings['traffic_count_days']. " day > ".now(); Regards, VijayThanks vijay,However, this gives me a fatal error: Fatal error: Call to undefined function now()I will continue to play with it and try to get it going.Thanks again Link to comment Share on other sites More sharing options...
Mr_CHISOL Posted March 9, 2007 Share Posted March 9, 2007 In PHP now() is called date() (which take's a formatstring) or time() which returns the current UNIX timestamp.But in SQL you have a function called NOW() that you can use.try $q = "select sum(in) as tin, sum(out) as tout from traffic where listing_id = ".$row['id']. " and date + interval ".$settings['traffic_count_days']. " day > NOW()"; wrote now() in uppercase to let it stand out... Moved the quot from before now() to after...Good Luck and Don't Panic! Link to comment Share on other sites More sharing options...
hyipcharts Posted March 10, 2007 Author Share Posted March 10, 2007 In PHP now() is called date() (which take's a formatstring) or time() which returns the current UNIX timestamp.But in SQL you have a function called NOW() that you can use.try $q = "select sum(`in`) as tin, sum(`out`) as tout from traffic where listing_id = ".$row['id']." and date + interval ".$settings['traffic_count_days']. " day > now()"; Errors have become common place, so I do expect them. Thanks again Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now