Jump to content

echo Error, not printing the data i want.


Person

Recommended Posts

<?php
$host = "";
$user = "";
$pass = "";
$dbname = "";

$con = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);

$yesterday = date('20ymd', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));
$query= "SELECT SUM(1) AS clicks, SUM(`clcpc`), SUM(`chcpc`) FROM `nuke_pnAffiliate_clicktracking` WHERE `pl` = 'rpu' AND  `date` = '" . $yesterday . "'";

$result= mysql_query($query);
    
$row= mysql_fetch_assoc($result);

echo $result ; 
   
?>

 

should print : 

clicks  SUM(`clcpc`)  SUM(`chcpc`)

211 38.299999821931 84.569998212159

 

but it prints : Resource id #5

 

How do i fix this ?

 

Link to comment
https://forums.phpfreaks.com/topic/52657-echo-error-not-printing-the-data-i-want/
Share on other sites

Change

<?php
$query= "SELECT SUM(1) AS clicks, SUM(`clcpc`), SUM(`chcpc`) FROM `nuke_pnAffiliate_clicktracking` WHERE `pl` = 'rpu' AND  `date` = '" . $yesterday . "'";

$result= mysql_query($query);
    
$row= mysql_fetch_assoc($result);

echo $result ;
?>

to

<?php
$query= "SELECT SUM(1) AS clicks, SUM(`clcpc`) as clcpc, SUM(`chcpc`) as chcpc FROM `nuke_pnAffiliate_clicktracking` WHERE `pl` = 'rpu' AND  `date` = '" . $yesterday . "'";
$result= mysql_query($query);
$row= mysql_fetch_assoc($result);
printf("%d   %02.12f   %02.12f",$row['clicks'],$row['clcpc'],$row['chcpc']);
?>

 

Ken

Archived

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

×
×
  • Create New...

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.