need help spliting this code
Posted: Wed Apr 06, 2005 5:34 am
Hi
I found this code:
And edited it to:
Which fully works,
Then I tried to split it up,
Thats when I ran into problems,
http://www.rc-expertise.com/build.php (See Graupner HotSpot )
Im trying to show the hits on build.php
while insert the hits into a DB via a
differant server (wrap.php?url=http://vk1.blogdns.com/build/hs)
Here is how I split it up:
build.php (in the table)
And on index.php on the other server
I have:
I have two Problems.
ONE
on http://www.rc-expertise.com/wrap.php?ur ... m/build/hs
I get:
What does that mean.
TWO
I but index.php (from the other server) onto
the same server, and the counter works fine....
http://www.rc-expertise.com/build/index.php (bottom of the page)
But now, on http://www.rc-expertise.com/build.php It isnt collecting the
info from the DB.
This is driven me mad!!
Please help me!!!!
I found this code:
Code: Select all
<?php
/*
SQL Dump:
CREATE TABLE `hits` (
`id` smallint(8) NOT NULL default '0',
`ip` varchar(15) NOT NULL default '',
`time` varchar(20) NOT NULL default ''
) TYPE=MyISAM;
CREATE TABLE `uhits` (
`id` int(8) NOT NULL default '0',
`ip` varchar(15) NOT NULL default '',
`time` varchar(15) NOT NULL default '',
KEY `id` (`id`)
) TYPE=MyISAM;
*/
// Configuration
$sql_host = "localhost"; // MySQL host
$sql_user = "root"; // MySQL username
$sql_pass = "my_pass"; // MySQL password
$sql_data = "my_database"; // MySQL database
/////////////////////////////////////////////////////////////////////////
// Setting the time and IP into variables
$time = date("mdY");
$ip = $_SERVER['REMOTE_ADDR'];
// Connection to the mysql database...
$sql_c = mysql_connect("$sql_host", "$sql_user", "$sql_pass") or die("MySQL Error:\n".mysql_error()."");
// Selecting the mysql database...
mysql_select_db("$sql_data") or die("MySQL Error: ".mysql_error()."");
// Getting and updating "all hits"
$j_hits = mysql_query("SELECT * FROM `hits`") or die("MySQL Error:\n ".mysql_error()."");
if (mysql_num_rows($j_hits) <= 0) { $hits = "1"; } else { $hits = mysql_num_rows($j_hits)+1; }
mysql_query("INSERT INTO `hits` (ip,time) VALUES ('$ip','$time')") or die("MySQL Error:\n".mysql_error()."");
// Getting today's hits
$t_hits = mysql_query("SELECT * FROM `hits` WHERE `time` = '$time'") or die("MySQL Error:\n".mysql_error()."");
if (mysql_num_rows($t_hits) <= 0) { $thits = "1"; } else { $thits = mysql_num_rows($t_hits); }
// Getting and updating "all unique hits"
$u_hits = mysql_query("SELECT * FROM uhits") or die("MySQL Error:\n ".mysql_error()."");
if (mysql_num_rows($u_hits) <= 0) { $uhits = "1"; } else { $uhits = mysql_num_rows($u_hits); }
$ips = mysql_query("SELECT * FROM `uhits` WHERE ip = '$ip'") or die("MySQL Error:\n ".mysql_error()."");
if (mysql_num_rows($ips) <= 0) { mysql_query("INSERT INTO `uhits` (ip,time) VALUES ('$ip', '$time')") or die("MySQL Error:\n".mysql_error().""); }
// Getting unique hits for today
$ut_hits = mysql_query("SELECT * FROM uhits WHERE `time` = '$time'") or die("MySQL Error:\n ".mysql_error()."");
if (mysql_num_rows($ut_hits) <= 0) { $uthits = "1"; } else { $uthits = mysql_num_rows($ut_hits); }
// Closing connection to MySQL
if ($sql_c) { mysql_close($sql_c); }
// Printing out results
echo ("
Hits $hits <br />\n
Today $thits <br />\n
Unique $uhits <br />\n
Unique today $uthits <br />\n
");
?>Code: Select all
<?php
/*
SQL Dump:
CREATE TABLE `hits` (
`id` smallint(8) NOT NULL default '0',
`ip` varchar(15) NOT NULL default '',
`time` varchar(20) NOT NULL default ''
) TYPE=MyISAM;
*/
// Configuration
$sql_host = "*********"; // MySQL host
$sql_user = "********"; // MySQL username
$sql_pass = "*******"; // MySQL password
$sql_data = "******"; // MySQL database
////////////////////////////////////////////////////////////////////////////
// Setting the time and IP into variables
$time = date("mdY");
$ip = $_SERVER['REMOTE_ADDR'];
// Connection to the mysql database...
$sql_c = mysql_connect("$sql_host", "$sql_user", "$sql_pass") or die("MySQL Error:\n".mysql_error()."");
// Selecting the mysql database...
mysql_select_db("$sql_data") or die("MySQL Error: ".mysql_error()."");
// Getting and updating "all hits"
$j_es = mysql_query("SELECT * FROM `es`") or die("MySQL Error:\n ".mysql_error()."");
if (mysql_num_rows($j_es) <= 0) { $es = "1"; } else { $es = mysql_num_rows($j_es)+1; }
mysql_query("INSERT INTO `es` (ip,time) VALUES ('$ip','$time')") or die("MySQL Error:\n".mysql_error()."");
// Closing connection to MySQL
if ($sql_c) { mysql_close($sql_c); }
// Printing out results
echo ("
Hits $es <br />\n
");
?>Then I tried to split it up,
Thats when I ran into problems,
http://www.rc-expertise.com/build.php (See Graupner HotSpot )
Im trying to show the hits on build.php
while insert the hits into a DB via a
differant server (wrap.php?url=http://vk1.blogdns.com/build/hs)
Here is how I split it up:
build.php (in the table)
Code: Select all
<?php
$sql_host = "*********"; // MySQL host
$sql_user = "********"; // MySQL username
$sql_pass = "*******"; // MySQL password
$sql_data = "******"; // MySQL database
?>
<?php
$sql_c = mysql_connect("$sql_host", "$sql_user", "$sql_pass") or die("MySQL Error:\n".mysql_error()."");
// Selecting the mysql database...
mysql_select_db("$sql_data") or die("MySQL Error: ".mysql_error()."");
$j_hs = mysql_query("SELECT * FROM `hs`") or die("MySQL Error:\n ".mysql_error()."");
if (mysql_num_rows($j_hs) <= 0) { $es = "1"; } else { $hs = mysql_num_rows($j_hs)+1; }
echo (" Hits: $hs ");
?>And on index.php on the other server
I have:
Code: Select all
<?php
$sql_host = "*********"; // MySQL host
$sql_user = "********"; // MySQL username
$sql_pass = "*******"; // MySQL password
$sql_data = "******"; // MySQL database
?>
<?php
// Setting the time and IP into variables
$time = date("mdY");
$ip = $_SERVER['REMOTE_ADDR'];
// Connection to the mysql database...
$sql_c = mysql_connect("$sql_host", "$sql_user", "$sql_pass") or die("MySQL Error:\n".mysql_error()."");
// Selecting the mysql database...
mysql_select_db("$sql_data") or die("MySQL Error: ".mysql_error()."");
// Getting and updating "all hits"
$j_es = mysql_query("SELECT * FROM `es`") or die("MySQL Error:\n ".mysql_error()."");
if (mysql_num_rows($j_es) <= 0) { $es = "1"; } else { $es = mysql_num_rows($j_es)+1; }
mysql_query("INSERT INTO `es` (ip,time) VALUES ('$ip','$time')") or die("MySQL Error:\n".mysql_error()."");
// Closing connection to MySQL
if ($sql_c) { mysql_close($sql_c); }
// Printing out results
echo ("
Hits $es <br />\n
");
?>ONE
on http://www.rc-expertise.com/wrap.php?ur ... m/build/hs
I get:
Code: Select all
Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in /var/www/vk1/build/hs/index.php on line 335
MySQL Error: Client does not support authentication protocol requested by server; consider upgrading MySQL clientTWO
I but index.php (from the other server) onto
the same server, and the counter works fine....
http://www.rc-expertise.com/build/index.php (bottom of the page)
But now, on http://www.rc-expertise.com/build.php It isnt collecting the
info from the DB.
This is driven me mad!!
Please help me!!!!