PHP Loading Script

  • Ads

PHP Loading Script

Postby TheKiller » Fri Jun 11, 2010 10:08 am

Greetings Everyone !
i Was Searching For a Time Zone DataBase on Google with this Keywords :Country Time Zone Free SQL Download

And made it here ! :D

i already had a Country Database Powered by IP2Nation.Com
but i will change it soon as i finally found a FREE Database Including City's as well !!!! :D (Yours)
Between ..
it will be great if you could Support continents and ISP s also

okay lets start the thing regarding the Timezone lol



i cant understand the this script...



SELECT tzd.gmtoff, tzd.isdst, tz.name
FROM `timezones_data` tzd
JOIN `timezones` tz ON tz.id = tzd.timezone
WHERE tzd.timezone = (
SELECT `timezone`
FROM `fips_regions`
WHERE `country_code` = 'CA'
AND `code` = '10' )
AND tzd.start < UNIX_TIMESTAMP( now( ) )
ORDER BY tzd.start DESC
LIMIT 1

could someone please offer me a script with the database login etc
the script isnt telling me much :|


Between .. Marc could you please enable the bbcodes and avatars
TheKiller
 
Posts: 25
Joined: Fri Jun 11, 2010 9:18 am
Location: Romania

Re: PHP Loading Script

Postby marchost » Mon Jun 14, 2010 6:23 am

Hi, im not sure exactly what you mean by database login... The code is not PHP but simply a MySQL query

Marc
marchost
Site Admin
 
Posts: 374
Joined: Wed Apr 08, 2009 9:55 pm

Re: PHP Loading Script

Postby TheKiller » Tue Jun 15, 2010 10:14 am

yes , its a MySQL Query that gows into a .php file and needs a user and password to connect to the database
if i am unclear please tell me how to use this query to query the database without to connect to the database

and between can you please activate more forum features ,like BBCodes and even smiles if you could :)
and please remove me from the moderation queue so ill be able to post without moderator approving as i am not a spammer

EDIT: Nevermind i saw that i was able to post this without Moderator approval so thank you :D

EDIT Again:6:33PM (Romanias hour)

i just thought better and i see what you were saying ...
sorry


Could you please help me with a PHP Script that posts the TimeZone of an IP ?
TheKiller
 
Posts: 25
Joined: Fri Jun 11, 2010 9:18 am
Location: Romania

Re: PHP Loading Script

Postby TheKiller » Tue Jun 15, 2010 12:13 pm

yay !!

Sorry for the double posting
i ve just managed to write the SQL Query For PHP
but its not really how i wish it to be

<?
$server = ''; // MySQL HostName
$username = 'USER; // MySQL UserName
$password = 'PASS'; // MySQL Password
$dbname = 'NAME'; // MySQL db Name

$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());

$sql = "SELECT
tzd.gmtoff, tzd.isdst, tz.name
FROM timezones_data tzd

JOIN timezones tz ON tz.id = tzd.timezone
WHERE tzd.timezone = (SELECT timezone FROM fips_regions WHERE country_code = 'RO' AND code = '10' )
AND tzd.start < UNIX_TIMESTAMP( now( ) )
ORDER BY tzd.start DESC
LIMIT 0,1";


$rows=list($gmtoff ,$isdst ,$name) = mysql_fetch_row(mysql_query($sql));
echo "<pre>",print_r($rows),"</pre>";
?>

The [CODE] [/CODE] BBCode would be very useful now .. or the [php] [/php] tag -.-

Anyways i couldnt figure it out how to imput the country code ....
TheKiller
 
Posts: 25
Joined: Fri Jun 11, 2010 9:18 am
Location: Romania

Re: PHP Loading Script

Postby TheKiller » Mon Jun 21, 2010 4:25 am

Marc can you please help me on the script?
TheKiller
 
Posts: 25
Joined: Fri Jun 11, 2010 9:18 am
Location: Romania

Re: PHP Loading Script

Postby marchost » Thu Jun 24, 2010 1:27 pm

Hi sorry for my late answer, I was away for some time... You must put the code inside a function such as this :

function getTimezone($country_code, $region_code) {
$sql = "SELECT
tzd.gmtoff, tzd.isdst, tz.name
FROM timezones_data tzd
JOIN timezones tz ON tz.id = tzd.timezone
WHERE tzd.timezone = (SELECT timezone FROM fips_regions WHERE country_code = '$country_code' AND code = '$region_code' )
AND tzd.start < UNIX_TIMESTAMP( now( ) )
ORDER BY tzd.start DESC
LIMIT 0,1";
}
marchost
Site Admin
 
Posts: 374
Joined: Wed Apr 08, 2009 9:55 pm

Re: PHP Loading Script

Postby TheKiller » Sat Jun 26, 2010 8:44 am

Marc that is giving me an SQL error

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/USER/domains/wheresmyip.net/public_html/TEST/index.php on line 46

Ive never meet a SQL Error b4 and idk what to do
can you give me a hand on the script please

<?
$server = ''; // MySQL HostName
$username = ' '; // MySQL UserName
$password = ' '; // MySQL Password
$dbname = ' ';// MySQL db Name

$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());

function getTimezone($country_code, $region_code) {
$sqltest = "SELECT
tzd.gmtoff, tzd.isdst, tz.name
FROM timezones_data tzd

JOIN timezones tz ON tz.id = tzd.timezone
WHERE tzd.timezone = (SELECT timezone FROM fips_regions WHERE country_code = '$country_code' AND code = '$region_code' )
AND tzd.start < UNIX_TIMESTAMP( now( ) )
ORDER BY tzd.start DESC
LIMIT 0,1";
}


$rows=list($gmtoff ,$isdst ,$name) = mysql_fetch_row(mysql_query($sqltest));//LINE 46
echo "<pre>",print_r($rows),"</pre>";
?>
TheKiller
 
Posts: 25
Joined: Fri Jun 11, 2010 9:18 am
Location: Romania

Re: PHP Loading Script

Postby marchost » Sat Jun 26, 2010 8:57 am

Hi, please google around to understand the principle of a function in PHP...

<?
$server = ''; // MySQL HostName
$username = ' '; // MySQL UserName
$password = ' '; // MySQL Password
$dbname = ' ';// MySQL db Name

$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());

function getTimezone($country_code, $region_code) {
$sqltest = "SELECT
tzd.gmtoff, tzd.isdst, tz.name
FROM timezones_data tzd

JOIN timezones tz ON tz.id = tzd.timezone
WHERE tzd.timezone = (SELECT timezone FROM fips_regions WHERE country_code = '$country_code' AND code = '$region_code' )
AND tzd.start < UNIX_TIMESTAMP( now( ) )
ORDER BY tzd.start DESC
LIMIT 0,1";

$query = mysql_query($sqltest, $db);
return mysql_fetch_array($query);
}

echo getTimezone('CA', '10');

I didnt test it, just to show you how to work with functions

Marc
marchost
Site Admin
 
Posts: 374
Joined: Wed Apr 08, 2009 9:55 pm

Re: PHP Loading Script

Postby TheKiller » Thu Jul 08, 2010 7:22 pm

Why dont you provide a PHP Script For ppls to use for the Country And Timezne databases :|

in my opinion the SQL script you provide is useless to ppls that dont know how to merge it with PHP
and run the database on a site
TheKiller
 
Posts: 25
Joined: Fri Jun 11, 2010 9:18 am
Location: Romania

Re: PHP Loading Script

Postby TheKiller » Fri Aug 13, 2010 3:26 pm

hey again ...........
Marc Could you please provide a PHP script to load The database ... ?
i am not that advanced in php and i know nothing about MySQL Or the PHP Classes yet

it would be helpful for others also not only me
TheKiller
 
Posts: 25
Joined: Fri Jun 11, 2010 9:18 am
Location: Romania

Next

Return to Timezone database related



Who is online

Users browsing this forum: No registered users and 1 guest