beyonder's PHP thread o' FUN

You can post anything you want in here! Woohoo!

Moderators: beyonder, Pez-Man

User avatar
Twilkitri
Pez-Ruler
Pez-Ruler
Posts: 1484
Joined: Sun May 19, 2002 10:20 pm
Location: Australia

beyonder's PHP thread o' FUN

Post by Twilkitri »

We all know he was going to make this eventually, so I've made it for him since he was taking so long.

beyonder, how would I use PHP to let people book through the FE4SRP/ProjectTables page rather than having to email me?
User avatar
beyonder
Webmaster
Webmaster
Posts: 672
Joined: Mon May 20, 2002 7:53 pm
Location: my house.
Contact:

Post by beyonder »

<?php
if (isset($submit)){
//code to do on submit goes here!(nifty, eh?)
}
else{
echo '
<form method="post" action="thisverysamefile.php">
make a form, put it here.....
<input type="submit" name="submit" value="submit"></input>
</form>
';
}
?>

when the user clicks the submit button, the script gets called again, but since $submit is now set, executes the other section....which will be used to store the data they entered. when making the form, remember that the name of each field and it's value will be passed to the script when the person hits the submit button...this means that if you use name="hello" for a field, that will be accessable through use of $name in the script. there would then be two ways to store the data, one being files on the server, the other being the mySQL database on the server(for this method you need to ask me for a db account for your script to use)

http://www.php.net/manual/en/ref.filesystem.php <-- php filesystem functions

http://www.php.net/manual/en/ref.mysql.php <-- php mySQL functions
Image
User avatar
Twilkitri
Pez-Ruler
Pez-Ruler
Posts: 1484
Joined: Sun May 19, 2002 10:20 pm
Location: Australia

Post by Twilkitri »

OK now, I haven't really looked at that yet, this is a different topic.

You know how old browsers can't handle PNG outside of a page, and send it to MPE or some such program, right? Anyways, I didn't really want to make a tiny page for every PNG sheet that got put up, so I tried making a single dynamic page in php. But it won't work ><
Can you see any errors in this?

Code: Select all

<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php
    header("Content-type: image/png");
    $string = $_GET['pic'];
    $add    = "SHEETS/";
    $add   .= $string;
    $im     = imagecreatefrompng($add);
    imagepng($im);
    //imagedestroy($im);
 ?>

 </body>
</html>
And here are the errors:

Code: Select all

Warning: Cannot add header information - headers already sent by (output started at c:\inetpub\wwwroot\darktwilkitri\FE4\PNGVIEW.PHP:6) in c:\inetpub\wwwroot\darktwilkitri\FE4\PNGVIEW.PHP on line 7

Fatal error: Call to undefined function: imagecreatefrompng() in c:\inetpub\wwwroot\darktwilkitri\FE4\PNGVIEW.PHP on line 1
Goes better on the net than in the cli... it just sits there if I try to run it in the cli...
User avatar
beyonder
Webmaster
Webmaster
Posts: 672
Joined: Mon May 20, 2002 7:53 pm
Location: my house.
Contact:

Post by beyonder »

if this script worked, it wold end up with some weird output.....the code for an image embedded into a html file if i'm thinking right......why can't you just echo an img tag to embed the picture into a very simple page

replace
$im = imagecreatefrompng($add);
imagepng($im);
//imagedestroy($im);

with
echo "<img src=\"" . $add . "\">";

adding attributes to the img tag as you wish.....and take out the header("Content-type: image/png"); line....this function can only be used if it is the absolute first thing in a file....no html before it, and if left in will make the browser think that what it's looking at is supposed to be *entirely* a png and kill itself.

and besides that, the php PNG functions are quite buggy(and for some reason the server seems to think that they don't exist....)
Image
User avatar
Twilkitri
Pez-Ruler
Pez-Ruler
Posts: 1484
Joined: Sun May 19, 2002 10:20 pm
Location: Australia

Post by Twilkitri »

It's been too long since beyonder had any FUN in his PHP thread o' it!

Rightio.
http://www.thegreatbeyond.net/DarkTwilkitri/sts2.php
There you can see the brains... er, error which is similar to what I was talking to you about in chat the other day. Although I didn't get those messages because I don't have notices turned on, so it may be a different error just with the same effect.

Any ideas?
I'll just pust the code here too...

Code: Select all

<?php
    $count = file_get_contents("STScount.txt");
    $count++;
    $countfile = fopen("STScount.txt", "wb");
    fwrite($countfile, $count);
    fclose($countfile);
print "This page has been viewed $count times since November 5, 2003.";
?>
User avatar
beyonder
Webmaster
Webmaster
Posts: 672
Joined: Mon May 20, 2002 7:53 pm
Location: my house.
Contact:

Post by beyonder »

Well, since giving the user 'nobody' write access to everything on a server does not make much sense, if you upload a file, the ftp writes the file using the user 'thegreat', now this user can write to the file but 'nobody' cannot. 'nobody' is the user that the Apache process, and therefore the PHP parser runs on. There's really two solutions to this. They both involve chmod 777'ing *something*, in one case it's a directory in another it's a file. You have access to chmod files through the ftp. THe directory method would be to make a directory, chmod it and have the script create the file in it. The file method should be pretty obvious.
Image
User avatar
beyonder
Webmaster
Webmaster
Posts: 672
Joined: Mon May 20, 2002 7:53 pm
Location: my house.
Contact:

Post by beyonder »

Or, if you're feeling like the spawn of satan, a chmod 666 should also do the trick. ^.~
Image
User avatar
Twilkitri
Pez-Ruler
Pez-Ruler
Posts: 1484
Joined: Sun May 19, 2002 10:20 pm
Location: Australia

Post by Twilkitri »

Hooray!
Took me a while to figure out how to get ftp to tell your ftp to chmod, though. What sort of a name for a remote command command is 'quote' ?!?
User avatar
beyonder
Webmaster
Webmaster
Posts: 672
Joined: Mon May 20, 2002 7:53 pm
Location: my house.
Contact:

Post by beyonder »

'quote' isn't a remote command. it's a local command. it tells your ftp client to send the command exactly as you type it.
Image
User avatar
Twilkitri
Pez-Ruler
Pez-Ruler
Posts: 1484
Joined: Sun May 19, 2002 10:20 pm
Location: Australia

Post by Twilkitri »

That's what I said...
User avatar
beyonder
Webmaster
Webmaster
Posts: 672
Joined: Mon May 20, 2002 7:53 pm
Location: my house.
Contact:

Post by beyonder »

no it's not...
Image
User avatar
Twilkitri
Pez-Ruler
Pez-Ruler
Posts: 1484
Joined: Sun May 19, 2002 10:20 pm
Location: Australia

Post by Twilkitri »

DarkTwilkitri wrote:Hooray!
Took me a while to figure out how to get ftp to tell your ftp to chmod, though. What sort of a name for a remote command command is 'quote' ?!?
Ergo, a command which runs remote commands.
User avatar
chromus
Pez-Ruler
Pez-Ruler
Posts: 1704
Joined: Tue Aug 13, 2002 9:24 pm
Contact:

Post by chromus »

As opposed to asking for help with PHP, I want to see how people like the PHP version of some of my scripts. Check them out:

http://chromus.thegreatbeyond.net/dunge ... s_scripts/

I've even included source code!
User avatar
beyonder
Webmaster
Webmaster
Posts: 672
Joined: Mon May 20, 2002 7:53 pm
Location: my house.
Contact:

Post by beyonder »

o_o; your special html characters in the source are missing semicolons...so in mozilla they just show up as &lt, should be <
Image
User avatar
chromus
Pez-Ruler
Pez-Ruler
Posts: 1704
Joined: Tue Aug 13, 2002 9:24 pm
Contact:

Post by chromus »

Whoops. All fixed now, I hope. If anyone finds any more problems, let me know and I'll fix them.
Post Reply