Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-13-2006, 12:00 AM   PM User | #1
mkphoto44
New Coder

 
Join Date: Feb 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
mkphoto44 is an unknown quantity at this point
trouble with a php process

I have set up a form and when I click on submit I get the following error message:

Warning: fopen(admin/data.dat): failed to open stream: No such file or directory in /home/mlkphoto/public_html/process.php on line 33

Warning: fwrite(): supplied argument is not a valid stream resource in /home/mlkphoto/public_html/process.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /home/mlkphoto/public_html/process.php:33) in /home/mlkphoto/public_html/process.php on line 39

What does this mean and how do I fix it? I do get the form information sent to my email so I know it's going through. I just can't get a "Thank you" page to come up and I get the error messages. Thanks in advance
mkphoto44 is offline   Reply With Quote
Old 02-13-2006, 12:29 AM   PM User | #2
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,548
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Show us some code that would help a bit....

Quote:
Warning: fopen(admin/data.dat): failed to open stream: No such file or directory in /home/mlkphoto/public_html/process.php on line 33
for that error, probably the path to your file is incorrect...try using the full absolute path, whatever that is on your server...for example:

Quote:
/home/httpd/vhosts/yourdomain.com/httpdocs/admin/data.dat
Or try using the full URL, for example:

__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
[Related videos and tutorials are also available at my YouTube channel]
chump2877 is offline   Reply With Quote
Old 02-13-2006, 12:31 AM   PM User | #3
mkphoto44
New Coder

 
Join Date: Feb 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
mkphoto44 is an unknown quantity at this point
Here is the code that I am working with:

<form enctype='multipart/form-data' action='process.php' method='post'>
<div align="center">
<table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#000066" width="51%" cellpadding="5">
<tr> </tr>
<tr>
<td colspan="3" bgcolor="#B5CBEF" height="16" width="100%" bordercolor="#FFFFFF" background="tile_sub.gif"><font size="2" face="Verdana"><b><font face="Verdana" size="2" color="#000066">
<!- You can add a brief form description here-->
&nbsp; </font></b></font></td>
</tr>
<tr>
<td height="30" width="189" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana" size="2">First
Name</font></td>
<td height="30" width="469" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana">
<input type=text name='FirstName'>
</font></td>
</tr>
<tr>

<td height="30" width="189" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana" size="2">Last
Name</font></td>
<td height="30" width="469" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana">
<input type=text name='LastName'>
</font></td>
</tr>
<tr>

<td height="30" width="189" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana" size="2">Wedding
Date</font></td>
<td height="30" width="469" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana">
<input type=text name='WeddingDate'>
</font></td>
</tr>
<tr>

<td height="30" width="189" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana" size="2">City</font></td>
<td height="30" width="469" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana">
<input type=text name='City'>
</font></td>
</tr>
<tr>

<td height="30" width="189" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana" size="2">State</font></td>
<td height="30" width="469" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana">
<input type=text name='State'>
</font></td>
</tr>
<tr>

<td height="30" width="189" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana" size="2">Zip
Code</font></td>
<td height="30" width="469" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana">
<input type=text name='ZipCode'>
</font></td>
</tr>
<tr>

<td height="30" width="189" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana" size="2">Daytime
Phone</font></td>
<td height="30" width="469" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana">
<input type=text name='DaytimePhone'>
</font></td>
</tr>
<tr>

<td height="30" width="189" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana" size="2">Evening
Phone</font></td>
<td height="30" width="469" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana">
<input type=text name='EveningPhone'>
</font></td>
</tr>
<tr>

<td height="30" width="189" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana" size="2">EMail
Address</font></td>
<td height="30" width="469" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> <font face="Verdana">
<input type=text name='EMailAddress'>
</font></td>
</tr>
<tr>
<td colspan="3" bgcolor="#B5CBEF" height="25" width="737" background="tile_sub.gif"><p align="center"><font face="Verdana" size="2">
<input name="submit" type=submit value='Submit Form'>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input name="reset" type=reset value='Reset Form'>
</font></td>
</tr>
</table>
</div>
</form>

Thank you for any help you can give.
mkphoto44 is offline   Reply With Quote
Old 02-13-2006, 12:32 AM   PM User | #4
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,548
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
PHP Code:
please use PHP tags to enclose your code 

By the way, lol, thats the HTML file, show us the offending code from your PHP file (that processes the form)....the error messages are telling you what lines the errors are ocurring on...any script editor will let you view line numbers, so then you can isolate the code for us
__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
[Related videos and tutorials are also available at my YouTube channel]

Last edited by chump2877; 02-13-2006 at 12:35 AM..
chump2877 is offline   Reply With Quote
Old 02-13-2006, 12:35 AM   PM User | #5
mkphoto44
New Coder

 
Join Date: Feb 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
mkphoto44 is an unknown quantity at this point
Sorry - here is the right code:

<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','FirstName');
pt_register('POST','LastName');
pt_register('POST','WeddingDate');
pt_register('POST','City');
pt_register('POST','State');
pt_register('POST','ZipCode');
pt_register('POST','DaytimePhone');
pt_register('POST','EveningPhone');
pt_register('POST','EMailAddress');
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EMailAddress)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="First Name: ".$FirstName."
Last Name: ".$LastName."
Wedding Date: ".$WeddingDate."
City: ".$City."
State: ".$State."
Zip Code: ".$ZipCode."
Daytime Phone: ".$DaytimePhone."
Evening Phone: ".$EveningPhone."
EMail Address: ".$EMailAddress."
";
$message = stripslashes($message);
mail("mkphoto44@comcast.net","Form Submitted at your website",$message,"From: phpFormGenerator");
$make=fopen("admin/data.dat","a");
$to_put="";
$to_put .= $FirstName."|".$LastName."|".$WeddingDate."|".$City."|".$State."|".$ZipCode."|".$DaytimePhone."|".$E veningPhone."|".$EMailAddress."
";
fwrite($make,$to_put);

header("Refresh: 0;url=http://photosbymlkeen.com/ThankYou.html");
?><?php
}
?>
mkphoto44 is offline   Reply With Quote
Old 02-13-2006, 12:42 AM   PM User | #6
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,548
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
PHP Code:
<?php

ob_start
();

include(
"global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','FirstName');
pt_register('POST','LastName');
pt_register('POST','WeddingDate');
pt_register('POST','City');
pt_register('POST','State');
pt_register('POST','ZipCode');
pt_register('POST','DaytimePhone');
pt_register('POST','EveningPhone');
pt_register('POST','EMailAddress');
if(!
eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EMailAddress)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if(
$errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="First Name: ".$FirstName."
Last Name: "
.$LastName."
Wedding Date: "
.$WeddingDate."
City: "
.$City."
State: "
.$State."
Zip Code: "
.$ZipCode."
Daytime Phone: "
.$DaytimePhone."
Evening Phone: "
.$EveningPhone."
EMail Address: "
.$EMailAddress."
"
;
$message stripslashes($message);
mail("mkphoto44@comcast.net","Form Submitted at your website",$message,"From: phpFormGenerator");
$make=fopen("admin/data.dat","a");
$to_put="";
$to_put .= $FirstName."|".$LastName."|".$WeddingDate."|".$City."|".$State."|".$ZipCode."|".$DaytimePhone."|".$E veningPhone."|".$EMailAddress."
"
;
fwrite($make,$to_put);

fclose($make);

ob_end_flush();

header("Refresh: 0;url=http://photosbymlkeen.com/ThankYou.html");
?><?php
}
?>
that will probably fix your header problem...i already told you what to do with the "opening the file" issue...
__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
[Related videos and tutorials are also available at my YouTube channel]
chump2877 is offline   Reply With Quote
Old 02-13-2006, 01:10 AM   PM User | #7
mkphoto44
New Coder

 
Join Date: Feb 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
mkphoto44 is an unknown quantity at this point
Thank you for your help. There is still a little gliche but for the most part it's doing what it should. It just seems that an error message flash very quickly on the screen but then goes to the Thank you page.
mkphoto44 is offline   Reply With Quote
Old 02-13-2006, 01:24 AM   PM User | #8
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,548
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
that's probably some of your own built in error checking....an echo or print statement somewhere that is showing up when you flush the output buffer with ob_end_flush()....so there is probably something else still wrong with your script....can you see/read the error?

I always put my error messages inside die() so that the script stops execution when my built in error checking picks up on something,,,maybe replace your echo statements with die() somewhere....then the script will stop so you can fix the small problem that is left....
__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
[Related videos and tutorials are also available at my YouTube channel]
chump2877 is offline   Reply With Quote
Old 02-13-2006, 01:30 AM   PM User | #9
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,548
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
change

PHP Code:
if($errors==1) echo $error
to


PHP Code:
if($errors==1) die($error); 
__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
[Related videos and tutorials are also available at my YouTube channel]
chump2877 is offline   Reply With Quote
Old 02-13-2006, 02:09 AM   PM User | #10
mkphoto44
New Coder

 
Join Date: Feb 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
mkphoto44 is an unknown quantity at this point
When I put the code:
if($errors==1) die($error);

I get the error:
Parse error: syntax error, unexpected T_VARIABLE in /home/mlkphoto/public_html/process.php on line 21

You asked if I could read the error before. It flashes on the screen and the goes away to fast to read. Is there a way to see what's going on? Thanks again for your help
mkphoto44 is offline   Reply With Quote
Old 02-13-2006, 02:18 AM   PM User | #11
mkphoto44
New Coder

 
Join Date: Feb 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
mkphoto44 is an unknown quantity at this point
I left out the () around ($error) so that's why I was getting the last error message. I am still getting what looks like 2 error messages flash very quickly across the screen before it goes to the Thank you page. Any additional help would be appreciated.
mkphoto44 is offline   Reply With Quote
Old 02-13-2006, 12:35 PM   PM User | #12
mkphoto44
New Coder

 
Join Date: Feb 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
mkphoto44 is an unknown quantity at this point
I was able to see the error message and it is as follows:

Warning: fopen(admin/data.dat): failed to open stream: No such file or directory in /home/mlkphoto/public_html/process.php on line 36

Warning: fwrite(): supplied argument is not a valid stream resource in /home/mlkphoto/public_html/process.php on line 40

Line 36 is:
$make=fopen("admin/data.dat","a");

I'm not sure what the admin/data.dat is representing. I looked in all the files on the server and couldn't find it.

Line 40 is:
fwrite($make,$to_put);

Any help would be appreciated. Thanks
mkphoto44 is offline   Reply With Quote
Old 02-13-2006, 03:16 PM   PM User | #13
Zegg90
New Coder

 
Join Date: Jan 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Zegg90 is an unknown quantity at this point
Quote:
I'm not sure what the admin/data.dat is representing. I looked in all the files on the server and couldn't find it.
And there's your problem. The script is trying to open data.dat, but the file doesn't exist. Did you writethe script yourself? If you aren't using data.dat for anything, then I suppose you can just delete those lines.
Zegg90 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:13 AM.


Advertisement
Log in to turn off these ads.