1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

creating a file with php - getting an error

Discussion in 'Web Design & Development' started by knight_47, Feb 5, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. knight_47

    knight_47 Thread Starter

    Joined:
    Mar 14, 2006
    Messages:
    941
    I have no idea why this is giving the die() error, everything seems to be fine, can anyone spot any errors:

    PHP:
    <?php

    $name 
    htmlspecialchars($_POST['name']);
    $msg htmlspecialchars($_POST['msg']);
    $clean_name stripslashes($name);
    $clean_msg stripslashes($msg);
    $cleaner_name rtrim($clean_name);


    $card '<HTML CODE IS HERE>';

    $link "$cleaner_name".htm";

    if (
    $_POST['Submit'] && !empty($cleaner_name) && !file_exists($link))
    {
      
    $create fopen($file'w') or die("Hm... There seems to be an error!");
        
    fwrite($create$card);
        
    fclose($create);
        echo 
    '<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.knight47.com/cards/' $link  '">';
    }
    else 
    {
    echo 
    "Sorry, there seems to be a few problems, either 1, you left the Name field empty, if so, click back in your browser button, or that $cleaner_name has already been submitted, please visit <a href=\"http://www.knight47.com/cards/" $file ">www.knight47.com/cards/" $file "</a> to view the already existing card, thanks!";
    }
    ?>
    I keep getting this: "Hm... There seems to be an error!", which is supposed to be the error message if something goes wrong, but I have no idea what is wrong.

    The folder is chmod to 777, and the php file is chmod to 755.

    Thanks
     
  2. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    It looks like $file is empty.
     
  3. knight_47

    knight_47 Thread Starter

    Joined:
    Mar 14, 2006
    Messages:
    941
    :eek: oops...

    Thanks B, I can't believe I missed that, thank you sir.
     
  4. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    [tsg=yourewelcome]yourewelcome[/tsg]
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/541611

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice