arrg need help summing Colum's

2006-04-13 Thread Brian E Boothe

why cant i get this to sum  ???
?
$link = mysql_connect(localhost,root,goobers) or 
die(mysql_error());

mysql_select_db(workorder, $link);
 $result = mysql_query(SELECT SUM(`ElecRem`) AS 
total FROM orders, $link);

//$total = mysql_fetch_row($result);
   echo mysql_result($result); // 
outputs total

 //return $total[0];
  echo mysql_error();  
 
  ?
 


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: arrg need help summing Colum's

2006-04-13 Thread Rhino


- Original Message - 
From: Brian E Boothe [EMAIL PROTECTED]

To: mysql@lists.mysql.com
Sent: Friday, April 14, 2006 5:09 AM
Subject: arrg need help summing Colum's



why cant i get this to sum  ???
?
$link = mysql_connect(localhost,root,goobers) or 
die(mysql_error());

mysql_select_db(workorder, $link);
 $result = mysql_query(SELECT SUM(`ElecRem`) AS total 
FROM orders, $link);

//$total = mysql_fetch_row($result);
   echo mysql_result($result); // outputs 
total

 //return $total[0];
  echo mysql_error();  ?

It would REALLY REALLY help if you gave us some idea why you think there is 
anything wrong with this code. You haven't indicated how the code is 
misbehaving or what statements, if any, are working correctly and which are 
failing.


Are you successfully getting connected to the server? If yes, how do you 
know?


Are you successfully connecting the database ('workorder')? If yes, how do 
you know?


What happens when you run the query? You haven't given us any clue at all. 
Does the statement work but return an incorrect answer? Does it fail with an 
error message? If so, what is the error message?


Or is it the statement that computes 'total' that is failing in some way? If 
so, what is wrong with it?


All you've done is given us a fragment of code without clearly identifying 
the failing code or giving us any real symptoms, other than a remark about a 
summing problem.


Without more information it is VERY hard to guess what might be wrong.

--
Rhino



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.4.1/310 - Release Date: 12/04/2006


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: arrg need help summing Colum's

2006-04-13 Thread Puiu Hrenciuc
I don't think your code should work anyway, you should really check PHP
manual to get this work. mysql_query doesn't actually return the result, but
a resource id that can be used with mysql_fetch_xxx functions. Try this :

$link = mysql_connect(localhost,root,goobers) or die(mysql_error());
mysql_select_db(workorder, $link);
$result = mysql_query(SELECT SUM(`ElecRem`) AS  total FROM orders, $link);
$row = mysql_fetch_array($result);
$total=$row['total'];
echo $total;



Brian E Boothe [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 why cant i get this to sum  ???
 ?
 $link = mysql_connect(localhost,root,goobers) or 
 die(mysql_error());
 mysql_select_db(workorder, $link);
  $result = mysql_query(SELECT SUM(`ElecRem`) AS total 
 FROM orders, $link);
 //$total = mysql_fetch_row($result);
echo mysql_result($result); // outputs 
 total
  //return $total[0];
   echo mysql_error();  ?
 



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]