PDA

View Full Version : PHP MYSQL Query to HTML in BlueVoda



theog@discovery.co.za
06-20-2006, 04:57 PM
Hi
I am trying to add a php script which queries a mysql table for my hit counter. When I upload the whole script as a seperate page to my website it works, but I'd like to integrate as html on my main website page just to see the counter.
I've included the script, any help would really be appreciated.
Thanks
Theo

include('config.php');
$date = date("d-m-Y" );
$time = time();
$select = "SELECT * FROM " . $pre . "counter WHERE ip = '$ip' AND date = '$date'";
$query = mysql_query($select);
while($l = mysql_fetch_object($query)){
$time2 = $l->time;
if($time2 > $time - $Dtime) $noentry = 1 ;
}
if(!$noentry){
$insert = "INSERT INTO " . $pre . "counter (ip, date, time) VALUES('$ip', '$date', '$time')";
$query = mysql_query($insert) or die(mysql_error());
}
$select = "SELECT * FROM " . $pre . "counter";
$query = mysql_query($select);
$num = mysql_num_rows($query);
$iparray = array();
$i = 0;
while($l = mysql_fetch_object($query)){
$ip2 = $l->ip;
$isin = 0;
$count = count($iparray);
if(!$count) $isin = 0;
for($j = 1; $j < $count + 1; $j++ ){
if($iparray[$j] == "$ip2") $isin = 1;
}
if(!$isin){
$i++;
$iparray[$i] = "$ip2";
}
}
$count = count($iparray);
echo "Hits: " . $num . "<br>";
echo"Unique hits: " . $count;
echo'<br /><a href="image.php">This month\'s chart</a>';
?>

Watdaflip
06-20-2006, 07:45 PM
Just create a html box in blue voda, enter in that complete php script. In the page properties change the file to have a .php extension and publish the page. Change any links to reflect the change from a .html to a .php extention and it should work

theog@discovery.co.za
06-22-2006, 05:00 PM
Hi
Thanks for that info, it worked! Problem is now I don't know how to change my site to using index.php in stead of index.html. I tried deleting index.html using the FTP manager, it's gone, but my default home page still opens the html page and not the php page.
Any help would be great
Theo

Watdaflip
06-22-2006, 07:13 PM
Make sure that there is only a index.php in the directory. if you type in

www.yoursite.com

It will attempt to open index.html first, if it doesn't exist, it will check for index.php and use that if it exists.

If you are still having issues then recreate index.html, and enter this on it

<META HTTP-EQUIV="Refresh" CONTENT="0; URL=index.php">

This will do an automatic redirect to index.php when index.html loads

theog@discovery.co.za
06-25-2006, 10:22 AM
Thanks for your help, that works! :-)

theog@discovery.co.za
07-14-2006, 07:06 AM
Hi
I am trying to adapt the code you gave me to re-direct my site to index.php. I have another domain, where the previous one is question is .com, this one is .co.za . I would only like to have one page on my .co.za domain, which redirects to the .com one. If I use the script as is my index.html on .com domain, it redirects to the following: http://www.sawelder.co.za/www.sawelder.com/index.php I just need it to go to www.sawelder.com (http://www.sawelder.com), from www.sawelder.co.za (http://www.sawelder.co.za) .
Excuse my ignorance, but I am very much a newby.
Kind Regards
Theo Groenewald

Nyoman
07-14-2006, 07:30 AM
it should work. write your full Url address include http://



<META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://www.sawelder.com/index.php">


or you can set your sawelder.co.za domain as a parked domain in control panel

theog@discovery.co.za
07-14-2006, 01:17 PM
thanks!