MySQL Forums
Forum List  »  PHP

Re: Problem with UPDATE to database table record
Posted by: Stephen Olds
Date: June 25, 2014 11:27AM

Peter Brawley Wrote:
-------------------------------------------------------
> The mysql API is deprecated and will disappear;
> use mysqli.
>
> Check the result of a query call before reporting
> that it succeeded.
>
> Do not quote table and column names in queries;
> you may surround such names with backticks (`) if
> you wish, though they're needed only if your names
> contain illegal characters.

OK, I changed it to mysqli:
<?php
$con = mysqli_connect("localhost","xxxx","xxxxxxxx");
if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con, "scw-db");
$filename = "InventoryList.txt";
$arr = file($filename);
foreach($arr as $r_bowlcode){
print $r_bowlcode . "<br />";
if (!mysqli_query($con, "UPDATE tblsplintersbowlinventory SET txtVenue='Shoreline 2014' WHERE txtProductBowlCode='$r_bowlcode'")) {
printf("Errormessage: %s\n", mysqli_error($con));
echo "Record NOT Updated<br />";
} ELSE {
echo "Record Updated<br />";
}
}
mysqli_close($con);
?>
This runs, no errors noted, but still does not do the update.
It seems like the WHERE statement is working but not finding a match, the items with the names do exist, I checked the spelling, all is correct. Is the '$r_bowlcode' syntax correct for the variable?

Options: ReplyQuote


Subject
Written By
Posted
Re: Problem with UPDATE to database table record
June 25, 2014 11:27AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.