You are here: Re: My function returns true but my code does not execute « PHP Programming Language « IT news, forums, messages
Re: My function returns true but my code does not execute

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация