Page 2 of 2

Posted: Sun Jun 06, 2004 7:39 pm
by dardsemail
There is a reference to include.php file which contains the following:

Additionally there is a requireOnce which opens the DB connection in the cart.php page.

Code: Select all

function GetCartId() 
{ 
// This function will generate an encrypted string and 
// will set it as a cookie using set_cookie. This will 
// also be used as the cookieId field in the cart table 
if(isset($_COOKIEї"cartId"])) 
{ 
return $_COOKIEї"cartId"]; 
} 
else 
{ 
// There is no cookie set. We will set the cookie 
// and return the value of the users session ID 

session_start(); 
setcookie("cartId", session_id(), time() + ((3600 * 24) * 30)); 
return session_id(); 
} 
} 

?>

Posted: Tue Jun 08, 2004 9:21 am
by dardsemail
Well, I'm still here and still stuck. I'm at a loss. Here's where I'm at:

I've determined that my hosting company is running 4.2.3 and reluctant to upgrade unless absolutely necessary.

I have been unable to successfully upload and test using the .htaccess file (see one of my earlier postings) as it craps out the whole site (clearly I'm doing something wrong!)

I have run the phpinfo() on my machine and that of my hosting company and here are the differences I've seen:

display_errors (mine)ON (hosting)OFF
error_reporting (mine)NO VALUE (hosting) 2047
log_errors (mine)OFF (hosting)ON
magic_quotes_gpc (mine)ON (hosting) OFF
output_buffering (mine)0 (hosting) 4096
register_argc_argv (mine) ON (hosting) OFF
register_globals (mine) OFF (hosting) ON
variables_order (mine) NO VALUE (hosting) GPCS

Those are the only differences I've been able to find in the PHP core configuration. Should I be looking elsewhere? Can someone walk me through creating the .htaccess file as I'm really stuck on that one and that could be my clue.

I really hate to sound so desperate - but, hey, lets be honest - I AM!!!!

Thanks!

Posted: Tue Jun 08, 2004 9:34 am
by leenoble_uk
I would say the .htaccess file crapping out your whole site was almost definately a line endings issue. Apache gets very upset with Mac line endings.
What app did you write the file in? Textedit?

Try this.
Open the Terminal (/Applications/Utilities/Terminal)

When the window has opened and you are presented with a prompt like

Code: Select all

yourusername%
then type:

Code: Select all

pico htaccess
I've left the dot off on purpose because in osx the file would be invisible otherwise.
In the blank screen which appears with (New File) written at the bottom type:

Code: Select all

php_value register_globals 0
and hit return.
Now hit Control-X
It will ask at the bottom of the window if you want to save changes. Type Y
Then it will ask file name to write :htaccess
Just hit return.
You're now back at the prompt, type exit and quit the terminal.
If you look in your home folder you will see your file htaccess.
Upload this to your server and rename it as .htaccess

This file will definately have the correct line endings so at least you can see if you get the same errors or not.
I'd use something other than Dreamweaver to upload though. I don't have MX myself but on occassion when I do use DW4 it always changes my files to Mac line breaks so I have to remember to open it back up in BBEdit and change them back again.

Posted: Tue Jun 08, 2004 9:53 am
by dardsemail
Thanks for the info. I tried it and it didn't seem to work.

I also tried using RBrowserLite as an FTP client and now that I have changed the htaccess to a .htaccess file I can't see it to remove it and I'm still getting the same error message:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Apache/1.3.27 Server at xxx Port 80
Uh - oh. Now I'm really hosed because it seems to be a hidden file and I can't see it to remove it. Any suggestions?

Posted: Tue Jun 08, 2004 9:55 am
by dardsemail
Okay - I'm not entirely hosed as I figured out how to get it off the server. But I'm still unable to use the .htaccess file correctly. Is it possible that my hosting provider doesn't support it?

Posted: Tue Jun 08, 2004 10:03 am
by leenoble_uk
Perhaps.
You could try putting something a little less controversial in the .htaccess file and see if that works.

Try

Code: Select all

DirectoryIndex flibertygibbet.php
And then put two files in there (index.php and flibertygibbet.php) and make sure they will display different content, preferably the name of the file.
This apache directive should override the default page allocation in the relevant directory so you don't have to call it index.html or index.php

If it happily displays the flib file when you try to browse to the location and leave the filename off the end then this is working as it should.
If you get directed to index.php then it didn't work.

Posted: Tue Jun 08, 2004 10:36 am
by dardsemail
Nope - no go. As soon as that .htaccess file gets up on the server all hell breaks loose.

My hosting provider suggested changing the php.ini file on my iMac to register_globals ON and see if the same behaviour took place.

I've been trying to do that using Pico, but it won't let me save the file. I guess I need to log in as SUDO. Ah, I wish my UNIX knowledge wasn't so pathetic.

I'm going to give it a shot and see what happens.

Posted: Tue Jun 08, 2004 11:27 am
by dardsemail
Alright, here's the status. I changed the register_globals on my iMac to ON from OFF and tried my code. Still works fine on my machine.

Should I go ahead and change all the settings to mirror that of my hosting provider to see if I can narrow it down?

Posted: Tue Jun 08, 2004 11:40 am
by Grim...
I don't think it's been stressed enough how much Mac line breaks can stuff up an server.
Basically, although your mac sees 'line break' in the code and starts a new line, your server may not recognise the breaks and stuff all the code on the same line.

I'd also tell your hosts to update their version of PHP as a matter of urgency - 4.2.1 is over two years old!
As already mentioned, you should tell them to go for 4.3.7 (and you should get it on your Mac, too).

Posted: Tue Jun 08, 2004 12:06 pm
by launchcode
Try sticking this at the very top of any script that is failing:

Code: Select all

error_reporting(E_ALL);
Now at least you'll see exactly what the heck is going on when the script does fail. Post your results.

Posted: Tue Jun 08, 2004 12:28 pm
by dardsemail
Okay - it just goes from weird to weirder. When I added the command to the top of the script and ran it through my iMac (where the code - apparently- is working) - I received these errors:
Notice: Undefined index: action in /Library/WebServer/Documents/mysite/cart.php on line 133

Notice: Undefined variable: rs_cart in /Library/WebServer/Documents/mysite/cart.php on line 155
But when I ran it through the server - I didn't receive any errors (but also didn't receive the results of the query. I also checked to make
sure that there was data in the database and, sure enough, there was.

Here's another little discovery - I cleared out my cache and then also cleared all my cookies (with the thought that I would create new cookie and track the behaviour). Oh, I also cleared out the cart table in the database. Start from scratch.

When I did so, I still don't get an error message, but I also only get one line item in the cart. I thought that odd, so I checked the cart table and found that a NEW cookie is being created each time I add an item (this didn't happen before I cleared the cache etc...). I tried the same thing on my iMac and it also happened. I also, in the meantime, reset my php.ini file so that the following settings were changed:

magic_quotes_gpc from ON to OFF
register_argc_argv from OFF to ON
register_globals from OFF to ON

Here is the error codes I get when I try to run the page on my iMac:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /Library/WebServer/Documents/mysite/cart.php:7) in /Library/WebServer/Documents/mysite/include.php on line 6

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /Library/WebServer/Documents/mysite/cart.php:7) in /Library/WebServer/Documents/mysite/include.php on line 6

Warning: Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/mysite/cart.php:7) in /Library/WebServer/Documents/mysite/include.php on line 6

Warning: Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/mysite/cart.php:7) in /Library/WebServer/Documents/mysite/include.php on line 6
All of the code has been listed above in this thread. I'm baffled and perplexed!!!

Posted: Tue Jun 08, 2004 12:30 pm
by dardsemail
Well, here's the latest in my ongoing saga...

Grim - I took your advice and changed the line endings in the code to be LF instead of CR. I then uploaded the pages to the server - still no go. I even cleared the cache to ensure I was working with the latest and greatest.

Then, I changed my php.ini file so that the register_globals and the register_argc_argv matched that of my server at the hosting company. I cannot seem to replicate the problem on my iMac even with these settings changed.

Other than the wonky behaviour which is inconsistent - the code seems to be working fine.

Unless anyone has any suggestions as to other sections of the phpinfo() that might be the culprit, I'm going to push my hosting company to upgrade. Perhaps they have at least one box floating around that they could upgrade that I could at least run my code through to test to see if its a version issue. I just don't know what else to do. I can't launch my site at this point and my client is very disappointed. :cry:

Posted: Mon Jun 14, 2004 11:08 am
by dardsemail
Alright, I'm so stuck its not even funny... Here's the latest. I'm hoping someone can help me.

I worked with my provider and they have moved my site to a new server running PHP 4.3.4.

I imported the database and now I can't even get anything up on the page and nothing is being added to the cart. ARGHHHHH! I am at a total loss. Any suggestions? If someone wants to PM me I will send them the site so that they can see the behaviour to which I'm referring.

Thanks so much! Please, someone, help me out of this pickle!!!