M MohammadNew Active Member Licensed User Longtime User Mar 21, 2017 #1 Hello everyone, I have problem with insert data error web request too long > because I insert base64string Code: Copy Dim InsertNewPerson As HttpJob InsertNewPerson.Initialize("InsertNewP", Me) InsertNewPerson.download2("http://" & ServerIP & "/persons.php", Array As String ("action", "InsertNewPerson", "name", NameET.Text, "age", AgeET.Text, "img",img64)) but without base64string it is done.
Hello everyone, I have problem with insert data error web request too long > because I insert base64string Code: Copy Dim InsertNewPerson As HttpJob InsertNewPerson.Initialize("InsertNewP", Me) InsertNewPerson.download2("http://" & ServerIP & "/persons.php", Array As String ("action", "InsertNewPerson", "name", NameET.Text, "age", AgeET.Text, "img",img64)) but without base64string it is done.
S sorex Expert Licensed User Longtime User Mar 21, 2017 #21 you forgot to quote the $img as it is text! INSERT INTO persons (name, age, img) VALUES ('$name', $age, '$img') make sure the age field is a numeric one or you need to quote it aswell Upvote 0
you forgot to quote the $img as it is text! INSERT INTO persons (name, age, img) VALUES ('$name', $age, '$img') make sure the age field is a numeric one or you need to quote it aswell
M MohammadNew Active Member Licensed User Longtime User Mar 21, 2017 #22 I tried with img and without img nothing happened Code: Copy this work without img InsertNewPerson.download2("http://" & ServerIP & "/persons.php", Array As String ("action", "InsertNewPerson", "name", NameET.Text, "age", AgeET.Text)) this does not work without img and with img InsertNewPerson.postString("http://" & ServerIP & "/persons.php","action=InsertNewPerson & name="& NameET.Text &"&age="& AgeET.Text) I think the problem with "poststring" I put ' ' in all because text Upvote 0
I tried with img and without img nothing happened Code: Copy this work without img InsertNewPerson.download2("http://" & ServerIP & "/persons.php", Array As String ("action", "InsertNewPerson", "name", NameET.Text, "age", AgeET.Text)) this does not work without img and with img InsertNewPerson.postString("http://" & ServerIP & "/persons.php","action=InsertNewPerson & name="& NameET.Text &"&age="& AgeET.Text) I think the problem with "poststring" I put ' ' in all because text
M MohammadNew Active Member Licensed User Longtime User Mar 21, 2017 #23 this is structure of the table Upvote 0
M MohammadNew Active Member Licensed User Longtime User Mar 21, 2017 #24 Code: Copy <?php $host = "my server"; $user = "my user"; $pw = "my pass"; $db = "my db"; $con = mysql_connect($host,$user,$pw) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); mysql_query("SET CHARACTER SET utf8"); mysql_query("SET NAMES 'utf8'"); $action = $_POST["action"]; switch ($action) { case "CountPersons": $q = mysql_query("SELECT * FROM persons"); $count = mysql_num_rows($q); print json_encode($count); break; Case "GetPersons": $q = mysql_query("SELECT name, age FROM persons"); $rows = array(); while($r = mysql_fetch_assoc($q)) { $rows[] = $r; } print json_encode($rows); break; case "InsertNewPerson": $name = $_POST["name"]; $age = $_POST["age"]; $q = mysql_query("INSERT INTO persons (name, age) VALUES ('$name', '$age')"); print json_encode("Inserted"); break; } ?> Upvote 0
Code: Copy <?php $host = "my server"; $user = "my user"; $pw = "my pass"; $db = "my db"; $con = mysql_connect($host,$user,$pw) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); mysql_query("SET CHARACTER SET utf8"); mysql_query("SET NAMES 'utf8'"); $action = $_POST["action"]; switch ($action) { case "CountPersons": $q = mysql_query("SELECT * FROM persons"); $count = mysql_num_rows($q); print json_encode($count); break; Case "GetPersons": $q = mysql_query("SELECT name, age FROM persons"); $rows = array(); while($r = mysql_fetch_assoc($q)) { $rows[] = $r; } print json_encode($rows); break; case "InsertNewPerson": $name = $_POST["name"]; $age = $_POST["age"]; $q = mysql_query("INSERT INTO persons (name, age) VALUES ('$name', '$age')"); print json_encode("Inserted"); break; } ?>
M MohammadNew Active Member Licensed User Longtime User Mar 21, 2017 #25 I am going to do insert now without img via poststring Upvote 0
S sorex Expert Licensed User Longtime User Mar 21, 2017 #26 you have a space between "&" & "name=" there that's why it failed. Upvote 0
M MohammadNew Active Member Licensed User Longtime User Mar 21, 2017 #27 correct . Thanks alot. Upvote 0
M MohammadNew Active Member Licensed User Longtime User Mar 21, 2017 #28 Now I add in php file this Code: Copy case "SelectPersons": $name = $_POST["name"]; $age = $_POST["age"]; $img= $_POST["img"]; $q = mysql_query("select * from persons where name='$name'"); print json_encode("Selected"); break; and what should I write select single row where name=NameET.Text Upvote 0
Now I add in php file this Code: Copy case "SelectPersons": $name = $_POST["name"]; $age = $_POST["age"]; $img= $_POST["img"]; $q = mysql_query("select * from persons where name='$name'"); print json_encode("Selected"); break; and what should I write select single row where name=NameET.Text
S sorex Expert Licensed User Longtime User Mar 21, 2017 #29 add limit 0,1 to it (0=result offset, 1=amount) Upvote 0
M MohammadNew Active Member Licensed User Longtime User Mar 21, 2017 #30 really I do not know I am new with php rest .. could you past the code here please > Upvote 0
techknight Well-Known Member Licensed User Longtime User Mar 21, 2017 #31 your PHP code needs some work, actually 2 things pop out to me. For one, your not using MySQLi because mysql_xxxx is deprecated and may not even work at all at this point. and two, your not using mysqli_escape_string so you will get SQL injection exploited. My advice, watch video courses, or take a course in PHP and PHP/MariaDB/MySQL integration. Upvote 0
your PHP code needs some work, actually 2 things pop out to me. For one, your not using MySQLi because mysql_xxxx is deprecated and may not even work at all at this point. and two, your not using mysqli_escape_string so you will get SQL injection exploited. My advice, watch video courses, or take a course in PHP and PHP/MariaDB/MySQL integration.
S sorex Expert Licensed User Longtime User Mar 21, 2017 #32 learning is the cure of your problems. if you just copy paste everything each time you'll keep coming back with the same questions since you don't know what's going on. most of the things you need is just a few lines of code so you don't need to go through 500 pages of php. Upvote 0
learning is the cure of your problems. if you just copy paste everything each time you'll keep coming back with the same questions since you don't know what's going on. most of the things you need is just a few lines of code so you don't need to go through 500 pages of php.
M MohammadNew Active Member Licensed User Longtime User Mar 21, 2017 #33 techknight said: your PHP code needs some work, actually 2 things pop out to me. For one, your not using MySQLi because mysql_xxxx is deprecated and may not even work at all at this point. and two, your not using mysqli_escape_string so you will get SQL injection exploited. My advice, watch video courses, or take a course in PHP and PHP/MariaDB/MySQL integration. Click to expand... sorex said: learning is the cure of your problems. if you just copy paste everything each time you'll keep coming back with the same questions since you don't know what's going on. most of the things you need is just a few lines of code so you don't need to go through 500 pages of php. Click to expand... Thanks alot I am going to learn it . I wish get the code . Upvote 0
techknight said: your PHP code needs some work, actually 2 things pop out to me. For one, your not using MySQLi because mysql_xxxx is deprecated and may not even work at all at this point. and two, your not using mysqli_escape_string so you will get SQL injection exploited. My advice, watch video courses, or take a course in PHP and PHP/MariaDB/MySQL integration. Click to expand... sorex said: learning is the cure of your problems. if you just copy paste everything each time you'll keep coming back with the same questions since you don't know what's going on. most of the things you need is just a few lines of code so you don't need to go through 500 pages of php. Click to expand... Thanks alot I am going to learn it . I wish get the code .