Re: [SMARTY] Real Queer Problem
| From: | Wom.bat | Date: | Wed, 16 Jul 2003 20:09:25 +0000 |
| Subject: | Re: [SMARTY] Real Queer Problem | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9906@lists.php.net to get a copy of this message | ||
1) you are on the very wrong mailing list
2) you should use globals or even better, superglobals
3) maybe you are using $return somewhere in your code? #2 will help you with
that... just $_SESSION["return"] etc...
David
On Wednesday, July 16, 2003 9:18 PM +0200, Thomas Deliduka wrote:
> Okay, I have narrowed it down to this code block:
>
> if (stristr($HTTP_REFEER, "list.php")) {
> $return = $HTTP_REFERER;
> session_register("return");
> } elseif (!$return) {
> $return = $HTTP_REFERER;
> session_register("return");
> }
>
> If I comment this out, the information displays properly. If I leave
> it back in, my problems with DB connections, passing variables, etc
> returns on next reload.
>
> Anyone see a problem with this code?
>
> On 7/16/03 3:11 PM this was written:
>
>> I'm looking to see if there is a "Smarty" PHP Developer who can get
>> on with me via Phone and AIM (so I can post code) to help debug a
>> problem I'm having.
>>
>> Here's the synopsys and what I have been able to figure out so far:
>>
>> I have an extensive shopping cart program (see demo at
>> www.xenocart.com) and there's this STRANGE bug that seems to happen
>> when I directly try to edit an item without first creating a
>> session. I guess that's the easiest way to put it. Although I
>> believe the session does get, oh I don't know. Here is the deal...
>>
>> If you go to my test system:
>>
>> http://webcam.fromtheduke.com:2525/necart/admin/edit.php?itemid=1
>>
>> Directly you will get errors all over the place on this page saying
>> the data doesn't exist. If you don't get errors than I'll be even
>> more confused.
>>
>>> From what I can find out is some queer things happening.
>>
>> First the program runs a 'startup.php' file which includes all the
>> functions and starts the session and assigns some basic variables
>> including a $config array. One of the includes is a dbaccess.php
>> file which defines all my database functions.
>>
>> Then on this page in the edit screen I define an SQL statement and
>> asign it to $sql Then I pass that to my query function
>> db_query($sql);
>>
>> What I found out initially is that once in that function the
>> variable passed was empty. No value. So, I passed by reference
>> db_query(&$sql) and it worked. But then I continue.
>>
>> The connection to the database is made before this earlier in the
>> startup.php file and it's assigned a resource ID. The function pulls
>> that resource ID through the global variables and uses it to perform
>> the query. I always get it's not a valid mysql-link resource error.
>> So, I decided, in debugging, to do a test to see if the query fails
>> and then perform a database connection with db_connect($config) my
>> function. Again, when passing theconfig it was empty so I had to
>> pas via reference. Once in I do an if statement and assign the
>> parameters for database, host, user, password to variables, $db,
>> $dh, $du, $dp respectively. I was still getting errors that the
>> database wouldn't connect at all. I decided to echo the variables
>> to the screen and all four variables were the same thing, the
>> password. It made no sense because I echoed with it the variables
>> out of the $config array and they were correct. They just weren't
>> being assigned correctly. And this, at the heart of it, was what was
>> the problem. Variables were not being assigned properly to values
>> within the functions. It makes no sense to me.
>>
>> Now, you can see why this is so complicated and if I were to post
>> code here it would be a HUGE message that's why I'm looking to see
>> if there is someone with some time who's willing to just talk to me
>> on it.
>>
>> A few notes on this issue:
>> 1. all the errors happen after running the startup.php file which
>> does all the initial connections and there are no errors within that
>> file.
>> 2. This only happens on this page, that I know of. And it happens
>> after I try to register a session variable.
>> 3. If I manually go to the 'list.php' page to view the items in the
>> cart and then choose the item to edit it looks fine.
>> 4. I notice while I'm debugging this, there is no session defined in
>> the database (I am redirecting session information to the database),
>> when I go to 'list.php' a record is created and then going back to
>> edit.php it works fine.
>>
>> That's why I think it's having to do with the session not being
>> created properly but again, why would variables not be assigned from
>> values when you're running clear easy statements like $a = $b; It's
>> so confusing.
>>
>> I can survive without fixing this, the rest of the cart works fine
>> but it's kinda bugging me so I thought I'd ask.
>
> --
>
> Thomas Deliduka
> IT Manager
> -------------------------
> Xenocast
> Street Smart Media Solutions
> http://www.xenocast.com/