|
Posted by J.O. Aho on 01/11/07 12:19
Kim André Akerø wrote:
> Dave Nash wrote:
>
>> On Thu, 11 Jan 2007 12:57:00 +0100, Ruben van Engelenburg
>> <nospam@nospam.com> wrote:
>>
>>> Dave Nash wrote:
>>>
>>>> $query = "select * from categories WHERE parentid = $catid";
>>>> $result = mysql_query($query) or die ("Couldn't execute query: " .
>>>> mysql_error());
>>>> echo "$query";
>>>>
>>>> Table is categories
>>>>
>>>> CATID
>>>> PARENTID
>>>>
>>>> Im trying to show all categories where the PARENTID value is the
>> same >> as the CATID value.
>>> It could be that the variable $catid is empty, causing the query to
>>> be invalid.
>>> I'm not sure where $catid is being set in your script because you
>>> didn't post that part, hence my question to echo the $query var.
>>>
>>> Ruben.
>> CATID is being passed via a url
>>
>> list_subs.php?catid=53
>>
>> So catid should always be there.
>
> Sure, if register_globals is set to "on" on both the local and live
> servers. Rather, get used to using $_GET["catid"] instead of $catid.
As most web-hotels are turning off register_globals (which is the default
nowadays in PHP), it's better to go with that $_GET than the other way around,
but of course if downloading examples from the net, there is the problem with
those codes that they used to be written for php3 or early php4 and there
seems to be many who don't know this, which leads to threads like this one.
It's sad that the authors of those examples don't update the code and see to
that those who host them gets the new code.
--
//Aho
[Back to original message]
|