Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
CerIs
- Forum Newbie
- Posts: 22
- Joined: Sat May 29, 2004 9:20 am
Post
by CerIs »
Is the result of a sum query put into the var of that column? Ive been trying this for a while and its not outputting anything:
Code: Select all
<?php
mysql_pconnect("localhost","User","Pass");
mysql_select_db("douple_Newdata");
$query = "SELECT sum(Downloads) from affmembers";
$result = mysql_query($query)
or die ("Couldn't execute query.");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
extract($row);
echo "$Downloads";
?>
Thanks
-
tim
- DevNet Resident
- Posts: 1165
- Joined: Thu Feb 12, 2004 7:19 pm
- Location: ohio
Post
by tim »
as always
to troubleshoot any code where you use mysql, add some
or die(mysql_error()); to anything MySQL related.
use error reporting, you will seee whats wrong w/ your code.

-
Weirdan
- Moderator
- Posts: 5978
- Joined: Mon Nov 03, 2003 6:13 pm
- Location: Odessa, Ukraine
Post
by Weirdan »
heh, just modify your query to look like:
Code: Select all
SELECT sum(Downloads) as Downloads from affmembers
tim is right though, it's much more useful to have mysql_error(), error reporting and so on on development server.
-
CerIs
- Forum Newbie
- Posts: 22
- Joined: Sat May 29, 2004 9:20 am
Post
by CerIs »
Thanks