
Alex
Staff Alumni-
Posts
2,467 -
Joined
-
Last visited
Everything posted by Alex
-
This is more HTML than PHP.. <?php echo "<a href='{$row_Recordset1['website']}'><img src=http://www.entertainfortwayne.com/images/home/".$row_Recordset1['logo'] ."></a> "; ?>
-
I believe mikesta707 is correct, you should be using $_FILES['file']['temp']. To check you should be doing: if($info) { //Upload file } As getimagesize() returns false when given an invalid image file.
-
When validating images I always use getimagesize() it works fine and you don't have to create that annoying switch for different image types. It also already gives you access to other information about that file that you may need after you've confirmed it's valid.
-
Doesn't matter, I usually do it; just a habit.
-
Try this switch: switch (strtolower($ext)) { case '.gif': $im = @imagecreatefromgif($filename); break; case '.jpg': $im = @imagecreatefromjpeg($filename); break; case '.png': $im = @imagecreatefrompng($filename); break; default: $im = false; break; } You had a case 'jpg': option and it didn't have a break.
-
Be more specific. Telling us exactly what you want to accomplish will allow us to tell you what the best method will be.
-
Essential ActionScript 3.0 is a good book.
-
You can create another SWF and load the other swfs from inside of that then play them in order.
-
Do what I said and tell us the error it returns; or try what mikesta707 said (remove the quotes). @mikesta707: Just to confirm I tested it, received no error.
-
Even if it is of type INT it shouldn't cause that problem.
-
Right after the query is executed put: if(!$result) echo mysql_error(); Post the result.
-
Pretty much.. Just a few things. The first snippet you posted would be ran only when they're sent, and you need to fix this line on it: $timeinhospital == $time+ 300; Should be: $timeinhospital = time() + 300; //There's no need to define $time Remember, '==' is for comparing only. And because the second snippet is separate from the first you need to define $time (or just use time() in the conditional) and $timeinhospital.
-
[SOLVED] Advice on creating thumbnails using gd library
Alex replied to php_beginner_83's topic in PHP Coding Help
Just to let you know, you can create an on the fly thumbnail using my class as well (Although I probably wouldn't).. //include my class posted above $image = new Image($_GET['image']); $image->resize(width, height); $image->output(); -
I'm pretty sure he doesn't want to do anything flash related.. You should give specific examples of what you wish to achieve for better help.
-
You're thinking about PHP in the wrong way. PHP is a server-side language. JavaScript is client-side. You're wording your question completely wrong so it's hard to know exactly what you want.. PHP is a preprocessor (hence the name, PHP Hypertext Preprocessor), it processes everything and then outputs the result to the browser. So it wouldn't handle anything done after the page has already loaded; so an onclick event in PHP essentially makes absolutely no sense. As I said before I'm not completely sure what you want.. But you can echo JavaScript and have it be handled by the Browser.. echo "<a href='http://www.google.com' onclick='somefunction();'>Stuff</a>";
-
You should be more descriptive.
-
[SOLVED] Advice on creating thumbnails using gd library
Alex replied to php_beginner_83's topic in PHP Coding Help
PHP GD is fine for this type of thing. I wrote a class that can do this very easily if you like.. class Image { private $image, $ext, $file; const CENTER = 0, CENTER_LEFT = 1, CENTER_RIGHT = 2, TOP_CENTER = 3, TOP_LEFT = 4, TOP_RIGHT = 5, BOTTOM_CENTER = 6, BOTTOM_LEFT = 7, BOTTOM_RIGHT = 8; public function __construct($im=NULL) { if(empty($im)) return true; $info = @getimagesize($im); $backtrace = debug_backtrace(); if(!$info) return die('<b>Fatal error:</b> \'' . $im . '\' is not a valid image resource on <b>line ' . $backtrace[0]['line'] . ' [' . $backtrace[0]['file'] . ']</b>'); $ex = explode('/', $info['mime']); $this->ext = $ex[1]; $func = 'imagecreatefrom' . $this->ext; $this->image = @$func($im); $this->file = $im; return true; } public function setImage($im) { $info = @getimagesize($this->file); $backtrace = debug_backtrace(); if(!$info) return die('<b>Fatal error:</b> \'' . $im . '\' is not a valid image resource on <b>line ' . $backtrace[0]['line'] . ' [' . $backtrace[0]['file'] . ']</b>'); $ex = explode('/', $info['mime']); $this->ext = $ex[1]; $func = 'imagecreatefrom' . $this->ext; $this->image = @$func($im); $this->file = $im; return true; } public function resize($width, $height, $porportional=FALSE, $percent=NULL, $max=NULL) { $backtrace = debug_backtrace(); if(empty($this->image)) return die('<b>Fatal error:</b> Invalid call to Image()->resize, no image is set on <b>line ' . $backtrace[0]['line'] . ' [' . $backtrace[0]['file'] . ']</b>'); $info = Array(imagesx($this->image), imagesy($this->image)); if($porportional) { if(empty($max) && empty($percent)) return false; if(empty($max)) { $new_width = $info[0] * ($percent/100); $new_height = $info[1] * ($percent/100); } else { if($info[0] < $max && $info[1] < $max) return false; $new_width = ($info[0] > $info[1]) ? $max : ($info[0]/$info[1]) * $max; $new_height = ($info[0] > $info[1]) ? ($info[1]/$info[0]) * $max : $max; } } else { $new_width = $width; $new_height = $height; } $new_image = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $new_width, $new_height, $info[0], $info[1]); $this->image = $new_image; return true; } public function crop($width, $height, $x, $y, $position=NULL) { $backtrace = debug_backtrace(); if(empty($this->image)) return die('<b>Fatal error:</b> Invalid call to Image()->crop, no image is set on <b>line ' . $backtrace[0]['line'] . ' [' . $backtrace[0]['file'] . ']</b>'); $info = Array(imagesx($this->image), imagesy($this->image)); if($width > $info[0] || $height > $info[1]) return false; if(!empty($position) && $position >= 0 && $position <= { switch($position) { case CENTER: $x = ($info[0] - $width)/2; $y = ($info[1] - $height)/2; break; case CENTER_LEFT: $x = 0; $y = ($info[1] - $height)/2; break; case CENTER_RIGHT: $x = ($info[0] - $height); $y = ($info[1] - $height)/2; break; case TOP_CENTER: $x = ($info[0] - $width)/2; $y = 0; break; case TOP_LEFT: $x = 0; $y = 0; break; case TOP_RIGHT: $x = ($info[0] - $width); $y = 0; break; case BOTTOM_CENTER: $x = ($info[0] - $width)/2; $y = ($info[1] - $height); break; case BOTTOM_LEFT: $x = 0; $y = ($info[1] - $height); break; case BOTTOM_RIGHT: $x = ($info[0] - $width); $y = ($info[1] - $height); break; default: return false; break; } } $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, $x, $y, $width, $height, $width, $height); $this->image = $new_image; return true; } public function save($loc, $compression=100) { $backtrace = debug_backtrace(); if(empty($this->image)) return die('<b>Fatal error:</b> Invalid call to Image()->save, no image is set on <b>line ' . $backtrace[0]['line'] . ' [' . $backtrace[0]['file'] . ']</b>'); $func = 'image' . $this->ext; return $func($this->image, $loc, $compression); } public function output() { $backtrace = debug_backtrace(); if(empty($this->image)) return die('<b>Fatal error:</b> Invalid call to Image()->output, no image is set on <b>line ' . $backtrace[0]['line'] . ' [' . $backtrace[0]['file'] . ']</b>'); header('Content-type: image/' . $this->ext); $func = 'image' . $this->ext; $func($this->image); } } An example of how to use it would be like: //include class $image = new Image('path/to/image'); $image->resize(width, height); $image->save('path/to/new/location'); There's a lot of different features like scaling it down porportionally, setting max widths, max heights etc.. Just depends on exactly what you're looking for. -
Yes, and make sure that it's at the top of the file. Otherwise if there's any output before you call that you'll get a headers already sent error.
-
You could create an additional function, or preferably a class. But if you're looking for simplicity, although I wouldn't necessary suggest it, you could just do something like this: function run_mysql_query($query) { echo "Query: " . $query; mysql_query($query); } run_mysql_query("SELECT * FROM `sometable` WHERE something='value'"); As I previously stated it would be better to create class because you would have much more control and less limitation. Edit: Just read that you want to do it all the bottom, again you should probably use a class.. But if you want to do it the easiest (not the best) way you could do something like: function run_mysql_query($query, &$querylist) { $querylist .= "Query: $query\n"; mysql_query($query); } run_mysql_query("SELECT * FROM `sometable` WHERE something='value'", $querylist); run_mysql_query("SELECT * FROM `sometable` WHERE something='value'", $querylist); run_mysql_query("SELECT * FROM `sometable` WHERE something='value'", $querylist); echo $querylist;
-
I'm not sure you realize exactly how large of a list that would be. It would take a very long time to process every combination as there are 340282366920938000000000000000000000000 different combinations.
-
Ideally, yes, you would make them unique fields. You could however also do something like this: $check = mysql_query("SELECT uid, path FROM `users` WHERE uid='$uid' OR path='$path'"); if(!mysql_num_rows($check)) { //Doesn't exist, insert }
-
You don't need quotes around the table name. $delq = "DELETE FROM $tablename WHERE id='$id'"; $result = mysql_query($delq); echo ($result) ? 'Success' : "Error: " . mysql_error();
-
echo $this->row['firstname']; // Samuel
-
Look into eval()
-
Your form method should be get.. Or you should be using $_REQUEST