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 10 of 10
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    114
    Thanks
    4
    Thanked 3 Times in 3 Posts

    PHP not cross browser?!

    Difficulties have arisen! I know that PHP is a server side language, yet I am having some problems running a simple code on firefox. I have tested it on Opera and IE and it works fine, just Firefox seems to be resistant to my efforts.

    Can someone with firefox try it out? It's a VERY crude code, I'm just playing around right now. http://www.cybercyclers.com/member/create.html.

    P.S. I know that there are ways to fix things such as only a one word title, but right now I'm feeling lazy. Thanks in advance, let me know how it turns out.

  • #2
    Regular Coder
    Join Date
    Mar 2005
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts
    im getting this error, both firefox and IE

    Code:
    Warning: flock(): supplied argument is not a valid stream resource in /home/www/cybercyclers.com/member/makeit.php on line 8
    
    Warning: fputs(): supplied argument is not a valid stream resource in /home/www/cybercyclers.com/member/makeit.php on line 10
    
    Warning: flock(): supplied argument is not a valid stream resource in /home/www/cybercyclers.com/member/makeit.php on line 12
    
    Warning: fclose(): supplied argument is not a valid stream resource in /home/www/cybercyclers.com/member/makeit.php on line 14
    It should be done

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    114
    Thanks
    4
    Thanked 3 Times in 3 Posts
    hmm, now it doesnt seem to work with any browser. What the code is is a very crude way to post your own content onto a site. The first page (create.html) gathers the information from the two input areas (title and content) and sends them to makeit.php. From there, makeit.php makes a file with the name of the title variable and fills it with the content variable. From file.html you can add ?topic=title to retrieve files.

    Here's my code, any help?

    create.html:
    Code:
    ...
    
    <form action="makeit.php" method="POST">
    Title (ONE WORD ONLY): <input type="text" name="$title" />
    <br />
    Stuff goes here:<br /> <textarea name="$content" rows="10" cols="65" wrap="wrap">Boogeldash!</textarea>
    <br />
    <input type="submit">
    
    ...
    makeit.php
    PHP Code:
    <?php

    $fp 
    fopen($title'w');

    $string $content

    flock($fpLOCK_EX);

    fputs($fp$string); 

    flock($fpLOCK_UN); 


    echo 
    "It should be done";
    ?>
    file.html
    Code:
    <?php 
    $topic = $_GET['topic']; 
    ?>
    
    ...
    
    <p>Today we will learn about <?php echo $topic ?>
    <table>
    <tr>
    <td>
    <?php require($topic); ?>
    
    ...

  • #4
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    PHP very little to do with the browser. It normally just outputs HTML code or something.
    var_dump($fp); to see if it's a resource. You probably can't open the file.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #5
    Regular Coder
    Join Date
    Sep 2004
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Change the Chmod of your folder to 766 and if that does not work try 777

    Also you can make the one word topic multiword by taking out the white spaces

    something like
    Code:
    $topic = ereg_replace("[ \t\n\r]","",$topic);
    Last edited by shinko_metsuo; 07-06-2005 at 02:42 AM.

  • #6
    Regular Coder
    Join Date
    Mar 2005
    Posts
    114
    Thanks
    4
    Thanked 3 Times in 3 Posts
    I was planning on changing it to %20 so that when printed a space is what people see.

    However, I am moving my files that it creates into a seperate folder for organization. Inside my code, how do I splice together a string and a variable to create a string? Is it like...
    Code:
    "folder/" . $string
    Last edited by JoWiGo; 07-06-2005 at 02:53 AM.

  • #7
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,855
    Thanks
    22
    Thanked 157 Times in 148 Posts
    Quote Originally Posted by JoWiGo
    Inside my code, how do I splice together a string and a variable to create a string? Is it like...
    Code:
    "folder/" . $string

    sure, that would work, but you might want to include a full address (including domain name) because servers can be touchy about that...
    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 !!… ♪♪

  • #8
    Regular Coder
    Join Date
    Mar 2005
    Posts
    114
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Okay, I have been working on this code for hours (can you tell i'm new?) and cannot make it work. Can someone give me a tutorial of how to do this (upload files and view them through a url using the "?") or modify my code to do so? I'm tired and need to sleep... please assist me...

  • #9
    Regular Coder
    Join Date
    Mar 2005
    Posts
    114
    Thanks
    4
    Thanked 3 Times in 3 Posts
    bumping

  • #10
    Regular Coder
    Join Date
    Apr 2004
    Posts
    298
    Thanks
    0
    Thanked 23 Times in 23 Posts
    Being old and a bit of a novice, I could be offbase here, but a couple of things seem amiss.

    1. your form states the method is POST yet you use GET to gather some of the variable info.

    2. you reference variables without accessing via either GET or POST

    3. you attempt to access the $title variable using title

    Perhaps the full code may be appropriate at this point.

    Sorry if I am offbase.

    Lite...


  •  

    Posting Permissions

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