Last edited:
<?
$key = (isset($_GET['key'])) ? $_GET['key'] : 0;
$query = (isset($_GET['query'])) ? $_GET['query'] : "";
$databasehost = "*******************************";
$databasename = "*******************************";
$databaseusername ="*******************************";
$databasepassword = "*******************************";
$where = $key;
if ( $where == null ) {print "key invalid";return;}
$action = array();
$action = split(" ", strtolower($query));
if ( $action[0] == "select" )
{
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query." where a04='".(string)$key."'";
$objQuery = mysql_query($strSQL);
$intNumRows = mysql_num_rows($objQuery);
if ( $intNumRows == null || $intNumRows = 0 )
{
print "No records found";
mysql_close($objConnect);
return;
}
$rows = array();
while($r = mysql_fetch_assoc($objQuery ))
{
$rows[] = $r;
}
print json_encode($rows);
mysql_close($objConnect);
}
else if ( $action[0] == "update")
{
print $action[0]." ok";
}
else if ( $action[0] == "insert")
{
print $action[0]." ok";
}
else if ( $action[0] == "delete")
{
print $action[0]." ok";
}
else
{
print "Error code string: <font color='red'>".strtolower($query)."</font>";
}
?>
1) realstudio (che mi sta facendo incazzare con insert) osx, windows, linux
2) android
3) windows mobile
4) ios (ma ho bisogno di una mano concreta)
<?
$key = (isset($_GET['key'])) ? $_GET['key'] : 0;
$querystring = (isset($_GET['query'])) ? $_GET['query'] : "";
$query = base64_decode($querystring);
$fp = fopen('data.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$databasehost = "xxxxxxxxxxxxxx";
$databasename = "xxxxxxxxxxxxx";
$databaseusername ="xxxxxxxxxxxxxx";
$databasepassword = "xxxxxxxxxxxxxxxxxxxxxx";
$where = $key;
if ( $where == null ) {print "key invalid";return;}
$action = array();
$action = split(" ", strtolower($query));
if ( $action[0] == "select" )
{
$fp = fopen('select.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query." where a04='".(string)$key."'";
$objQuery = mysql_query($strSQL);
$intNumRows = mysql_num_rows($objQuery);
if ( $intNumRows == null || $intNumRows = 0 )
{
print "No records found";
mysql_close($objConnect);
return;
}
$rows = array();
while($r = mysql_fetch_assoc($objQuery ))
{
$rows[] = $r;
}
print json_encode($rows);
mysql_close($objConnect);
}
else if ( $action[0] == "update")
{
$fp = fopen('update.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query;
$objQuery = mysql_query($strSQL);
mysql_close($objConnect);
print $action[0]." ok";
}
else if ( $action[0] == "insert")
{
$fp = fopen('insert.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query;
$objQuery = mysql_query($strSQL);
mysql_close($objConnect);
print $action[0]." ok";
}
else if ( $action[0] == "delete")
{
$fp = fopen('delete.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query;
$objQuery = mysql_query($strSQL);
mysql_close($objConnect);
print $action[0]." ok";
}
else
{
$fp = fopen('error.txt', 'w');
fwrite($fp, $query);
fclose($fp);
print "Error code string: <font color='red'>".strtolower($query)."</font>";
}
?>
Quali sono i simboli speciali che danno fastidio a mysql?
io so solo questo: '
ci sono altri?
<?
ob_start();
session_start();
//error_reporting (E_ERROR);
$_SESSION['debug'] = "on";
if ( isset($_SESSION['debug']) && $_SESSION['debug']=="on" ) {
error_reporting (E_ALL ^ E_NOTICE); // tutti tranne E_NOTICE
ini_set("display_errors", 1);
}
else
{
error_reporting (E_ERROR | E_WARNING);
ini_set("display_errors", 0);
}
ini_set("log_errors","on");
ini_set("error_log","./runtime_error.txt");
$fp = fopen('loadquery.txt', 'a');
fwrite($fp, "start:\r\n");
fclose($fp);
$key = (isset($_POST['key'])) ? $_POST['key'] : 0;
$querystring = (isset($_POST['query'])) ? $_POST['query'] : "";
$query = base64_decode($querystring);
$databasehost = "xxxxxxxx";
$databasename = "xxxxxx";
$databaseusername ="xxxxxxxxx";
$databasepassword = "xxxxxxxxxxxxx";
$where = $key;
if ( $where == null ) {print "key invalid";return;}
$action = array();
$action = split(" ", strtolower($query));
if ( $action[0] == "select" )
{
$fp = fopen('select.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query." where a04='".(string)$key."'";
$objQuery = mysql_query($strSQL);
$intNumRows = mysql_num_rows($objQuery);
if ( $intNumRows == null || $intNumRows = 0 )
{
print "No records found";
mysql_close($objConnect);
return;
}
$rows = array();
while($r = mysql_fetch_assoc($objQuery ))
{
$rows[] = $r;
}
print json_encode($rows);
mysql_close($objConnect);
}
else if ( $action[0] == "update")
{
$fp = fopen('update.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query;
$objQuery = mysql_query($strSQL);
mysql_close($objConnect);
print $action[0]." ok";
}
else if ( $action[0] == "insert")
{
$fp = fopen('insert.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query;
$objQuery = mysql_query($strSQL);
if (mysql_errno()) {
echo "MySQL error ".mysql_errno().": ".mysql_error()."\r\n<br>When executing:<br>\n$query\n<br>";
}
mysql_close($objConnect);
print $action[0]." ok";
}
else if ( $action[0] == "delete")
{
$fp = fopen('delete.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query;
$objQuery = mysql_query($strSQL);
mysql_close($objConnect);
print $action[0]." ok";
}
else
{
$fp = fopen('error.txt', 'w');
fwrite($fp, $query);
fclose($fp);
print "Error code string: <font color='red'>".strtolower($query)."</font>";
}
$fp = fopen('loadquery.txt', 'a');
fwrite($fp, "query:$query\r\n");
fclose($fp);
?>
<?
ob_start();
session_start();
$_SESSION['debug'] = "on";
if ( isset($_SESSION['debug']) && $_SESSION['debug']=="on" ) {
error_reporting (E_ALL ^ E_NOTICE); // tutti tranne E_NOTICE
ini_set("display_errors", 1);
}
else
{
error_reporting (E_ERROR | E_WARNING);
ini_set("display_errors", 0);
}
ini_set("log_errors","on");
ini_set("error_log","./runtime_error.txt");
$fp = fopen('loadquery.txt', 'a');
fwrite($fp, "start:\r\n");
fclose($fp);
$key = (isset($_POST['key'])) ? $_POST['key'] : 0;
$querystring = (isset($_POST['query'])) ? $_POST['query'] : "";
$idrecord = (isset($_POST['idrecord'])) ? $_POST['idrecord'] : "";
$query = base64_decode($querystring);
$databasehost = "xxxxxx";
$databasename = "xxxxxx";
$databaseusername ="xxxxxx";
$databasepassword = "xxxxx";
$where = $key;
if ( $where == null ) {print "key invalid";return;}
$action = array();
$action = split(" ", strtolower($query));
if ( $action[0] == "select" )
{
$fp = fopen('select.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query." where a04='".(string)$key."'";
$objQuery = mysql_query($strSQL);
$intNumRows = mysql_num_rows($objQuery);
if ( $intNumRows == null || $intNumRows = 0 )
{
print "No records found";
mysql_close($objConnect);
return;
}
$rows = array();
while($r = mysql_fetch_assoc($objQuery ))
{
$rows[] = $r;
}
print json_encode($rows);
mysql_close($objConnect);
}
else if ( $action[0] == "update")
{
$fp = fopen('update.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query." where a04='".(string)$key."' and id='".$idrecord."'";
$objQuery = mysql_query($strSQL);
mysql_close($objConnect);
print $action[0]." ok";
}
else if ( $action[0] == "insert")
{
$fp = fopen('insert.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query;
$objQuery = mysql_query($strSQL);
if (mysql_errno()) {
echo "MySQL error ".mysql_errno().": ".mysql_error()."\r\n<br>When executing:<br>\n$query\n<br>";
}
mysql_close($objConnect);
print $action[0]." ok";
}
else if ( $action[0] == "delete")
{
$fp = fopen('delete.txt', 'w');
fwrite($fp, $query);
fclose($fp);
$objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword);
$objDB = mysql_select_db($databasename );
$strSQL = $query." where a04='".(string)$key."' and id='".$idrecord."'";
$objQuery = mysql_query($strSQL);
mysql_close($objConnect);
print $action[0]." ok";
}
else
{
$fp = fopen('error.txt', 'w');
fwrite($fp, $query);
fclose($fp);
print "Error code string: <font color='red'>".strtolower($query)."</font>";
}
$fp = fopen('loadquery.txt', 'a');
fwrite($fp, "query:$query\r\n");
fclose($fp);
?>
qui posto il codice dell'intera pagina, con le relative modifiche di insert + select + update + delete con relativa kiave di relazione. Il codice è stato testato 2 giorni e credo possa essere al completo.
Chi vuole testare sono lieto di sentire i suoi commenti.
PHP:<? ob_start(); session_start(); $_SESSION['debug'] = "on"; if ( isset($_SESSION['debug']) && $_SESSION['debug']=="on" ) { error_reporting (E_ALL ^ E_NOTICE); // tutti tranne E_NOTICE ini_set("display_errors", 1); } else { error_reporting (E_ERROR | E_WARNING); ini_set("display_errors", 0); } ini_set("log_errors","on"); ini_set("error_log","./runtime_error.txt"); $fp = fopen('loadquery.txt', 'a'); fwrite($fp, "start:\r\n"); fclose($fp); $key = (isset($_POST['key'])) ? $_POST['key'] : 0; $querystring = (isset($_POST['query'])) ? $_POST['query'] : ""; $idrecord = (isset($_POST['idrecord'])) ? $_POST['idrecord'] : ""; $query = base64_decode($querystring); $databasehost = "xxxxxx"; $databasename = "xxxxxx"; $databaseusername ="xxxxxx"; $databasepassword = "xxxxx"; $where = $key; if ( $where == null ) {print "key invalid";return;} $action = array(); $action = split(" ", strtolower($query)); if ( $action[0] == "select" ) { $fp = fopen('select.txt', 'w'); fwrite($fp, $query); fclose($fp); $objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword); $objDB = mysql_select_db($databasename ); $strSQL = $query." where a04='".(string)$key."'"; $objQuery = mysql_query($strSQL); $intNumRows = mysql_num_rows($objQuery); if ( $intNumRows == null || $intNumRows = 0 ) { print "No records found"; mysql_close($objConnect); return; } $rows = array(); while($r = mysql_fetch_assoc($objQuery )) { $rows[] = $r; } print json_encode($rows); mysql_close($objConnect); } else if ( $action[0] == "update") { $fp = fopen('update.txt', 'w'); fwrite($fp, $query); fclose($fp); $objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword); $objDB = mysql_select_db($databasename ); $strSQL = $query." where a04='".(string)$key."' and id='".$idrecord."'"; $objQuery = mysql_query($strSQL); mysql_close($objConnect); print $action[0]." ok"; } else if ( $action[0] == "insert") { $fp = fopen('insert.txt', 'w'); fwrite($fp, $query); fclose($fp); $objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword); $objDB = mysql_select_db($databasename ); $strSQL = $query; $objQuery = mysql_query($strSQL); if (mysql_errno()) { echo "MySQL error ".mysql_errno().": ".mysql_error()."\r\n<br>When executing:<br>\n$query\n<br>"; } mysql_close($objConnect); print $action[0]." ok"; } else if ( $action[0] == "delete") { $fp = fopen('delete.txt', 'w'); fwrite($fp, $query); fclose($fp); $objConnect = mysql_connect($databasehost,$databaseusername,$databasepassword); $objDB = mysql_select_db($databasename ); $strSQL = $query." where a04='".(string)$key."' and id='".$idrecord."'"; $objQuery = mysql_query($strSQL); mysql_close($objConnect); print $action[0]." ok"; } else { $fp = fopen('error.txt', 'w'); fwrite($fp, $query); fclose($fp); print "Error code string: <font color='red'>".strtolower($query)."</font>"; } $fp = fopen('loadquery.txt', 'a'); fwrite($fp, "query:$query\r\n"); fclose($fp); ?>
spero possa essere utile.
Come ti ho detto non sonu un grandissimo esperto!!
Cos'è la key?
come passo la querry a questa pagina?
puoi darmi un po di spiegazioni?
Oggi faccio una prova con Basic4Android poi posto il progetto.
Ho fatto un po di ricerche,correggimi se sbaglio!
Con il metodo $POST le pagine rimane sempre una traci abilita con e sicurezza,avevo fatto al mo tempo una cosa simile con vb.net e avevo notato che aprendo il brauser mi rimanevano i record sul indirizzo non sono molto bravo a spiegarti spero mi capisci.
Sto provando a fare una pagina di esempio in php che poi magari se sei molto più bravo potresti dargli un occhiata!
<?
$userdb="xxxxxxxxxxxxxxxx";
$passworddb="xxxxxxxxxxxxxxxx";
$databasedb="xxxxxxxxxxxxxxxx";
$con = mysql_connect("localhost",$userdb,$passworddb) or die(mysql_error());
mysql_select_db($databasedb) or die(mysql_error());
$query = file_get_contents("php://input");
//$sth = mysql_query($query);
$action = array();
$action = split(" ", strtolower($query));
$key = "aXZhbm9tb250aUBsaWJlcm8uaXQ=";
$arr1 = array();
$arr1 = split($key, ($query));
$key1 = (strtolower($action[0]));
$key2 = $key;
$key2 = (strtolower($key2));
$action[0] = str_replace($key2, "", $action[0]);
// tolgo la key all query
$query2 = str_replace($key, "", $query);
$kiavedicontrollo = str_replace($query2, "", $query);
// verifico che la key non sia nulla
if ( $kiavedicontrollo == null )
{
print json_encode("key invalid!");
return;
}
else
{
// verifico che la sia uguale alla key spedita
if ( $kiavedicontrollo == $key )
{
if ( $action[0] == "select" )
{
$sth = mysql_query($query2);
//print json_encode("1");
}
if ( $action[0] == "update" )
{
$sth = mysql_query($query2);
//print json_encode("2");
}
if ( $action[0] == "insert" )
{
$sth = mysql_query($query2);
//print json_encode("3");
}
// Blocco per Sicurezza database
if ( $action[0] == "delete" )
{
print json_encode("Non e possibile!");
}
if ( $action[0] == "create" )
{
print json_encode("Non e possibile!");
}
}
}
// Db
if (mysql_errno()) {
header("HTTP/1.1 500 Internal Server Error");
echo ("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysql_error();
}
else
{
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
}
?>
"aXZhbm9tb250aUBsaWJlcm8uaXQ="&"UPDATE "&Face.str_query&" SET name='fffujgjgjhff',id_phone='2',pw='3',amministrator='false',luogo='4' WHERE "&Face.str_query&".ID='17';",1
Sub hc_login_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Try
Dim res As String
res = Response.GetString("UTF8")
Log("Response from server login: " & res)
If Face.login=True Then
ProgressDialogHide
Dim parser As JSONParser
parser.Initialize(res)
Dim l As List
l = parser.NextArray
Dim m As Map
For i = 0 To l.Size - 1
m = l.Get(i)
Dim str_map As String
str_map=""
str_map=m
Dim cc As Int
Dim dd As Int
Dim str1 As String
cc =func.InStr(str_map,"name=")
dd =func.InStr(str_map,"}")
str1=str_map.SubString2(cc,dd)
str1= str1.Replace("name=","")
If str1=EditText_nome.text Then
Dim ccc As Int
Dim ddd As Int
Dim str2 As String
ccc =func.InStr(str_map,"pw=")
ddd =func.InStr(str_map,", name")
str2=str_map.SubString2(ccc,ddd)
str2= str2.Replace("pw=","")
If Decrypt(str2)=EditText_pw.text Then
Dim cc1 As Int
Dim dd1 As Int
Dim strg As String
cc1 =func.InStr(str_map,"ID=")
dd1 =func.InStr(str_map,",")
strg=str_map.SubString2(cc1,dd1)
strg= strg.Replace("ID=","")
Face.login_id=strg
Face.login_nome= EditText_nome.text
save_config("Login OK!")
mnuPage2_Click
Face.login_ok=True
End If
End If
Next
End If
Face.login=False
Response.Release
ProgressDialogHide
Catch
Msgbox("Errore!","")
Face.login=False
Response.Release
ProgressDialogHide
End Try
End Sub
Ho modificato un po di cose e migliorandola parecchio!
grazie ai consigli di ivanomonti! grazie
Sono felice, io sto finendo il progetto sotto windows phone che poi posto direttamente nel sito in quanto il mio progetto prevede di creare api via php per tutti i dispositivi (osx,android, windows phone, windows desktop, mac desktop e linux ... ma molto probabilmente anche per web os e altri.
le risorse che devo scrivere sono in
1) windows phone (visual studio)
2) windows desktop (visual studio (net) e RealStudio)
3) Max osx desktop (xcode e Realstudio)
4) Linux (realstudio)
5) android Basic4Android
7) web (realstudio & php)
speriamo di finire tutto il progetto questa volta, di solito poi abbandono.
ivanomonti scusa una domanda,
Cos'è la key? Da dove la prelevi ?è la private sing key? o un numero a caso?
Aggiornata versione 1.2
Versione 1.2
Versione 1.2
Modifiche:
Aggiunto Log Out
Correzione vari bugs
Controllo Network State
Aggiunto Ricorda Password
Aggiunto panello hello World dopo aver eseguito il login.