Reputation: 263
I have been trying to get mysql entries to update via php from ios. I realize that I have made another question about update commands (see MySQL Update command not working) but this is a VERY different script that I am trying (and much simpler). However, I cannot get this to update either! What am I doing wrong? (ps. I have also tried this command with AND's instead of commas inbetween the sets and I have also tried $_POST...and I am connecting to my database). Also, I am just trying to figure out how to get the update command working...then I will learn how to sql inject. I have also tried manual values and still nothing.
<?php
$login = $_GET["log1b"];
$dogname = $_GET["dogname"];
$city = $_GET["city"];
$pass = $_GET["pass"];
$dogusername = $_GET["username"];
$mcode = $_GET["mcode"];
$con = mysql_connect("(censored)");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("(censored)", $con);
mysql_query("UPDATE login SET dogname = '$dogname', city = '$city', pass = '$pass', username = '$dogusername', mcode = '$mcode' WHERE login = '$login'");
mysql_close($con);
?>
or in xcode...
NSString *urlString = [NSString stringWithFormat:@"http://(censored)?username=%@&dogname=%@&mcode=%@&pass=%@&city%@&log1b=%@", fldUsername.text, flddogname.text, fldmcode.text, fldpass.text, fldcity.text, log1b];
Upvotes: 0
Views: 385
Reputation: 111
I think you are missing a '
around $city
.
Also you may want to use mysql_real_escape_string.
The syntax looks good to me now. You should try to it manually (using something like MySQL Toad) to make sure the query is valid.
Upvotes: 1