Person Posted May 4, 2007 Share Posted May 4, 2007 This is the error im getting ... any ideas ? Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/brian/imp.php on line 18 <?php $host = ""; $user = ""; $pass = ""; $dbname = ""; $con = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname); $query = 'SELECT' . ' user,' . ' sum(imps) AS imps,' . ' sum(clicks) AS clicks,' . ' sum(clientrev) AS clientrev' . ' FROM' . ' nuke_pnAffiliate_unauditedstats' . ' WHERE' . ' `date` = ''20070418'' AND sid like ''%rpu%'' AND user IN (SELECT DISTINCT(cl) FROM rpu_sales WHERE salesman = ''ryan'')' . ' GROUP BY user' . ' ORDER BY clientrev DESC LIMIT 0, 30'; $result = mysql_query($query); $num_results = mysql_num_rows($result); $row = mysql_fetch_assoc($result); mysql_free_result($result); $email_to = ""; $email_from = ""; $email_subject = "."; $email_body = "Content-Type: text/html; charset=UTF-8\n"; $email_body .= "Content-Transfer-Encoding: 8bit\n\n"; $email_body .= " <TABLE BORDER=\"1\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"500\" HEIGHT=\"70\"> <TR> <TD ALIGN=\"CENTER\" COLSPAN=\"3\" BGCOLOR=\"#1a467d\"> <B> RPU Sales yesterday for Ryan </B> </TD> </TR> <TR> <TD ALIGN=\"CENTER\" WIDTH=\"100\" BGCOLOR=\"#1a467d\"> <B> Clicks </B> <TD ALIGN=\"CENTER\" WIDTH=\"200\" BGCOLOR=\"#1a467d\"> <B> SUM(`clcpc`) </B> <TD ALIGN=\"CENTER\" WIDTH=\"200\" BGCOLOR=\"#1a467d\"> <B> SUM(`chcpc`) </B> </TR> <TR> <TD ALIGN=\"CENTER\" WIDTH=\"100\" BGCOLOR=\"#e36328\">" . $row['clicks'] . " <TD ALIGN=\"CENTER\" WIDTH=\"200\" BGCOLOR=\"#e36328\">" . $row['SUM(`clcpc`)'] . " <TD ALIGN=\"CENTER\" WIDTH=\"200\" BGCOLOR=\"#e36328\">" . $row['SUM(`chcpc`)'] . " </TD> </TABLE> "; mail($email_to,$email_from,$email_subject,$email_body,"From:$email_from\r\nReply-To:do not reply to sever"); ?> I did have to chance MySQL connection collation: to latin1_swedish1_ci could this have something to do to it ? Link to comment https://forums.phpfreaks.com/topic/50041-parse-error-syntax-error-unexpected-t_constant_encapsed_string/ Share on other sites More sharing options...
papaface Posted May 4, 2007 Share Posted May 4, 2007 Pretty sure it should be: $query = 'SELECT'; $query . = ' user,'; $query . = ' sum(imps) AS imps,'; $query . = ' sum(clicks) AS clicks,'; $query . = ' sum(clientrev) AS clientrev'; $query . = ' FROM'; $query . = ' nuke_pnAffiliate_unauditedstats'; $query . = ' WHERE'; $query . = ' `date` = ''20070418'' AND sid like ''%rpu%'' AND user IN (SELECT DISTINCT(cl) FROM rpu_sales WHERE salesman = ''ryan'')'; $query . = ' GROUP BY user'; $query . = ' ORDER BY clientrev DESC LIMIT 0, 30'; Link to comment https://forums.phpfreaks.com/topic/50041-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-245629 Share on other sites More sharing options...
obsidian Posted May 4, 2007 Share Posted May 4, 2007 Any time you have a single quote within a single-quoted string, you need to escape the inner ones. So, you would need to modify all your strings to reflect this pattern (only one line done for simplicity: ' `date` = \'20070418\' AND sid like \'%rpu%\' AND user IN (SELECT DISTINCT(cl) FROM rpu_sales WHERE salesman = \'ryan\')' While postgresql escapes using the double single quotes, you have to use the backslash in PHP. Link to comment https://forums.phpfreaks.com/topic/50041-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-245633 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.