|
Posted by John Moore on 10/31/05 16:43
On 31 Oct 2005 05:46:12 -0800, in comp.lang.php "Ian B"
<ianbambury@gmail.com> wrote:
>Try something along the lines of
>
>$result = mysql_query($sql) or die("<br />Could not run query $sql
>Reason: " . mysql_error());
>
>to find out what it's complaining about.
>
Thanks Ian,
I just tried your suggestion, calling the query like this:
$result = mysql_query($query) or die("<br>Could not run query $sql
Reason: " . mysql_error());
But the script didn't die, the function continued to execute, and no
update took place.
>($result = mysql_query($query)) will always return true even if the
>query fails.
>
>Ian
I tested the result like this:
if ($result) {
// keep doing stuff
}
else {
return false;
}
Here is the current version of this function:
function new_category2($category_id=null) {
global $category_id_new;
if (create_category($_SESSION['cat_name'])) {
// update this page with the new category_id
$query = "UPDATE about SET category_id = $category_id_new WHERE
about_id = {$_SESSION['about_id']}";
$result = mysql_query($query) or die("<br>Could not run query $sql
Reason: " . mysql_error());
if ($result) {
// both new and old categories must be updated to reflect new
totals
if (update_cat_total('add', $category_id_new) &&
update_cat_total('remove', $category_id)) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
else {
return false;
}
}
I'm going to try this under a different operating system. I'm just not
understanding why the update wouldn't occur here. This is PHP 4.4.3
running mysql 4.0.16-nt on Apache 1.3.24.
What kills me is that the update_cat_total() function updates a
different table using the exact same syntax for the query- and updates
the field every time.
Thanks again,
J Moore
Navigation:
[Reply to this message]
|