PDA

View Full Version : using wamp now get this error with my scripts?


nanny
07-24-2007, 04:01 AM
Hi can somebody explain what this actually means. I am not using register_globals on they are off and the wamp installed php5.
Anyway this is the message at the bottom of the screen:

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

Now if I turn the warning to off that won't help my situation. I am wanting to understand the message so I can fix it if it happens again.

Thanks....

davidj
07-24-2007, 05:49 AM
i have never seen this before but it looks like your script is carrying some code which version 5 doesnt like.

examine your script and look at any session relating code and check that it hasnt been dropped in version 5

nanny
07-24-2007, 08:31 AM
Yeh I am having all sorts of complaints since upgrading to php5 with wamp.
I fixed that one, had to remove sessionid()
but now I have the problem of this:
Warning: mail() [function.mail (http://localhost/salonspa/function.mail)]: SMTP server response: 550 5.7.1 Unable to relay for blah@blah.com in C:\blah\www\salonspa\contact.php on line 52

Warning: Cannot modify header information - headers already sent by (output started at C:\blah\www\salonspa\contact.php:52) in C:\blah\www\salonspa\contact.php on line 56

I had no trouble what so ever before, as well I can't get my sessions to work how they did before.
Everything was just about to go online.....bummer...
any suggestions with the above. I gather and have read that wamp doesn't allow you to send phpmail()
Has anybody had this problem???
Cheers

davidj
07-24-2007, 08:36 AM
yes it does but not from your local machine as you dont have an smtp service running
/////

Warning: Cannot modify header information
This is just a symptom of the first error

nanny
07-24-2007, 08:39 AM
OK so how do I change the settings - do I place it as an empty or as localhost
then me@localhost as some phpini's already have in them?
Cheers

davidj
07-24-2007, 08:49 AM
as long as your host allows the mail() function to work then it will work

there is a mail tut on this site. You dont need to configure any ini file as i am aware? PHP shpuld be setup correctly on your host. all you need to do to test it is the following...

inside the mail function you need to set the vars with content.

your $MailTo var needs to point to your email address. I have sorted your header vars


$headers = 'To: your@address.com'."\r\n";
$headers .= 'From: your@address.com'."\r\n";

mail($MailTo, $Subject, $message, $headers);


just upload it to your host and run it. You should get an email back

nanny
07-24-2007, 09:06 AM
Hi I don't think it is the script that is the problem, I think it is the ini setup:

$MM_flag="option";
if (isset($_POST[$MM_flag])) {
$name = trim($_POST['name']);
if (empty($name)) {
$error['name'] = 'Please give your name';
}
$pat = '([[:digit:]]|[~`!@#$%^&*()_=+{}|\:;"/?,]|[|]|-)+';
if (eregi($pat, trim($_POST['name']))) {
$error['name'] = 'Sorry you must be using the wrong type of character';
}
$email = $_POST['email'];
$_POST['email'] = trim($_POST['email']);
if (empty($_POST['email'])) {
$error['email'] = 'Please enter your email address, if you need one go to hotmail.com';
}
else {
$pattern = '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$';
if (!eregi($pattern, trim($_POST['email']))) {
$error['email'] = 'Please enter a valid email address';
}
}
$option = trim($_POST['option']);
if (empty($option)) {
$error['option'] = 'Please select an option';
}
$messageBody = trim($_POST['message']);
if (empty($messageBody)) {
$error['message'] = 'Please enter your message';
}
else {
if (!empty($messageBody)) {
$type = '/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:|MIME-Version:|Content-Transfer-Encoding:)/i';
if (preg_match($type, trim($_POST['message']))) {
$error['message'] = 'Sorry you can not place that for a message';
}
}
}
$to = 'info@blah.com'; // use your own email address
$subject = 'Feedback Salon Spa Directory';
$message = 'On '.date('l, M j, Y').' at '.date('g:ia').', ';
$message .= "$name ($email) wrote: \n\n";
$message .= $messageBody;
$additionalHeaders = "From: Salon Spa Directory<ed@blah.com>\r\n";
$additionalHeaders .= "Reply-To: $email";
$message = wordwrap($message, 70);
$additionalHeaders = 'From: Salon Spa Directory<info@blah.com>';
if (!empty($email)) {
$additionalHeaders .= "\r\nReply-To: $email";
}
if (!isset($error)) {
mail($to, $subject, $message, $additionalHeaders); {
unset($error);
$URL="thanks.php"; //page to redirect to if the mail is sent successfully
}
header ("Location: $URL");
}

}


See what you think, it worked well until now I have wamp installed.

davidj
07-24-2007, 09:07 AM
test the mail function first then you will know for sure

nanny
07-24-2007, 09:09 AM
I am testing on my local server is this why

davidj
07-24-2007, 09:14 AM
yes

you cant test a mail script locally

nanny
07-24-2007, 09:18 AM
OK so what is the use of testing locally then???
The other problem is the sessions not working as they were previously.
What I do with them is after one form is submitted they are taken to the next page e.g. banner upload (the upload form is only shown if the session has been made from the previous form) after this they are taken to the confirmation page of their details with they select for 1, 3, 6 or 12 months and go straight to the shopping cart where they give their credit details.
Now this doesn't work........
Lots that doesn't work anymore......
The session doesn't seem to set anymore....

davidj
07-24-2007, 09:36 AM
first question...
OK so what is the use of testing locally then???
This is the only aspect of PHP that needs a host environment. Not everyone has an exchange server in their home but if you need on you can buy one.

Why would you do that when your host has it in place already

does that really negate the use of testing php locally?
//////
ok

are you initialising your sessions by calling...

session_start();

at the top of every page you use sessions?
////

did you write these scripts or did you copy and paste them???????

nanny
07-25-2007, 12:01 AM
Hi davidj
I have taught myself php etc. from reading online so yes some things have been copied and pasted but then I have modified a lot to suit me as I found out other persons scripts aren't enough for what I want. So a bit of both you could say.
Now I am re-writing my whole website because it was all html and I had to do the work manually - it's up to about 1000 pages or so - big work.
So this is why I have taught myself all of this.
I haven't done anything on my webserver because I wanted it to be perfect before redirecting everything. Another big job........
I have a form to be filled out on the first page.
Yes I do use session start();
and this is the session I am wanting on the next page this is right under connection:

session_start();
if ($_POST && !empty($_POST['inv_company'])) {
$_SESSION['inv_company'] = $_POST['inv_company'];
}


then in the body:

if (isset($_SESSION['inv_company'])) {
echo 'Hello, '.$_SESSION['inv_company'].'.';
}
else {
echo 'Sorry? <a href="imageform.php">You need to fill out form before you can send your banner</a>';
}


I have placed an echo to see if it is showing but it doesn't

<?php echo $_SESSION['inv_company']; ?>


Driving me crazy .........

nanny
07-25-2007, 12:40 AM
Aahhh I got it working I had to change the forward slash to backward slash for windows for the session path. I changed the session.bug_compat_42 to off - is that a bad thing???
Thanks.....

davidj
07-25-2007, 05:40 AM
dont know anything about it

i would research before switching stuff off

nanny
07-25-2007, 08:37 AM
davidj
I have uploaded the contact script above to my server for testing.
It works so well with the error checking but won't send.
Would it be because of too many headers etc.?
I get a
Internal Server Error


yes a big fat one......
Any suggestions here would be appreciated. I have never done a contact form before.
I did this way because I can understand my error checking methods.

davidj
07-25-2007, 08:48 AM
check out the tutorial on this site regarding PHP mail()

it should point you in the right direction

nanny
07-25-2007, 10:29 PM
Howdy
couldn't find the tutorial so I had a look at my code for a while.
I had a couple of mistakes that I cleaned up:
I changed this -:

$to = 'info@blah.com'; // use your own email address
$subject = 'Feedback Salon Spa Directory';
$message = 'On '.date('l, M j, Y').' at '.date('g:ia').', ';
$message .= "$name ($email) wrote: \n\n";
$message .= $messageBody;
$additionalHeaders = "From: Salon Spa Directory<ed@blah.com>\r\n";
$additionalHeaders .= "Reply-To: $email";
$message = wordwrap($message, 70);
$additionalHeaders = 'From: Salon Spa Directory<info@blah.com>';
if (!empty($email)) {
$additionalHeaders .= "\r\nReply-To: $email";
}
if (!isset($error)) {
mail($to, $subject, $message, $additionalHeaders); {


to this -:

if (!isset($error)) {
$to = 'info@blah.com'; // use your own email address
$subject = 'Feedback Salon Spa Directory';
$message = 'On '.date('l, M j, Y').' at '.date('g:ia').', ';
$message .= "$name ($email) wrote: \n\n";
$message .= "$messageBody ($messageBody) Message: \n\n";
$message .= "$option ($option) Reason: \n\n";
$additionalHeaders = "From: Salon Spa Directory<ed@blah.com>\r\n";
$additionalHeaders .= "Reply-To: $email";
$message = wordwrap($message, 70);
$additionalHeaders = 'From: Salon Spa Directory<info@blah.com>';
if (!empty($email)) {
$additionalHeaders .= "\r\nReply-To: $email";
}
mail($to, $subject, $message, $additionalHeaders); {
}
}


Now i get the message sent to my inbox.
First step on the server.........

davidj
07-25-2007, 10:34 PM
so you cracked it?

nanny
07-26-2007, 12:38 AM
Yep I surely did...
But can I still go through the keywords problem with you, I have been searching the web and a lot talk of mysql fulltext but I would like to try the method you suggested, I understand the split and replace a little.......

Cheers.....

nanny
07-26-2007, 12:41 AM
Actually if you wouldn't mind testing it out for me.... there is only the two pages there at the moment till I get the rest working properly.
The address is http://salonspa.hairbeautyjobs.com.au/contact.php

Thanks

davidj
07-26-2007, 05:34 AM
nice little animation on the thankyou page

nanny
07-26-2007, 06:36 AM
Thanks for testing out I received it all intact.