I'm trying to update the form's text box city, state from the user input using onblur, focus. So far 3 days and zero results!
here is my code:
phpcode: newcityState.ph p
[CODE=php]<?php
/**
* Connects to the database.
* Return false if connection failed.
* Be sure to change the $database_name. $database_usern ame , and
* $database_passw ord values to reflect your database settings.
*/
function db_connect() {
$database_name = 'records'; // Set this to your Database Name
$database_usern ame = 'code'; // Set this to your MySQL username
$database_passw ord = 'exe:exe'; // Set this to your MySQL password
$result = mysql_pconnect( 'localhost',$da tabase_username , $database_passw ord);
if (!$result) return false;
if (!mysql_select_ db($database_na me)) return false;
return $result;
}
$conn = db_connect(); // Connect to database
if ($conn) {
$zipcode = $_GET['param']; // The parameter passed to us
$query = "select * from zipcodes where zipcode = '$zipcode'";
$result = mysql_query($qu ery,$conn);
$count = mysql_num_rows( $result);
if ($count > 0) {
$city = mysql_result($r esult,0,'city') ;
$state = mysql_result($r esult,0,'state' );
$areacode = mysql_result($r esult,0,'areaco de');
}
}
if (isset($city) && isset($state) && isset($areacode )) {
$return_value = $city . "," . $state . "," . $areacode;
}
else {
$return_value = "not correct".",".$_ GET['param']; // Include Zip for debugging purposes
}
echo $return_value; // This will become the response value for the XMLHttpRequest object
?>[/CODE]
What am I doing wrong? just can't figure out! please help!
thank you!
Ed
here is my code:
phpcode: newcityState.ph p
[CODE=php]<?php
/**
* Connects to the database.
* Return false if connection failed.
* Be sure to change the $database_name. $database_usern ame , and
* $database_passw ord values to reflect your database settings.
*/
function db_connect() {
$database_name = 'records'; // Set this to your Database Name
$database_usern ame = 'code'; // Set this to your MySQL username
$database_passw ord = 'exe:exe'; // Set this to your MySQL password
$result = mysql_pconnect( 'localhost',$da tabase_username , $database_passw ord);
if (!$result) return false;
if (!mysql_select_ db($database_na me)) return false;
return $result;
}
$conn = db_connect(); // Connect to database
if ($conn) {
$zipcode = $_GET['param']; // The parameter passed to us
$query = "select * from zipcodes where zipcode = '$zipcode'";
$result = mysql_query($qu ery,$conn);
$count = mysql_num_rows( $result);
if ($count > 0) {
$city = mysql_result($r esult,0,'city') ;
$state = mysql_result($r esult,0,'state' );
$areacode = mysql_result($r esult,0,'areaco de');
}
}
if (isset($city) && isset($state) && isset($areacode )) {
$return_value = $city . "," . $state . "," . $areacode;
}
else {
$return_value = "not correct".",".$_ GET['param']; // Include Zip for debugging purposes
}
echo $return_value; // This will become the response value for the XMLHttpRequest object
?>[/CODE]
What am I doing wrong? just can't figure out! please help!
thank you!
Ed
Comment