Current location: Hot Scripts Forums » General Web Coding » JavaScript » Making a php script into a Javascript


Making a php script into a Javascript

Reply
  #1 (permalink)  
Old 06-24-05, 05:13 PM
ghornsby ghornsby is offline
New Member
 
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Making a php script into a Javascript

Hi

Can anyone help ....

I have some php code that calls a short programme which in turns calls two other files .... Then it goes to a mysql database looks up a few things and decides whether or not to redirect you to another page, or stick with the one you're on ..... thus:


<?
require_once("pcr_val.php");
require_once("pcr_func.php");
db_open();
$sql = @mysql_Fetch_object(mysql_Query("SELECT `ip` FROM `pcr_ips` WHERE `ip`='".$REMOTE_ADDR."'"));
if(!$sql->ip){
$sql = "SELECT country FROM ip2nation WHERE ip < INET_ATON('".$REMOTE_ADDR."') ORDER BY ip DESC LIMIT 0,1";
$country = mysql_result(mysql_query($sql), 0, 0);
setcookie("user_country", $country, time()+3600);
$sql = mysql_fetch_object(mysql_query("SELECT * FROM `pcr_countries` WHERE `code`='$country'"));
db_close();
if(($sql->status == 1)&&($sql->outpage <>"")){
header("Location: $sql->outpage");
}
}
?>


*************pcr_val.php

<?php
$mysql_host = 'localhost';
$mysql_db = 'dog';
$mysql_user = 'dog';
$mysql_pass = '999';
?>



*************pcr_func.php


<?
function db_open() {
global $mysql_host, $mysql_user, $mysql_pass, $mysql_db, $mysql_link;
$mysql_link = mysql_connect($mysql_host,$mysql_user,$mysql_pass) or print mysql_error();
mysql_select_db($mysql_db) or print mysql_error();
}
function db_close() {
global $mysql_link;
@mysql_close($mysql_link) or print mysql_error();
}

?>


Does anyone know of a way I could turn the above into a single javascript, which I could insert into .html pages, with it doing the same thing?

Would be interested in any help

Thanks

Guy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-25-05, 10:24 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
That can't be done. JavaScript isn't suited for use with MySQL.
A simple redirect script is possible though.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-25-05, 11:03 AM
ghornsby ghornsby is offline
New Member
 
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks .....

I'll try it that way ....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 06-29-05, 09:33 AM
pg2sg pg2sg is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
there is possibility javascript to work with database through AJAX
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 11:17 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-25-05 12:09 AM
to get javascript in php script upendrakumar PHP 2 06-03-05 10:55 AM
PHP script problem (please help) osmanmumtaz PHP 0 05-24-05 08:29 AM
POSTing to PHP, - making a install script urlguy PHP 4 03-30-05 05:48 PM


All times are GMT -5. The time now is 09:14 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.