Problem with UPDATE<

windows

Guest
I've been staring at this code forever but can't figure out the problem. Every time I call updateDriverEdit() I don't get a valid return parameter in $result. I've printed out all of the parameters & they are correct, but I always get the debug statement saying there is a problem with the database. I can call the next function,
updateDriverAdd, which uses the exact same parameters & it works fine, so I don't think its a permissions problem. Is there another way to find out where the error in the query is occurring?



<?

function updateDriverEdit() {

$lastName=addslashes($_REQUEST["lastName"]);
$firstName=addslashes($_REQUEST["firstName"]);
$suffixName=addslashes($_REQUEST["suffixName"]);
$driverIndex=addslashes($_REQUEST["driverIndex"]);

$sql = <<<HERE
UPDATE driversprofile
SET
lastName="$lastName",
firstName="$firstName",
suffixName="$suffixName",
WHERE
driverIndex="$driverIndex"
HERE;

$result=mysql_query($sql);

if($result) {
Header("Location: <!-- m --><a class="postlink" href="http://localhost/public/drivers/nascarDriverTable.php">http://localhost/public/drivers/nascarDriverTable.php</a><!-- m -->");
}
else {
print "<br>There is a problem with the database, result:$result\n";
}
}

function updateDriverAdd() {

$lastName=addslashes($_REQUEST["lastName"]);
$firstName=addslashes($_REQUEST["firstName"]);
$suffixName=addslashes($_REQUEST["suffixName"]);
$driverIndex=addslashes($_REQUEST["driverIndex"]);

$sql = <<<HERE
INSERT INTO driversprofile VALUES
(NULL,"$lastName","$firstName","$suffixName")
HERE;
$result=mysql_query($sql);

if($result) {
Header("Location: <!-- m --><a class="postlink" href="http://localhost/public/drivers/nascarDriverTable.php">http://localhost/public/drivers/nascarDriverTable.php</a><!-- m -->");
}
else {
print "<br>There is a problem with the database\n";
}
}you don't need heredoc syntax for the query

$sql = "UPDATE driversprofile
SET
lastName='$lastName',
firstName='$firstName',
suffixName='$suffixName',
WHERE
driverIndex='$driverIndex'"

you don't get return parameter for it, it will be blank if it is not ran or had errors. you need this

print "<br>There is a problem with the database, result: ".mysql_error()."\n";
 
Back
Top