Real Queer Problem

From: Date: Wed, 16 Jul 2003 19:11:00 +0000
Subject: Real Queer Problem
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-9904@lists.php.net to get a copy of this message
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/

« previous php.smarty.general (#9904) next »