I think the problem lies elsewhere. because I changed this:
function save_profile_date($ident = "", $first = "", $last = "", $year = "", $age = "", $gender = "") {
if ($_SESSION['is_rec']) {
$sql = sprintf("UPDATE %s SET first=%s, last=%s, year=%s, age=%s, gender=%s, last_change=NOW() WHERE cid = %s AND user_id = %s",
PROFILE_TABLE, $this->ins_string($first), $this->ins_string($last), $this->ins_string($year),
$this->ins_string($age), $this->ins_string($gender), $_SESSION['user_id']);
} else {
$sql = sprintf("INSERT INTO %s (id, user_id, first, last, year, age, gender, last_change) VALUES (NULL, %s, %s, %s, %s, %s, %s, NOW())",
PROFILE_TABLE, $_SESSION['user_id'], $this->ins_string($first), $this->ins_string($last),
$this->ins_string($year), $this->ins_string($age), $this->ins_string($gender));
}
if (mysql_query($sql) or die (mysql_error())) {
$this->profile_id = (!$_SESSION['is_rec']) ? mysql_insert_id() : $ident;
$this->the_msg = $this->extra_text(2);
} else {
$this->the_msg = $this->extra_text(3);
}
}
to this:
function save_profile_date($ident = "", $first = "", $last = "", $year = "", $age = "", $gender = "") {
$sqlupdate = "UPDATE %s SET first=%s, last=%s, year=%s, age=%s, gender=%s, last_change=NOW() WHERE cid = %s AND user_id = %s";
$sql = sprintf($sqlupdate, PROFILE_TABLE, $this->ins_string($first), $this->ins_string($last), $this->ins_string($year),
$this->ins_string($age), $this->ins_string($gender), $_SESSION['user_id']);
print($sql);
}
and still go the error: You have an error in your SQL syntax near '' at line 1
which leads me to think that the problem is in this function:
<?php
include($_SERVER['DOCUMENT_ROOT']."/user/ext_user_profile.php");
error_reporting (E_ALL); // I use this only for testing
$update_profile = new Users_profile;
$update_profile->access_page($_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']); // protect this page too.
// with this function that populates the form fileds
$update_profile->get_runner_data();
if (isset($_POST['profile_data'])) {
// i dont think its with this funciton but i could be wrong
$update_profile->save_profile_date($_POST['cid'], $_POST['first'], $_POST['last'], $_POST['year'], $_POST['age'], $_POST['gender']);
}
$error = $update_profile->the_msg; // error message
?>
where is the other function:
// Function gets the runner of the user
function get_runner_data() {
$this->get_user_CID();
$uid = $_GET['cid'];
$_SESSION['cid'] = $uid;
$sql = sprintf("SELECT cid, user_id, first, last, year, age, gender FROM %s WHERE cid = $uid", PROFILE_TABLE, $this->uid);
$result = mysql_query($sql) or die (mysql_error());
if (mysql_num_rows($result) == 0) {
$_SESSION['is_rec'] = false;
$this->the_msg = $this->extra_text(1); // There is no profile data at the moment
} else {
$_SESSION['is_rec'] = true; // this session acts like an extra controle
while ($obj = mysql_fetch_object($result)) {
$this->profile_id = $obj->cid;
$this->first = $obj->first;
$this->last = $obj->last;
$this->year = $obj->year;
$this->age = $obj->age;
$this->gender = $obj->gender;
}
}
}