It's just a testing script and a testing database but I can't get it to work. It's using an edit-in-place script that allows users to edit their data, then it calls this save php script which is supposed to save it and update it within the database. It does neither. Any help would be greatly appreciated.
<?php
$loggedIn = 1;
if($loggedIn == 1) {
$part = mysql_escape_string($_GET['part']);
$val = mysql_escape_string($_GET['val']);
$id = $userId;
//include 'database_connect.php';
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("johnDoe", $con);
if($part == "name") {
$array = split(" ",$val);
$name = mysql_escape_string($array[0]);
$sql = "UPDATE johnDoe SET name = '$name' WHERE id=$id";
}
else if($part == "email") {
$sql = "UPDATE johnDoe SET email = '$val' WHERE id=$id";
}
else if($part == "desc") {
$sql = "UPDATE johnDoe SET description = '$val' WHERE id=$id";
}
else if($part == "phone") {
$sql = "UPDATE johnDoe SET phone = '$val' WHERE id=$id";
}
mysql_query($sql);
mysql_close();
echo $part;
}
?>