PDA

View Full Version : php is not responding.



nongkoogkai
11 May 2011, 7:32 PM
:((
Please see below.
this image => https://picasaweb.google.com/lh/photo/XWb7GW63FZnSnBy3j45hoj7TpmUTmleqZnn_viu0umE?feat=directlink

this javascript code

handler: function() {
simple.getForm().submit({
method : 'POST',
waitTitle:'??????',
waitMsg:'??????????????...',
success: function(options,response) {
Ext.Msg.alert('?????????', response.result.data);
},
failure: function(options,response) {
Ext.Msg.alert('???????',"?????????? <b>" + response.failureType + "</b>");
}
});
}
this php code


<?php
function mysqlConnect($host, $user, $password, $database) {
$con->mysql = mysql_connect ( $host, $user, $password );
if (! $con->mysql)
die ( mysql_error () );
mysql_select_db ( $database, $con->mysql );
}

$json = '[{"jobid":"0","description":"1","quantity":"2","unitprice":"3","duedate":"2011-05-11T00:00:00","discount":"4"},{"jobid":"0","description":"1","quantity":"2","unitprice":"3","duedate":"2011-05-11T00:00:00","discount":"4"}]';

$arr = json_decode($json);
$con = mysqlConnect("localhost", "root", "itsystem%*1", "imc");
foreach ($arr as $key => $value){
mysql_insert_array(object2array($value), "order_items");
}


function object2array($object) {
if (is_object($object)) {
foreach ($object as $key => $value) {
$array[$key] = $value;
}
}
else {
$array = $object;
}
return $array;
}

function mysql_insert_array($array, $table) {

$keys = array_keys ( $array );

for($index = 0; $index < count ( $array ); $index ++) {

if ($index != 0) {
$columns .= ",";
$values .= ",";
}

/** construct the column names from the array **/
$columns .= $keys [$index];

if (is_int ( $array [$keys [$index]] )) {
$values .= $array [$keys [$index]];
} else {
$values .= "'" . mysql_real_escape_string ( $array [$keys [$index]] ) . "'";
}
}

$query = "INSERT INTO `" . $table . "` (" . $columns . ") VALUES (" . $values . ")";

if (($result = mysql_query ( $query )) == 0)
return (0);
//echo '{"success":true,"data":"???????????? ?????"}';

if (mysql_affected_rows () == 1)
return (1);
//echo '{"success":true,"data":"????????? ?????"}';
else
return (0);
//echo '{"success":true,"data":"???????????? ?????"}';
}
echo '{"success":true,"data":"???????????? ?????"}';
?>

friend
12 May 2011, 9:46 AM
I don't see a url declared in your submit...

nongkoogkai
12 May 2011, 5:30 PM
thank you