Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,826
    Thanks
    19
    Thanked 157 Times in 148 Posts
    Show us some code that would help a bit....

    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:

    /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 and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #3
    New Coder
    Join Date
    Feb 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,826
    Thanks
    19
    Thanked 157 Times in 148 Posts
    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
    Last edited by chump2877; 02-13-2006 at 12:35 AM.
    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 and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #5
    New Coder
    Join Date
    Feb 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    }
    ?>

  • #6
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,826
    Thanks
    19
    Thanked 157 Times in 148 Posts
    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 and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #7
    New Coder
    Join Date
    Feb 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,826
    Thanks
    19
    Thanked 157 Times in 148 Posts
    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 and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #9
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,826
    Thanks
    19
    Thanked 157 Times in 148 Posts
    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 and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #10
    New Coder
    Join Date
    Feb 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #11
    New Coder
    Join Date
    Feb 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #12
    New Coder
    Join Date
    Feb 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #13
    New Coder
    Join Date
    Jan 2006
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •