Click to See Complete Forum and Search --> : This code seems to have an error


Anon
06-28-2000, 04:45 PM
Can someone tell me if this code seems ok. Cause no one can edit their cv on our site. The site is programmed in PHP3. I have no one to help me please help
--------------------------------------------

if (($auth->auth["uid"] == $uid) || ($perm->have_perm("admin"))) {
$results = new CVDB;
$q = "DELETE from cv where rid='$rid'";
$results->query($q);

echo "<h2>Record Deleted</h2>
Please click <a href=\"$HTTP_REFERER\">here</a> to continue searching.<br>";

Anon
06-28-2000, 08:52 PM
We'd need more code to help out. A lot of what this code is doing is evidently in a class called CVDB, we'd need to take a look at the methods that class defines to get a good idea.

Off the top of my head, I'd say check the return value of your database query, e.g.

// ($return_value >0 if query succeeds)
if ($return_value = $result->query($q)) {
echo "<h2>deleted</h2>";
} else {
echo "<h2>Record not deleted</h2>";
// check database error string here
}
...

I don't know what database you're using, if it's mysql you should check the value of mysql_error($link_identifier), other DBs will have similar functions associated with them.

Given that you're using a class to access the DB, you might want to add an error() method to your database class of the form:

function error() {
return mysql_error($link_id);
}

and check the return value of that.

HTH,

AC