[PHP] getimagesize() MySQL Image Storage (Running functions on contents of variables)
I'm using a MySQL database to store images as BLOBs. I know how to handle all the MySQL stuff, it's easy, and really makes keeping track of files nice an clean. No permissions, no risk of getting things out of sync, finding stuff is as easy as SQL. My question is about handling stuff once you pull it out of the database. When I store images in the database, I currently stash the format and the resolution in the database, which works but is a bit messy. I can't find any easy way to run getimagesize on the contents of a variable, not a file. I could write the image to a file if I needed to, but that can be slow and rather inelegant, I'd rather store the values in the DB. Any ideas on how I could use getimagesize or similar function to determine the format and resolution of the image in a variable? I have had a similar problem with ftp uploading. There was no way to upload the contents of a variable, so I had to write everything to the disk, kind of annoying when I have 1,000 files. The script wasn't a very heavily used script nor could the public execute it, but it bugged me to no end. I think there are some other functions that also only operate on files and I've fought with them too. Is there any kind of generic solution for this? Some kind of wrapper I could use to make a variable act like a reference to a file but actually be in memory only? If this seems totally pointless, please tell me. But it seems like there should be a way for almost any function that runs off a file to run off the contents of a variable, it's just binary data. Thanks, Galen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and IIS
Of course but when I make a file test.shtml, the php-code will be ignored, and when I name the file test.php, the SSI will be ignored. - Original Message - From: John W. Holmes [EMAIL PROTECTED] To: V.B. de Haan [EMAIL PROTECTED] Cc: PHP General Mailing List [EMAIL PROTECTED] Sent: Saturday, December 06, 2003 11:54 PM Subject: Re: [PHP] PHP and IIS V.B. de Haan wrote: I'm running IIS 5.0 on win 2000 professional. I want to include SSI and PHP code in one single file of HTML. How can I do this? The question is WHY you'd want to do this. Whatever you're doing in your SSI should just be done in PHP. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and IIS
Now the WHY-question: at the bottom of every page, a complex CGI-Perl-script has to be executed, it's more easily to add only one line of SSI-comment, than the whole content of te script. I also have to translate it to PHP. Vincent - Original Message - From: John W. Holmes [EMAIL PROTECTED] To: V.B. de Haan [EMAIL PROTECTED] Cc: PHP General Mailing List [EMAIL PROTECTED] Sent: Saturday, December 06, 2003 11:54 PM Subject: Re: [PHP] PHP and IIS V.B. de Haan wrote: I'm running IIS 5.0 on win 2000 professional. I want to include SSI and PHP code in one single file of HTML. How can I do this? The question is WHY you'd want to do this. Whatever you're doing in your SSI should just be done in PHP. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Persistence of session files
On Sunday, December 7, 2003, at 04:48 PM, Pablo Gosse wrote: Hi all. I'm wondering if anyone can tell me how long temporary session files stay on the server after the session has ended if session_destroy() is not called. AFAIK, this depends on two php.ini directives: --- ; Define the probability that the 'garbage collection' process is started ; on every session initialization. ; The probability is calculated by using gc_probability/gc_divisor, ; e.g. 1/100 means there is a 1% chance that the GC process starts ; on each request. session.gc_probability = 1 session.gc_divisor = 100 ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process. session.gc_maxlifetime = 1440 --- If you still need a little clarification, after 1440 seconds (24 mins) of an inactive session, the session will be seen as garbage. BUT the probability of the garbage collection taking place is reliant on the the 1% (in the above case) chance that garbage collection should take place. On a busy server, this means that garbage will be thrown out almost straight after the 1440 seconds are up, but on a very quiet server, you might need to change the 1/100 to something like 2/100 (2%) or even more. What I'm curious about is how long these last before they are somehow deleted? Is there some way I can control this? Modify the php.ini and test. session.gc_probability and session.gc_maxlifetime can also be modified via ini_set() or a .htaccess file. http://au3.php.net/ini_set Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: getimagesize() MySQL Image Storage (Running functions on contents of variables)
Galen wrote: I'm using a MySQL database to store images as BLOBs. I know how to handle all the MySQL stuff, it's easy, and really makes keeping track of files nice an clean. No permissions, no risk of getting things out of sync, finding stuff is as easy as SQL. My question is about handling stuff once you pull it out of the database. When I store images in the database, I currently stash the format and the resolution in the database, which works but is a bit messy. I can't find any easy way to run getimagesize on the contents of a variable, not a file. I could write the image to a file if I needed to, but that can be slow and rather inelegant, I'd rather store the values in the DB. Any ideas on how I could use getimagesize or similar function to determine the format and resolution of the image in a variable? I have had a similar problem with ftp uploading. There was no way to upload the contents of a variable, so I had to write everything to the disk, kind of annoying when I have 1,000 files. The script wasn't a very heavily used script nor could the public execute it, but it bugged me to no end. I think there are some other functions that also only operate on files and I've fought with them too. Is there any kind of generic solution for this? Some kind of wrapper I could use to make a variable act like a reference to a file but actually be in memory only? If this seems totally pointless, please tell me. But it seems like there should be a way for almost any function that runs off a file to run off the contents of a variable, it's just binary data. Thanks, Galen If the programs read from a file descriptor, you could open a pipe, write into it on your side, and have the command read from it. But that's really messy... and won't work for the image size function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL Dump using PHP
Justin Patrin [EMAIL PROTECTED] wrote news:[EMAIL PROTECTED] Use mysqldump in a system() call, redirect it to a temp file, then read it back and out to the browser. Or, you could use popen to get the output piped back into php. Make sure to check the mysqldump options for things you need (I often use -Q -e --add-drop-table). ?php header('Content-type: application/mysql'); header('Content-disposition: attachment; filename=dump.sql'); $fd = popen('mysqldump -uuser -ppassword databaseName', 'r'); while(!feof($fd)) { echo fgets($fd); } pclose($fd); ? Thanks a lot. I haven't used this functions ever, but I'm sure PHP.net (and maybe some help from you guys) will do the job. Also thanks to Ajai for the idea. ___ Cesar L. Aracena Commercial Manager / Developer ICAAM Web Solutions 2K GROUP Neuquen, Argentina Tel: +54.299.4774532 Cel: +54.299.6356688 E-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and IIS
V.B. de Haan wrote: Now the WHY-question: at the bottom of every page, a complex CGI-Perl-script has to be executed, it's more easily to add only one line of SSI-comment, than the whole content of te script. I also have to translate it to PHP. No you don't. Just use virtual(). http://us2.php.net/virtual -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 7 Dec 2003 15:26:52 -0000 Issue 2459
php-general Digest 7 Dec 2003 15:26:52 - Issue 2459 Topics (messages 172111 through 172129): Random Numbers.. 172111 by: TheHeadSage 172115 by: Alex 172116 by: Burrito Warrior Re: Random Numbers.. [Solved, Ignore] 172112 by: TheHeadSage Re: Check type of uploaded file 172113 by: Richard Davey 172121 by: Gerard Samuel Re: Apache 2 + PHP 172114 by: Yves Arsenault Help!session problem! 172117 by: ÎÚÓÐ ÎÞ 172119 by: Chris Shiflett Persistence of session files 172118 by: Pablo Gosse 172120 by: Chris Shiflett 172125 by: Justin French getimagesize() MySQL Image Storage (Running functions on contents of variables) 172122 by: Galen 172126 by: Justin Patrin 172127 by: Justin Patrin Re: PHP and IIS 172123 by: V.B. de Haan 172124 by: V.B. de Haan 172129 by: John W. Holmes Re: MySQL Dump using PHP 172128 by: Cesar Aracena Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- Hey, I've got a script which used to generate a random quote. It worked fine untill this problem occurred.. Say we have 4 quotes with QuoteID's of 1 through to 4 The script would grab a number of rows, and generate a random number between 1 and this value (being 4 in this case) This worked fine untill, one of the quotes was removed and another added, leaving 4 quotes once again, but the last one had an ID of 5. The problem is the Random number generated is between 1 and 4, so the final quote is never shown.. I tried using the RAND() function in the MySQL statement it's self, but it's not random enough... Then I thought of doing this: Select all the Quote ID's from the DB. Store them in an Array. Generate a random number between 1 and the last ID. If the Random Number matches a Quote ID, then display the quote, otherwise Generate another But I couldn't get the code to work. Any suggestions on either how to write the above, or made the MySQL RAND() function, more random? ---End Message--- ---BeginMessage--- Theheadsage wrote: Hey, I've got a script which used to generate a random quote. It worked fine untill this problem occurred.. Say we have 4 quotes with QuoteID's of 1 through to 4 The script would grab a number of rows, and generate a random number between 1 and this value (being 4 in this case) This worked fine untill, one of the quotes was removed and another added, leaving 4 quotes once again, but the last one had an ID of 5. The problem is the Random number generated is between 1 and 4, so the final quote is never shown.. I tried using the RAND() function in the MySQL statement it's self, but it's not random enough... Then I thought of doing this: Select all the Quote ID's from the DB. Store them in an Array. Generate a random number between 1 and the last ID. If the Random Number matches a Quote ID, then display the quote, otherwise Generate another But I couldn't get the code to work. Any suggestions on either how to write the above, or made the MySQL RAND() function, more random? how about if ($randnumber == 4) $randnumber++; ? ---End Message--- ---BeginMessage--- No, I wouldn't do that. What if another quote gets deleted. The new assigned QuoteID would be 6 and your solution wouldn't work. This would: /* selecting a random record, where n = 1. Works fine on small tables */ mysql SELECT value FROM table ORDER BY RAND() LIMIT n; /* selecting a random record. This is good on large tables if numbering sequence is used */ mysql SET @val = FLOOR(RAND() * n) + 1; mysql SELECT value FROM table WHERE ID = @val; -Original Message- From: Alex [mailto:[EMAIL PROTECTED] Sent: Sunday, December 07, 2003 12:00 AM To: [EMAIL PROTECTED] Subject: [PHP] Re: Random Numbers.. Theheadsage wrote: Hey, I've got a script which used to generate a random quote. It worked fine untill this problem occurred.. Say we have 4 quotes with QuoteID's of 1 through to 4 The script would grab a number of rows, and generate a random number between 1 and this value (being 4 in this case) This worked fine untill, one of the quotes was removed and another added, leaving 4 quotes once again, but the last one had an ID of 5. The problem is the Random number generated is between 1 and 4, so the final quote is never shown.. I tried using the RAND() function in the MySQL statement it's self, but it's not random enough... Then I thought of doing this: Select all the Quote ID's from the DB. Store them in an Array. Generate a random number between 1 and the last ID. If the Random Number matches a Quote ID, then display the quote, otherwise Generate another But I couldn't get the code to work. Any suggestions on either how to write the
Re: [PHP] Re: getimagesize() MySQL Image Storage (Running functions on contents of variables)
So you're saying there's no way to do what I want to do. Anybody got any other ideas? It seems so stupid to be unable to run functions that accept files on variables, with so many people using databases and whatnot these days. -Galen On Dec 7, 2003, at 1:46 AM, Justin Patrin wrote: Galen wrote: I'm using a MySQL database to store images as BLOBs. I know how to handle all the MySQL stuff, it's easy, and really makes keeping track of files nice an clean. No permissions, no risk of getting things out of sync, finding stuff is as easy as SQL. My question is about handling stuff once you pull it out of the database. When I store images in the database, I currently stash the format and the resolution in the database, which works but is a bit messy. I can't find any easy way to run getimagesize on the contents of a variable, not a file. I could write the image to a file if I needed to, but that can be slow and rather inelegant, I'd rather store the values in the DB. Any ideas on how I could use getimagesize or similar function to determine the format and resolution of the image in a variable? I have had a similar problem with ftp uploading. There was no way to upload the contents of a variable, so I had to write everything to the disk, kind of annoying when I have 1,000 files. The script wasn't a very heavily used script nor could the public execute it, but it bugged me to no end. I think there are some other functions that also only operate on files and I've fought with them too. Is there any kind of generic solution for this? Some kind of wrapper I could use to make a variable act like a reference to a file but actually be in memory only? If this seems totally pointless, please tell me. But it seems like there should be a way for almost any function that runs off a file to run off the contents of a variable, it's just binary data. Thanks, Galen If the programs read from a file descriptor, you could open a pipe, write into it on your side, and have the command read from it. But that's really messy... and won't work for the image size function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Can I request ?
Hi, I am using a PHPBB to have forum and site in php and i need a little script , can i request it here or do you know an otehr group where i can request it. Thnaks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can I request ?
On Sunday 07 December 2003 11:33 am, playerfr wrote: Hi, I am using a PHPBB to have forum and site in php and i need a little script , can i request it here or do you know an otehr group where i can request it. Uh, you can request help writing the script here when you hit a wall, but it's not really a good idea to ask someone to do it for you, unless you're going to pay them. If you want to pay someone, this is a great place to find experienced coders... Thnaks -- Evan Nemerson [EMAIL PROTECTED] http://coeusgroup.com/en -- I am indeed amazed when I consider how weak my mind is and how prone to error. -Rene Descartes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random Numbers..
On Saturday 06 December 2003 10:39 pm, TheHeadSage wrote: Hey, I've got a script which used to generate a random quote. It worked fine untill this problem occurred.. Say we have 4 quotes with QuoteID's of 1 through to 4 The script would grab a number of rows, and generate a random number between 1 and this value (being 4 in this case) This worked fine untill, one of the quotes was removed and another added, leaving 4 quotes once again, but the last one had an ID of 5. The problem is the Random number generated is between 1 and 4, so the final quote is never shown.. I tried using the RAND() function in the MySQL statement it's self, but it's not random enough... Perhaps something like SELECT quote FROM quotes ORDER BY RAND('.mt_rand().') LIMIT 1 Then I thought of doing this: Select all the Quote ID's from the DB. Store them in an Array. Generate a random number between 1 and the last ID. If the Random Number matches a Quote ID, then display the quote, otherwise Generate another Wow, sounds complicated. How about shuffle($quotes); echo $quotes[0]; but much better speed-wise to do it from the DB. But I couldn't get the code to work. Any suggestions on either how to write the above, or made the MySQL RAND() function, more random? um, yeah. -- Evan Nemerson [EMAIL PROTECTED] http://coeusgroup.com/en -- A popular government, without popular information, or the means of acquiring it, is but a Prologue to a Farce or a Tragedy - or perhaps both. Knowledge will forever govern ignorance, and a people who mean to be their own Governors must arm themselves with the power which knowledge gives. -James Madison -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] write failed
Just wanted to see if this was correct. To me this is saying that /tmp cannot be written to as there is no space left on device. Warning: Unknown(): write failed: No space left on device (28) in Unknown on line 0 Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Check type of uploaded file
Richard Davey wrote: BH I want to test an uploaded file to see if it is a text file, but I don't want BH to rely on the presence of an os command such as 'file.' Is there a BH straightforward way to do this within PHP? Thanks in advance. Yes, check the $_FILES['userfile']['type'] after upload. I tried this initially, but the problem is that it relies on the client's interpretation of the file type. With the files I used for testing, Konqueror and other reported the MIME type as text/plain, but Mozilla reported it as application/octet-stream. What I am looking for is a way to test the file depending only upon PHP. i.e., to be platform and client independent. -Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Check type of uploaded file
Gerard Samuel wrote: On Saturday 06 December 2003 11:01 pm, Richard Davey wrote: Yes, check the $_FILES['userfile']['type'] after upload. That can be spoofed. There isn't really a way to determine file types... I was thinking of trying something like ereg([[:print:]]*, $contents) on the file. Not really what I want, but would reject obvious non-text files. -Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Random Numbers..
select all and use mysql_data_seek($result, rand(mysql_num_rows($result) - 1)); $row = mysql_fetch_assoc($result); and there, your random row is returnd, that should be easy enough :) and it should work -- Luke Theheadsage [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hey, I've got a script which used to generate a random quote. It worked fine untill this problem occurred.. Say we have 4 quotes with QuoteID's of 1 through to 4 The script would grab a number of rows, and generate a random number between 1 and this value (being 4 in this case) This worked fine untill, one of the quotes was removed and another added, leaving 4 quotes once again, but the last one had an ID of 5. The problem is the Random number generated is between 1 and 4, so the final quote is never shown.. I tried using the RAND() function in the MySQL statement it's self, but it's not random enough... Then I thought of doing this: Select all the Quote ID's from the DB. Store them in an Array. Generate a random number between 1 and the last ID. If the Random Number matches a Quote ID, then display the quote, otherwise Generate another But I couldn't get the code to work. Any suggestions on either how to write the above, or made the MySQL RAND() function, more random? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Not able to execute Linux binary
Hello I think there is some problem with the permission. Even if I execute a command like - echo ( start ); exec ( pwd ); echo ( end ); the output is - startend shouldnt be pwd showing the present working directory to me. Karam --- Jason Wong [EMAIL PROTECTED] wrote: On Saturday 06 December 2003 12:56, Karam Chand wrote: looking at manuals and help and some help from you. i wrote the attached code- error_reporting (E_ALL); ini_set('display_errors', 1); $result = `./myapp`; print_r ( $result ); echo ( 2 ); exec(./myapp,$result); print_r($result); It is returning output 2Array ( ) which means the array is empty !!! it should have outputted ErrorError I believe you mean to say that it should output: 2Error OK, does your myapp program dump its output to STDOUT?, Remember exec() only captures STDOUT. Both the php and the binary exsits in http://www.mydomain.com/mgmt/ One way to satisfy yourself that exec() is working is to create a small test program, eg: 8- #!/bin/bash echo test 8- Then exec() it. Can I send you the binary so that you can check it out? No thank you. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* The girl who stoops to conquer usually wears a low-cut dress. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 8 Dec 2003 04:56:54 -0000 Issue 2460
php-general Digest 8 Dec 2003 04:56:54 - Issue 2460 Topics (messages 172130 through 172138): Re: getimagesize() MySQL Image Storage (Running functions on contents of variables) 172130 by: Galen Can I request ? 172131 by: playerfr 172132 by: Evan Nemerson Re: Random Numbers.. 172133 by: Evan Nemerson 172137 by: Luke write failed 172134 by: Dan McCullough Re: Check type of uploaded file 172135 by: Bob Hockney 172136 by: Bob Hockney Re: Not able to execute Linux binary 172138 by: Karam Chand Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- So you're saying there's no way to do what I want to do. Anybody got any other ideas? It seems so stupid to be unable to run functions that accept files on variables, with so many people using databases and whatnot these days. -Galen On Dec 7, 2003, at 1:46 AM, Justin Patrin wrote: Galen wrote: I'm using a MySQL database to store images as BLOBs. I know how to handle all the MySQL stuff, it's easy, and really makes keeping track of files nice an clean. No permissions, no risk of getting things out of sync, finding stuff is as easy as SQL. My question is about handling stuff once you pull it out of the database. When I store images in the database, I currently stash the format and the resolution in the database, which works but is a bit messy. I can't find any easy way to run getimagesize on the contents of a variable, not a file. I could write the image to a file if I needed to, but that can be slow and rather inelegant, I'd rather store the values in the DB. Any ideas on how I could use getimagesize or similar function to determine the format and resolution of the image in a variable? I have had a similar problem with ftp uploading. There was no way to upload the contents of a variable, so I had to write everything to the disk, kind of annoying when I have 1,000 files. The script wasn't a very heavily used script nor could the public execute it, but it bugged me to no end. I think there are some other functions that also only operate on files and I've fought with them too. Is there any kind of generic solution for this? Some kind of wrapper I could use to make a variable act like a reference to a file but actually be in memory only? If this seems totally pointless, please tell me. But it seems like there should be a way for almost any function that runs off a file to run off the contents of a variable, it's just binary data. Thanks, Galen If the programs read from a file descriptor, you could open a pipe, write into it on your side, and have the command read from it. But that's really messy... and won't work for the image size function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- Hi, I am using a PHPBB to have forum and site in php and i need a little script , can i request it here or do you know an otehr group where i can request it. Thnaks ---End Message--- ---BeginMessage--- On Sunday 07 December 2003 11:33 am, playerfr wrote: Hi, I am using a PHPBB to have forum and site in php and i need a little script , can i request it here or do you know an otehr group where i can request it. Uh, you can request help writing the script here when you hit a wall, but it's not really a good idea to ask someone to do it for you, unless you're going to pay them. If you want to pay someone, this is a great place to find experienced coders... Thnaks -- Evan Nemerson [EMAIL PROTECTED] http://coeusgroup.com/en -- I am indeed amazed when I consider how weak my mind is and how prone to error. -Rene Descartes ---End Message--- ---BeginMessage--- On Saturday 06 December 2003 10:39 pm, TheHeadSage wrote: Hey, I've got a script which used to generate a random quote. It worked fine untill this problem occurred.. Say we have 4 quotes with QuoteID's of 1 through to 4 The script would grab a number of rows, and generate a random number between 1 and this value (being 4 in this case) This worked fine untill, one of the quotes was removed and another added, leaving 4 quotes once again, but the last one had an ID of 5. The problem is the Random number generated is between 1 and 4, so the final quote is never shown.. I tried using the RAND() function in the MySQL statement it's self, but it's not random enough... Perhaps something like SELECT quote FROM quotes ORDER BY RAND('.mt_rand().') LIMIT 1 Then I thought of doing this: Select all the Quote ID's from the DB. Store them in an Array. Generate a random number between 1 and the last ID. If the Random Number matches a Quote ID, then display the quote,
Re: [PHP] getimagesize() MySQL Image Storage (Running functions on contents of variables)
Hi, Sunday, December 7, 2003, 6:38:13 PM, you wrote: G I'm using a MySQL database to store images as BLOBs. I know how to G handle all the MySQL stuff, it's easy, and really makes keeping track G of files nice an clean. No permissions, no risk of getting things out G of sync, finding stuff is as easy as SQL. G My question is about handling stuff once you pull it out of the G database. When I store images in the database, I currently stash the G format and the resolution in the database, which works but is a bit G messy. I can't find any easy way to run getimagesize on the contents of G a variable, not a file. I could write the image to a file if I needed G to, but that can be slow and rather inelegant, I'd rather store the G values in the DB. Any ideas on how I could use getimagesize or similar G function to determine the format and resolution of the image in a G variable? G I have had a similar problem with ftp uploading. There was no way to G upload the contents of a variable, so I had to write everything to the G disk, kind of annoying when I have 1,000 files. The script wasn't a G very heavily used script nor could the public execute it, but it bugged G me to no end. I think there are some other functions that also only G operate on files and I've fought with them too. G Is there any kind of generic solution for this? Some kind of wrapper I G could use to make a variable act like a reference to a file but G actually be in memory only? G If this seems totally pointless, please tell me. But it seems like G there should be a way for almost any function that runs off a file to G run off the contents of a variable, it's just binary data. G Thanks, G Galen Do the get sizes while it is still as a file after upload then save the size info with the file in the db or use unpack to get the size from the raw data, it is usually in the header somewhere. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Not able to execute Linux binary
On Monday 08 December 2003 12:56, Karam Chand wrote: I think there is some problem with the permission. Even if I execute a command like - echo ( start ); exec ( pwd ); echo ( end ); the output is - startend shouldnt be pwd showing the present working directory to me. Yes, but exec() itself does NOT output anything. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Every recipe ever written includes one ingredient that you do not have in your kitchen -- Murphy's Food Laws n5 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Not able to execute Linux binary
On Mon, Dec 08, 2003 at 01:28:11PM +0800, Jason Wong wrote: On Monday 08 December 2003 12:56, Karam Chand wrote: I think there is some problem with the permission. Even if I execute a command like - echo ( start ); exec ( pwd ); echo ( end ); the output is - startend shouldnt be pwd showing the present working directory to me. Yes, but exec() itself does NOT output anything. If there is a beter way, someone reply but I beleave the command you are looking for is system() -- Jerry M. Howell II -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php