[thelist] php/mySQL update problem
Tom Dell'Aringa
pixelmech at yahoo.com
Sat Aug 23 19:37:21 CDT 2003
Hi,
I'm trying to do an update of an article. My update does not seem to
be working. When my script attempts to SELECT the newly updated
article, it does not find the newly updated article. Strangely, in my
admin page I get the updated information displayed, but it never
makes it to the database. I am not getting a mySQL error on my update
statement. Basically cannot figure this out. Here is the code
snippet. Not sure if this is enough info but hoping I'm missing
something obvious:
-----------
else if($pageAction == 'Edit')
{
$sql = "UPDATE article
SET articleTitle = '$aTitle',
authorID = '$author',
dateModified = '$aDate',
article = '$aBody',
categoryID = '$aCat',
articleBlurb = '$aBlurb'
WHERE articleID = '$aid'";
$result = mysql_query($sql);
if (!$result)
{
$msg = "Update Failed: " . mysql_error();
}
else
{
$msg = "Updated article successfully.";
$newData = @mysql_query(
"SELECT
articleID, authorID, articleTitle, UNIX_TIMESTAMP(dateCreated) as
unixtime, article, categoryID, articleBlurb
FROM
article
WHERE
articleID = '$aid'") or die ("There was a problem getting the
article: ".mysql_error());
/// RIGHT HERE - trying to get this data fails ///
$items = mysql_num_rows($newData);
if($items > 0)
{
while ($qResult = mysql_fetch_assoc($newData))
{
// Get article data
$aTitle = $qResult["articleTitle"];
$aBody = $qResult["article"];
$aid = $qResult["articleID"];
$author = $qResult["authorID"];
$aCat = $qResult["categoryID"];
$aBlurb = $qResult["articleBlurb"];
$unixTime = $qResult["unixtime"];
$aDate = date("M j, Y", $unixTime);
}
}
else
{
/// SO, I am getting this...
print "Problem retrieving new updated data...";
}
}
$mode = "Edit";
}
--------------------
Thanks
Tom
=====
http://www.pixelmech.com/ :: Web Development Services
http://www.DMXzone.com/ :: Premium Content Author / JavaScript / Every Friday!
http://www.maccaws.com/ :: Group Leader
[Making A Commercial Case for Adopting Web Standards]
"That's not art, that's just annoying." -- Squidward
More information about the thelist
mailing list