NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page some small sql help

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 01-07-2007, 09:34 PM THREAD STARTER               #1 (permalink)
Account Suspended
Join Date: Jun 2006
Posts: 472
Gandhi is a splendid one to beholdGandhi is a splendid one to beholdGandhi is a splendid one to beholdGandhi is a splendid one to beholdGandhi is a splendid one to beholdGandhi is a splendid one to beholdGandhi is a splendid one to beholdGandhi is a splendid one to behold
 


Find Marrow Donors! Cancer Survivorship Adoption Wildlife Cystic Fibrosis

Help! some small sql help


Well just started www.templatesurge.com and as you will notice at top right under the big banner you will see
Quote:
Total Templates: 31 Total Downloads: 18 Total Tutorials: 17 Users Online: 1 user online
What I want is for the Total Templates, Downloads, to update by it self, by getting the info from the sql db. Anyone know how to do this, I was told that it was easy, but I dont know how to do it.
????: NamePros.com http://www.namepros.com/programming/278437-some-small-sql-help.html


So please if anyone can help it would be appreciated.
Gandhi is offline  
Old 01-07-2007, 10:57 PM   #2 (permalink)
Tech Support
Join Date: Mar 2005
Posts: 4,944
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Yes, would be fairly easy.

Would need to know your database structure to give you the exact code for it...

But, let's say your template table was for example:

Code:
CREATE TABLE templates (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
author VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);
Total templates:
????: NamePros.com http://www.namepros.com/showthread.php?t=278437
PHP Code:
<?php

$query 
mysql_query("SELECT COUNT(id) AS tpl_count FROM templates") or die(mysql_error());
$numtemplates mysql_fetch_assoc($query);
$numtemplates $numtemplates['tpl_count'];

echo 
$numtemplates;

?>
and could be something similar for the others..
Eric is offline  
Old 01-07-2007, 11:16 PM THREAD STARTER               #3 (permalink)
Account Suspended
Join Date: Jun 2006
Posts: 472
Gandhi is a splendid one to beholdGandhi is a splendid one to beholdGandhi is a splendid one to beholdGandhi is a splendid one to beholdGandhi is a splendid one to beholdGandhi is a splendid one to beholdGandhi is a splendid one to beholdGandhi is a splendid one to behold
 


Find Marrow Donors! Cancer Survivorship Adoption Wildlife Cystic Fibrosis
Thanks for the code, really appreciate it

When I enterted the code I got this error

PHP Code:
Warningmysql_query() [function.mysql-query]: Access denied for user 'wwwtemp'@'localhost' (using passwordNOin /home2/wwwtemp/public_html/index.php on line 78
????: NamePros.com http://www.namepros.com/showthread.php?t=278437

Warning
mysql_query() [function.mysql-query]: A link to the server could not be established in /home2/wwwtemp/public_html/index.php on line 78
Access denied 
for user 'wwwtemp'@'localhost' (using passwordNO
Gandhi is offline  
Old 01-08-2007, 03:42 AM   #4 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,074
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
looking at those errors it looks like you are not actually connected to the database yet.
Peter is offline  
Old 01-08-2007, 04:47 AM   #5 (permalink)
NamePros Regular
 
-PS-'s Avatar
Join Date: Jun 2006
Location: Sydney
Posts: 251
-PS- will become famous soon enough-PS- will become famous soon enough
 



Originally Posted by 2007
Thanks for the code, really appreciate it
????: NamePros.com http://www.namepros.com/showthread.php?t=278437

When I enterted the code I got this error

PHP Code:
Warningmysql_query() [function.mysql-query]: Access denied for user 'wwwtemp'@'localhost' (using passwordNOin /home2/wwwtemp/public_html/index.php on line 78

Warning
mysql_query() [function.mysql-query]: A link to the server could not be established in /home2/wwwtemp/public_html/index.php on line 78
Access denied 
for user 'wwwtemp'@'localhost' (using passwordNO


Those errors are saying your trying to connect to the database with out a password, i would suggestion you check the mysql_connect/ mysql_pconnection function to make sure there's a password in there, and if your storing the password in a varible, that the varible is spelt the same in all places (it's a common problem even out experinced dev team at work suffer from .. =) )
-PS- is offline  
Old 01-08-2007, 09:33 AM   #6 (permalink)
NamePros Regular
Join Date: Jul 2006
Location: England
Posts: 721
chicker is a name known to allchicker is a name known to allchicker is a name known to allchicker is a name known to allchicker is a name known to allchicker is a name known to allchicker is a name known to allchicker is a name known to all
 


Save The Children
At this to the top if you do not have a config page,
<?

$dbhost = "localhost"; // database host, most of the time localhost
$dbuser = "username"; // database user
$dbpass = "pass"; // database password
$dbname = "dbname"; // database name

// DO NOT EDIT
mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db("$dbname");

?>

That will connect for you, else do an include once with your php config file
chicker is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 02:18 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger