Search found 16 matches

by emperor
Wed Nov 24, 2004 9:44 am
Forum: General Discussion
Topic: Travelling at the speed of light....
Replies: 7
Views: 1193

I mean theoretically, if it were possible to observe a car zooming past you at the speed of light, then it switched its headlights on, surely you wouldn't see a difference even though the driver does? I'm no scientist and got what little I know from what little I read of The Elegant Universe, but in...
by emperor
Tue Nov 23, 2004 11:23 am
Forum: General Discussion
Topic: Travelling at the speed of light....
Replies: 7
Views: 1193

Come on now folks, the speed of light is weird in that it is constant to all observers, so the headlights would work normally from your point of view. To a stationary observer however the car and the headlights would be going at the same speed, whatever that would look like... probably just a car wi...
by emperor
Fri Nov 19, 2004 5:54 am
Forum: PHP - Code
Topic: Resizing JPG / JPEG
Replies: 4
Views: 702

GD can be slightly complicated to get used to, but the most common way to resize JPEGs using it is like this <?php $src = ImageCreateFromJPEG ($src_filename); $width = ImageSx ($src); $height = ImageSy ($src); $x = $new_width; $y = $new_height; $dst = ImageCreateTrueColor ($x, $y); ImageCopyResample...
by emperor
Thu Nov 18, 2004 3:51 pm
Forum: PHP - Code
Topic: [Solved]Array comparison
Replies: 9
Views: 1055

Ah good, glad to see it was what you were after. Just a quickie, there's a function to retrieve a random array value, so instead of this <?php shuffle($categories[$cat]); echo current($categories[$cat]); ?> You could try this <?php echo $categories[$cat][array_rand($categories[$cat])]; ?>
by emperor
Thu Nov 18, 2004 9:00 am
Forum: PHP - Code
Topic: Forms: Submit to two at once?
Replies: 2
Views: 342

You can post info to external sites manually with PHP using [php_man]fsockopen[/php_man]. There may be an easier way but this is how I do it: <?php $url = fsockopen ('http://www.blah.com', 80); $data = 'variable=value&variable2=something'; $length = strlen ($data); $post = "POST /path/to/sc...
by emperor
Thu Nov 18, 2004 8:18 am
Forum: PHP - Code
Topic: [Solved]Array comparison
Replies: 9
Views: 1055

I have to admit I'm still not too sure what you're after, but it looks like you could use a bit of [php_man]array_intersect[/php_man], see if this is what you want: <?php if ($cat = current (array_intersect (array_keys ($categories), $query_string_array))) print_r ($categories[$cat]); ?> (PS in case...
by emperor
Mon Nov 15, 2004 3:25 pm
Forum: PHP - Code
Topic: Convert db encoding
Replies: 4
Views: 708

Check which version of MySQL you have - the manual sez: "The USING form of CONVERT() is available as of 4.1.0"
by emperor
Fri Nov 12, 2004 8:11 am
Forum: PHP - Code
Topic: Removing \n and tabs?
Replies: 4
Views: 379

Alternatively it may be quicker to use an array with [php_man]str_replace[/php_man] like this:

Code: Select all

<?php
    $chars = array (' ', "\t", "\r", "\n");
    $text = str_replace ($chars, '', $text);
?>
by emperor
Mon Nov 08, 2004 1:26 pm
Forum: PHP - Code
Topic: reading a random quote
Replies: 13
Views: 956

Check out [php_man]array_rand[/php_man] which picks out the required number of random entries from an array
by emperor
Mon Nov 08, 2004 12:57 pm
Forum: PHP - Code
Topic: JPEG Image Upload
Replies: 5
Views: 536

To create a thumbnail from the uploaded JPEG try this: <?php $src = ImageCreateFromJPEG ($src_filename); $width = ImageSx ($src); $height = ImageSy ($src); $x = $desired_width; $y = $desired_height; $dst = ImageCreateTrueColor ($x, $y); ImageCopyResampled ($dst, $src, 0, 0, 0, 0, $x, $y, $width, $he...
by emperor
Mon Nov 08, 2004 12:47 pm
Forum: PHP - Code
Topic: Help with = $_SERVER['REMOTE_USER']
Replies: 2
Views: 751

Do you mean $_SERVER['REMOTE_ADDR'] or maybe $_SERVER['REMOTE_HOST'] for info on the machine accessing the script. If you want info on the server the script is running on then maybe you want $_SERVER['SERVER_NAME']. There are a load more too, check them out here http://www.php.net/manual/en/reserved...
by emperor
Mon Nov 08, 2004 5:05 am
Forum: PHP - Code
Topic: converting array into a string
Replies: 2
Views: 237

Try using [php_man]implode[/php_man] - eg...

Code: Select all

<?php
    $array = array (3, '435', 5, 886, 'sdr');
    $string = implode (',', $array);
?>
by emperor
Thu Nov 04, 2004 8:11 am
Forum: PHP - Code
Topic: Get text from another website
Replies: 3
Views: 812

Perhaps a slightly easier alternative to using curl to get the contents of a page is [php_man]file_get_contents[/php_man] which works as long as allow_url_fopen is set to "on" in php.ini (which it is by default).
by emperor
Wed Mar 03, 2004 10:25 am
Forum: PHP - Code
Topic: Session variables gets flushed!!
Replies: 9
Views: 799

Just to confirm really - I copied & pasted your code directly and it worked absolutely fine on my comp. If you changed the session files' directory in php.ini, make sure that PHP has write permission. Other than that I'm not sure what else it could be.
by emperor
Wed Mar 03, 2004 9:06 am
Forum: General Discussion
Topic: Beta testing a web site!
Replies: 7
Views: 1637

Thanks for the input guys, I have fixed the script error! Re the JavaScript form validation, I actually wrote the PHP validation first before putting JavaScripts in to do it, so it's fairly secure. As for query strings, I have tried to keep a lot of stuff hidden in POSTs but due to the "back&qu...