...

View Full Version : PHP not cross browser?!



JoWiGo
07-06-2005, 01:19 AM
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.

trancedm
07-06-2005, 01:25 AM
im getting this error, both firefox and IE



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

JoWiGo
07-06-2005, 01:31 AM
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:



...

<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

$fp = fopen($title, 'w');

$string = $content;

flock($fp, LOCK_EX);

fputs($fp, $string);

flock($fp, LOCK_UN);


echo "It should be done";
?>

file.html

<?php
$topic = $_GET['topic'];
?>

...

<p>Today we will learn about <?php echo $topic ?>
<table>
<tr>
<td>
<?php require($topic); ?>

...

marek_mar
07-06-2005, 01:36 AM
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.

shinko_metsuo
07-06-2005, 01:36 AM
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

$topic = ereg_replace("[ \t\n\r]","",$topic);

JoWiGo
07-06-2005, 01:48 AM
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...

"folder/" . $string

chump2877
07-06-2005, 02:21 AM
Inside my code, how do I splice together a string and a variable to create a string? Is it like...

"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...

JoWiGo
07-06-2005, 02:38 AM
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...

JoWiGo
07-06-2005, 11:21 AM
bumping

litebearer
07-06-2005, 12:01 PM
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...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum