[PHP] Setting up group mailer
I am planning a script that will send mail to all my clients (potentially up to 1, even more clients)... I figured I can loop a mailer script for every client (I don't want to have more than one email address per message in the recipient field). Any special advise or pages I could view for help or is looping a mailer script acceptable? I know I had one in ASP once upon a time and the script was so slow that it would mail about 100 messages in a minute and the script would time out quickly before I was done. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Increment alphabetical character (simple question)
How do I get the ASCII value of a character increment it by one... and convert back to a character. For example: I want to grab a char such as "C" and increment it to "D" ??? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Full source
allowcache_expire * 60); $Link = mysql_connect("mysite.com", "db_user", "db_password") or die ("SL1-".mysql_errno().": ".mysql_error()); mysql_select_db ("db_name", $Link) or die ("SL2-".mysql_errno().": ".mysql_error()); /* update Counter Table */ $UpdateCounter = "UPDATE Counter SET Ct=Ct+1 WHERE WHERE Img = '${Img}'"; mysql_query($UpdateCounter, $Link); /* get Img data */ $Query = "SELECT ImgType, ImgData FROM Photos WHERE Img = '${Img}'"; $Results = mysql_query($Query, $Link) or die ("SL3-".mysql_errno().": ".mysql_error()); $Num_rows = mysql_num_rows($Results); if ($Num_rows==1) { $ImgType = mysql_result($Results,0,ImgType); $ImgData = mysql_result($Results,0,ThmData); header("Content-Type: " . $ImgType); echo $ImgData; } ?> Jason Wong wrote: > On Friday 08 February 2002 16:26, phantom wrote: > > I have this really cool script that grabs image data stored in a mysql > > bin field and echo's the data into an image file. > > > > 01: /* QUERY DB AND LOAD IMAGE DATA */ > > 02: /* must get values for ImgType and ThmData */ > > 03: $Results = mysql_query($Query, $Link) > > 04: or die ("SL3-".mysql_errno().": ".mysql_error()); > > 05: $Num_rows = mysql_num_rows($Results); > > 06: if ($Num_rows==1) { // show image; > > 07: $ImgType = mysql_result($Results,0,ImgType); > > 08: $ThmData = mysql_result($Results,0,ThmData); > > 09: header("Content-Type: " . $ImgType); //$ImgType shoud be > > image/jpeg; > > 10: echo $ThmData; > > 11:} > > > > However, I have a simple mysql database counter that counts how many > > times this image is loaded. $UpdateQuery = "UPDATE Counter SET Ct=Ct=1 > > WHERE Img = '${Img}'"; > > Where is this query being used? You're not inadvertently using it twice? > Could you post the complete code? > > > However everytime I run this script the counter increments by 2 (not > > 1). G. > > > > After dicing this script up, the line that is suspect is Line 09: > > > > If I comment out this line (Line 09), the counter increments properly > > (by 1). > > > > If I comment out Line 10 and leave Line 09 in, the counter increases by > > 2 and the image fails to display. Also Line 09 echos the URL of the > > image. Could this URL be resubmitting the script again, thus > > incrementing the counter an extra count??? > > I don't see how it can "resubmit" your script again, it's not using Location:. > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > > /* > The future isn't what it used to be. (It never was.) > */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Header / image question
I have this really cool script that grabs image data stored in a mysql bin field and echo's the data into an image file. 01: /* QUERY DB AND LOAD IMAGE DATA */ 02: /* must get values for ImgType and ThmData */ 03: $Results = mysql_query($Query, $Link) 04: or die ("SL3-".mysql_errno().": ".mysql_error()); 05: $Num_rows = mysql_num_rows($Results); 06: if ($Num_rows==1) { // show image; 07: $ImgType = mysql_result($Results,0,ImgType); 08: $ThmData = mysql_result($Results,0,ThmData); 09: header("Content-Type: " . $ImgType); //$ImgType shoud be image/jpeg; 10: echo $ThmData; 11:} However, I have a simple mysql database counter that counts how many times this image is loaded. $UpdateQuery = "UPDATE Counter SET Ct=Ct=1 WHERE Img = '${Img}'"; However everytime I run this script the counter increments by 2 (not 1). G. After dicing this script up, the line that is suspect is Line 09: If I comment out this line (Line 09), the counter increments properly (by 1). If I comment out Line 10 and leave Line 09 in, the counter increases by 2 and the image fails to display. Also Line 09 echos the URL of the image. Could this URL be resubmitting the script again, thus incrementing the counter an extra count??? Any ideas or where I could find more info? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using strings in switches
The manual shows that you can use switches with numeric values but is it also possible to use strings? Is this possible? If not, what can I do? Just a bunch of if statements? "; break; case Fred Flinstone: echo "Yabba Dabba Do"; break; default: echo "Do not know you"; break; } } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] browser back button - "Page has Expired.. " problem
Also consider: header("Cache-Control: public"); header("Cache-Control: max-age=" . $this->allowcache_expire * 60); This will allow to set the expiration of the cached file on the on the clients browser. The Cache Expire time is in minutes and can be found (and changed) in the php.ini file. Search keyword Cache in php.ini and it will be the first thing you find. Alex Vargas wrote: > Just add this header > > header ("Cache-Control: public"); > > Alex. > > - Original Message - > From: "Lee P Reilly" <[EMAIL PROTECTED]> > To: "PHP List" <[EMAIL PROTECTED]> > Sent: Monday, January 28, 2002 11:26 PM > Subject: [PHP] browser back button - "Page has Expired.. " problem > > > Hi, > > > > I wonder if anyone can offer me a few pointers..? > > > > I'm building a portal to do various bits and bobs. I'm using sessions to > > facilitate the user authentication/login, etc. The only problem I have > > is that when viewing these (.php) pages in IE once the session variable > > has been set, a "Warning: Page has Expired " page is displayed whenever > > the 'Back' button is pressed. This means that the user can only access > > the page again by hitting 'Refresh' (and therefore posting the form data > > back & executing whatever scripts again). > > > > The rest of IE's error message reads, "The page you requested was > > created using information you submitted in a form. This page is no > > longer available. As a security precaution, Internet Explorer does not > > automatically resubmit your information for you." > > > > I know from using other web applications (Hotmail is one example), that > > this doesn't always have to be the case. Is there anyway I can eliminate > > this security precaution on the *server side* i.e. without telling users > > to ditch IE ;-) > > > > Thanks very much in advance for any advice. > > > > - Best regards, > > > >Lee > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] FOUND SOLUTION
Doing some research I found that session cache paramemters may be set in PHP.INI or overridden by inserting the following header() lines into the php for the page you want to cache on the clients browser. Allow Cache Expire time is set in php.ini in minutes. Search php.ini for key word cache and it will be the first time that comes up. header("Cache-Control: public"); header("Cache-Control: max-age=" . $this->allowcache_expire * 60); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Back button to Query Pages
Yes, I would prefer using the back button and go to the page in the clients cache but I think you are right, I may have place a back button on the page that actually resubmits the query paramemters for me. Finally found something that ASP pages can do better than PHP... but only one thing. :) Edward Van Bilderbeek - Bean It wrote: > the moment I hit the send button I realised it myself too :-) > > but this is a pretty good alternative... > > Edward > > - Original Message - > From: "Nick Wilson" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, January 28, 2002 10:15 AM > Subject: Re: [PHP] Back button to Query Pages > > > -BEGIN PGP SIGNED MESSAGE- > > Hash: SHA1 > > > > > > * and then Edward van Bilderbeek - Bean IT blurted > > > Hi, > > > > > > a possible solution is also to provide the backbutton href with the > original > > > variable values... > > > > I'm pretty sure he means the /browser/ back button though. > > - -- > > > > Nick Wilson > > > > Tel: +45 3325 0688 > > Fax: +45 3325 0677 > > Web: www.explodingnet.com > > > > > > > > -BEGIN PGP SIGNATURE- > > Version: GnuPG v1.0.6 (GNU/Linux) > > > > iD8DBQE8VRamHpvrrTa6L5oRAs5EAJ4kJyVPGdcvNmPkTEgCJkIUJZ20PwCgi4K0 > > XJCudv0n1sFrJBrH37W5mVg= > > =ntoU > > -END PGP SIGNATURE- > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Back button to Query Pages
Page 1 is a list of people's names (queried by State). Page 2 is each person's profile. When I hit the back button on Page 2 it tells me it has to requery the List on Page 1 (apparently not stored in the client's browser cache). Is there anyway to make it use the cached copy instead of requeurying the database? I know using Active Server Pages you could do this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Remove value from array
$Str = apple,orange,cyanide,bananna $Arr = split(",",$Str); How do I remove the unwanted value from the array? (in this example, Cyanide ($Arr[2]) from the Fruit array)??? Thanks. array_splice()??? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Zhang Session Expiration
Hey all, I am using the Zhang session method from http://www.phpbuilder.com/columns/ying2602.php3 and it works great with a mysql database. Does anyone out there know how to tell if a session is expired using this method? The Read Session function is: \\---; function sess_read($key) { global $SESS_DBH, $SESS_LIFE; $qry = "SELECT value FROM Sessions WHERE sesskey = '$key' AND expiry > " . time(); $qid = mysql_query($qry, $SESS_DBH); if (list($value) = mysql_fetch_row($qid)) { return $value; } return false; } \\---; So if session is expired, this script will return nothing (per the expiry WHERE clause). Say I had placed a variable called $NameOfUser in the session data using session_register($NameOfUser), if the session is expired, would I be able to know that it was expired by using isset($NameOfUser) after running the session_register($NameOfUser) in the script?? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: --enable-trans-sid
forgot to add, operating on Red Hat 7.1 Phantom wrote: > Hello to my php friends! > > I am trying to compile PHP with: ---enable-trans-sid > > But when i test out pages, the only time a real session is propagated > between pages is when i included the in the URL's (AND THIS > WORKS GREAT!!!). > > BUT, If I remove that PHP sniplet, the session restarts on every PHP > page I load. The PHP manuel specifically says that transparent ID > enabled eliminates the need to do that. Does anyone know what is > going on by chance? > > Does anyone have some insight as to why my transparent ID is not being > passed between pages? Thank you. > > my source files are: > > (1) php-4.1.1.tar.gz (2) mysql_3.23.46.tar.gz and (3) apache_1.3.22.tar.Z > > my whole compile command is: > > ./configure --with-mysql --with-apacher=../apache_1.3.24 > --enable-track-vars --enable-trans-sid --with-imap --with-kerberos > --with-imap-ssl > > in php.ini, i have: > > session.use_trans_sid = 1 > > when i check my config logs, it says: > > checking wether to enable transparent session id propagation . . . . yes > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] --enable-trans-sid
Hello to my php friends! I am trying to compile PHP with: ---enable-trans-sid But when i test out pages, the only time a real session is propagated between pages is when i included the in the URL's (AND THIS WORKS GREAT!!!). BUT, If I remove that PHP sniplet, the session restarts on every PHP page I load. The PHP manuel specifically says that transparent ID enabled eliminates the need to do that. Does anyone know what is going on by chance? Does anyone have some insight as to why my transparent ID is not being passed between pages? Thank you. my source files are: (1) php-4.1.1.tar.gz (2) mysql_3.23.46.tar.gz and (3) apache_1.3.22.tar.Z my whole compile command is: ./configure --with-mysql --with-apacher=../apache_1.3.24 --enable-track-vars --enable-trans-sid --with-imap --with-kerberos --with-imap-ssl in php.ini, i have: session.use_trans_sid = 1 when i check my config logs, it says: checking wether to enable transparent session id propagation . . . . yes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] mysql_escape_string
How do I remove the slashes from mysql_escape_string when I pull the string back out of the DB and want to display it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Reverse effect of htmlspecialchars
Anyway to reverse the effect of htmlspecialchars? Reason: to send an email message where " is shown as " and not " LOL Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Number Format
I would like to format numbers to be a fixed width. I want all numbers to be 2 characters in width to the left of the decimal point. 1 should be 01 2 should be 02 3 should be 03 How can I do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Preg Match
I am passing a string and making sure all the characters in that string are valid. Example: For a persons age I am using: if (!preg_match("/^[0-9]+$/", $Age)) echo "Please Enter numeric value for age". But how would I include the following characters as permissible in preg match ~!@#$%^&*()-=_+,.?/\|{}[] since some of these characters have special meaning in PCRE regrex syntax?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] preg match question
I am passing a string and making sure all the characters in that string are valid. Example: For a persons age I am using: if (!preg_match("/^[0-9]+$/", $Age)) echo "Enter numeric value for age". But how would I include the following characters as permissible in preg match ~!@#$%^&*()-=_+,.?/\|{}[] since some of these characters have special meaning in PCRE regrex syntax?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Date formatting
What would be an easy what to format a date value into month day year?? I want to specially display a date stored in mysql in date format -MM-DD The manual says: string date (string format, int [timestamp]) I tried $FormattedDate = date("F y, Y",${StoredDate}) 1999-04-15 spit out December 31, 1969 when I had hoped for April 15, 1999. Apparently -MM-DD is not a valid timestamp... i tried mysql formats of timestamp(8) and timestamp(14) and that didn't work either -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] replacing Carriage Return
I solicit information from a text field and save the data in mysql to be pulled out later and displayed as text on a webpage. However, Carrage Returns in the text field do not appear in the webpage text. With ereg_replace() I can replace the Carriage Returns with "\n", so what is this the character I need to find in the text field to replace? chr(13) ??? ereg_replace("chr(13)", "\n", $TextFieldData) Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Uploaded Image display problems
hehe. Just for fun I decided to save a copy of the file in a /images folder and then save it into MySQL. Now when I get a bad image in MySQL I also have a bad image in the /images folder. When I have a good image in MySQL I have a good image in /images. So that tells me the problem happens before this step (so before mysql_escape_string and addslashes (if I were using that)), so for some reason it appears the data error problem occurs before it reaches this script. Maybe it gets tainted on submission time to investigate more. Phantom wrote: > I am starting to wonder if the problem lies in mysql_escape_string and it's > manipulation of the binary data before inserting it into the mysql db > (INSERT.PHP) > > I have pretty much the same thing that Gareth has. I did check, the php > script does not time out. I have to at least leave the Header: > Content-Type: $ImgType otherwise the script will output a string and not an > image. > > Gareth Hastings wrote: > > > I found this worked fine for me, I used the same method to read the file > > into the database and the following lines to print the image out. > > > > I tested this with images from 1kb --> 945kb both gif/jpg and it worked > > fine > > > > > $conn = mysql_connect("x", "x", "x"); > > $db = mysql_select_db ("img"); > > $result = mysql_query ("select * from img"); > > $image = mysql_result($result, 0, "image"); > > mysql_close($conn); > > > > echo $image; > > ?> > > > > Try taking out your header statements in display.php just to see what > > happens. Also, you script doesn't timeout half way through does it ? > > (wild guessing now) Does your web server show anything in the logs ? > > > > Gareth > > > > -Original Message- > > From: Michael Hall [mailto:[EMAIL PROTECTED]] > > Sent: 07 December 2001 14:08 > > To: phantom > > Cc: [EMAIL PROTECTED] > > Subject: Re: [PHP] Uploaded Image display problems > > > > I can't help you with the problem described below, but I can tell you > > this: > > > > I, like many others, do not store images as BLOBs in a database. I store > > them in a regular directory (/images), and just store the image name, > > path > > or URL in the database. This generally creates less hassles. > > > > Mick > > > > On Fri, 7 Dec 2001, phantom wrote: > > > > > With thanks to you who have helped me, I have constructed a PHP script > > > that allows the client to upload an image (jpg or gif) that is stored > > in > > > a MySQL Blob field. > > > > > > And I have a PHP script that will pull the binary data out of the > > MySQL > > > database and display the upload image for the client. > > > > > > THE PROBLEM: HALF MY GIF AND JPG FILES DO NOT DISPLAY PROPERLY WHEN > > > VIEWING THE DISPLAY.PHP SCRIPT (see below). Half display fine, half > > do > > > not. > > > > > > Has anyone else had this problem or know what I can do to remedy it? > > > Thank you. > > > > > > Source code below * form.htm, insert.php, display.php * > > > > > > FORM HTM = > > > > > > > > > > > > Insert Binary Data in a Database > > > > > > > > > > > > Upload a File: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > INSERT PHP = > > > > > > > > if (!isset($img1)) { > > > header("Location: insert_file.htm?Msg=EmptyUpload"); > > > exit(); > > > } > > > > > > $db = mysql_connect("localhost", $DB_Username, $DB_pass) > > > or die ("Unable to connect to server."); > > > mysql_select_db($DB_name) > > > or die ("Unable to select DB"); > > > > > > $binary_junk = mysql_escape_string(fread(fopen($img1, "r"), > > > filesize($img1))); > > > // original file used addslashes but here I used mysql_escape_string; > > > > > > $insert_data = "INSERT INTO ImageTable > > (ImgName,ImgSize,ImgType,ImgData) > > > VALUES ('$img1_name', '$img1_size', '$img1_type', '$binary_junk')"; > > > > > > mysql_query($insert_data) > > > or die ("Unable to insert data: ".mysql_error()); > > > &g
Re: [PHP] Uploaded Image display problems
I am starting to wonder if the problem lies in mysql_escape_string and it's manipulation of the binary data before inserting it into the mysql db (INSERT.PHP) I have pretty much the same thing that Gareth has. I did check, the php script does not time out. I have to at least leave the Header: Content-Type: $ImgType otherwise the script will output a string and not an image. Gareth Hastings wrote: > I found this worked fine for me, I used the same method to read the file > into the database and the following lines to print the image out. > > I tested this with images from 1kb --> 945kb both gif/jpg and it worked > fine > > $conn = mysql_connect("x", "x", "x"); > $db = mysql_select_db ("img"); > $result = mysql_query ("select * from img"); > $image = mysql_result($result, 0, "image"); > mysql_close($conn); > > echo $image; > ?> > > Try taking out your header statements in display.php just to see what > happens. Also, you script doesn't timeout half way through does it ? > (wild guessing now) Does your web server show anything in the logs ? > > Gareth > > -Original Message- > From: Michael Hall [mailto:[EMAIL PROTECTED]] > Sent: 07 December 2001 14:08 > To: phantom > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] Uploaded Image display problems > > I can't help you with the problem described below, but I can tell you > this: > > I, like many others, do not store images as BLOBs in a database. I store > them in a regular directory (/images), and just store the image name, > path > or URL in the database. This generally creates less hassles. > > Mick > > On Fri, 7 Dec 2001, phantom wrote: > > > With thanks to you who have helped me, I have constructed a PHP script > > that allows the client to upload an image (jpg or gif) that is stored > in > > a MySQL Blob field. > > > > And I have a PHP script that will pull the binary data out of the > MySQL > > database and display the upload image for the client. > > > > THE PROBLEM: HALF MY GIF AND JPG FILES DO NOT DISPLAY PROPERLY WHEN > > VIEWING THE DISPLAY.PHP SCRIPT (see below). Half display fine, half > do > > not. > > > > Has anyone else had this problem or know what I can do to remedy it? > > Thank you. > > > > Source code below * form.htm, insert.php, display.php * > > > > FORM HTM = > > > > > > > > Insert Binary Data in a Database > > > > > > > > Upload a File: > > > > > > > > > > > > > > > > > > > > > > > > INSERT PHP = > > > > > if (!isset($img1)) { > > header("Location: insert_file.htm?Msg=EmptyUpload"); > > exit(); > > } > > > > $db = mysql_connect("localhost", $DB_Username, $DB_pass) > > or die ("Unable to connect to server."); > > mysql_select_db($DB_name) > > or die ("Unable to select DB"); > > > > $binary_junk = mysql_escape_string(fread(fopen($img1, "r"), > > filesize($img1))); > > // original file used addslashes but here I used mysql_escape_string; > > > > $insert_data = "INSERT INTO ImageTable > (ImgName,ImgSize,ImgType,ImgData) > > VALUES ('$img1_name', '$img1_size', '$img1_type', '$binary_junk')"; > > > > mysql_query($insert_data) > > or die ("Unable to insert data: ".mysql_error()); > > > > $PKey = mysql_insert_id(); > > > > ?> > > > > > > > > Successful File Insertion! > > > > Success! > > > > You have inserted the following into your database: > > > > a > > > > byte file with a mime type of > >> echo "$img1_type"; ?>. > > View Your Image HERE > > > > > > > > DISPLAY PHP = > > > > > $db = mysql_connect("localhost", $DB_Username, $DB_pass) > > or die ("Unable to connect to server."); > > mysql_select_db($DB_name) > > or die ("Unable to select DB"); > > > > $get_image = "SELECT ImgType, ImgData FROM ImageTable WHERE > PKey=$PKey"; > > > > $get_image_result = mysql_query($get_image) > > or die ("Unable to get image."); > > > > $binary_junk = mysql_result($get_image_result,0,ImgData); > > $file_type = mysql_result($get_image_result,0,ImgType); > > > > header("Content-Type: $file_type"); > > header("Content-Length: " . strlen($binary_junk)); > > echo "$binary_junk"; > > > > ?> > > > > > > > > -- > > Michael Hall > [EMAIL PROTECTED] > [EMAIL PROTECTED] > http://openlearningcommunity.org > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Uploaded Image display problems
With thanks to you who have helped me, I have constructed a PHP script that allows the client to upload an image (jpg or gif) that is stored in a MySQL Blob field. And I have a PHP script that will pull the binary data out of the MySQL database and display the upload image for the client. THE PROBLEM: HALF MY GIF AND JPG FILES DO NOT DISPLAY PROPERLY WHEN VIEWING THE DISPLAY.PHP SCRIPT (see below). Half display fine, half do not. Has anyone else had this problem or know what I can do to remedy it? Thank you. Source code below * form.htm, insert.php, display.php * FORM HTM = Insert Binary Data in a Database Upload a File: INSERT PHP = Successful File Insertion! Success! You have inserted the following into your database: a byte file with a mime type of . View Your Image HERE DISPLAY PHP = -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Display BLOB Image
I have successfully placed images (jpg,gif,png) into a MySQL database BLOB field, now I want to be able to pull the data out and diplay it. based on tutorial at http://www.zdnet.com/devhead/stories/articles/0,4413,2644827,00.html after Querying the DB I have the following lines: $ImgFile = mysql_result($Results,0,ImgFile); \\ image data; $ImgType = mysql_result($Results,0,ImgType); \\ image type (image/jpeg, image/gif); header("Content-type: ${ImgType}"); echo "$ImgFile"; Problem: This method, when it pulls up an image, it shows no image but a bunch of greek code. Example http://www.phantomcougar.com/strawberrypie_com/mem/show_img.php?PNum=8 ((be sure to view page source) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Storing Img Binary in MySQL
I want to store the image binary data in a MySQL Blob field. So I created a simple form that prompted the client for an image file that would be uploaded to the server. The server takes the file and gets the following data, assuming ImgFile is the name of the uploaded image. $ImgTitle = $HTTP_POST_FILES['ImgFile']['name']; $ImgType = $HTTP_POST_FILES['ImgFile']['type']; $ImgSize = $HTTP_POST_FILES['ImgFile']['size']; When I go to save $ImgFile into MySQL is is actually saving the name of the temporary location of that file on my server and not the binary data that compose that image. This does not surprise I knew this much at least. So how do I get the Binary DATA to save and not the temp file location? Thx. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Session Help
I am trying to set my session data to be stored in MySQL so I am using session_set_save_handler() which sets the six user-level session storage functions (which I have already defined). Will session_set_save_handler automatically run the appropiate storage function when required (like when i say session_register("Variable")) --OR-- do I specifically have to run that function (mysql_sessions_write(SID,$Value)) from my script when I want to save info to the session table? I would appreciate any scripts anyone might have that would illustrate how this works, the PHP manual and online examples I have found just are not cutting it. Thank you. [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] session_set_save_handler()
I am trying to set up a session setup that saves session data to a mysql database. I have gone into php.ini and set session.save_handler to user. I call the following include file up using session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); (of course I have labeled each function correctly as they appear in my include file, just too lazy to write it all out here). When I run the page this is on, I get a parse error at the line where function session_open is in the include file (see below) Any idea why? Thanks I am modeling this word for word from a example found at: http://www.onlamp.com/pub/a/php/2001/05/10/sessions.html?page=1 (pages 1 thru 3) my session include file: ". time(); $result = mysql_query($query); } // end mysql_session_select() //= // function: mysql_session_write() // purpose: This function writes the session data to the database. If that SID // already exists, then the existing data will be updated. //= mysql_session_write($SID, $value) { GLOBAL $sess_db; GLOBAL $sess_table; GLOBAL $lifetime; $expiration = time() + $lifetime; $query = "INSERT INTO $sess_table VALUES('$SID', '$expiration', '$value')"; $result = mysql_query($query, $sess_db); if (! $result) : $query = "UPDATE $sess_table SET expiration = '$expiration', value = '$value' WHERE SID = '$SID' AND expiration >". time(); $result = mysql_query($query, $sess_db); endif; } // end mysql_session_write() //= // function: mysql_session_destroy() // purpose: deletes all session information having input SID (only one row) //= mysql_session_destroy($sessionID) { GLOBAL $sess_table; $query = "DELETE FROM $sess_table WHERE SID = '$sessionID'"; $result = mysql_query($query); } // end mysql_session_destroy() //= // function: mysql_session_garbage_collect() // purpose: deletes all sessions that have expired. //= mysql_session_garbage_collect($lifetime) { GLOBAL $sess_table; $query = "DELETE FROM $sess_table WHERE sess_expiration < ".time() - $lifetime; $result = mysql_query($query); return mysql_affected_rows($result); } // end mysql_session_garbage_collect() ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Invalid preceding regular expression
What is a << Warning: Invalid preceding regular expression >> mean when running a page? Output --- Warning: Invalid preceding regular expression in /ereg.php on line 4 PHP Page Source - <% function invalid_string($string,$valid) { for ($i=0; $i Ereg <%=$Msg;%>EREG Please enter a valid word only. Only alphanumeric characters! I dare you to try anything else. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Valid Chars Function
Anyone know a good PHP function or script to scan a string for Valid Characters to make sure something that is not allow is not included in a form? $Name = "#@@##@!#!@" would not be a valid alphabetical name, how do I scan for that in PHP? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Changing var value from int to string
Is there any inherit danger or taboos against changing the value of a variable from an integer to a string? example: if ($Msg==1) $Msg = "You have foobar'ed your entire server."; Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] eregi_replace probs
oh duh, why is it always the simplest reason. :) fixed it and it runs good now. thank you sir! Jim Lucas wrote: > sorry didn't notice the & in the args > you'll want this instead. > > > function scan_string(&$str) { > > $forbid = array ("coke", "tylenol", "ford"); > > $swap = array ("pepsi", "advil", "chevrolet"); > > for ($i = 0; $i < count ($forbid); $i++) { > > $str = eregi_replace($forbid[$i],$swap[$i],$str); > > } > > } > > Jim > - Original Message - > From: "phantom" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, November 16, 2001 2:16 PM > Subject: [PHP] eregi_replace probs > > > function scan_string(&$str) { > > $forbid = array ("coke", "tylenol", "ford"); > > $swap = array ("pepsi", "advil", "chevrolet"); > > for ($i = 0; $i < count ($forbid); $i++) { > > eregi_replace($forbid[$i],$swap[$i],$str); > > } > > } > > > > I run this script, and I know the array's load up and the for...do loop > > runs ok. As does the passing variable ($str). > > > > I enter a test script such as "I like coke." and my returned value > > remains "I like coke." > > > > It appears the eregi_replace is the problem. > > > > Any idea why? > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] eregi_replace probs
function scan_string(&$str) { $forbid = array ("coke", "tylenol", "ford"); $swap = array ("pepsi", "advil", "chevrolet"); for ($i = 0; $i < count ($forbid); $i++) { eregi_replace($forbid[$i],$swap[$i],$str); } } I run this script, and I know the array's load up and the for...do loop runs ok. As does the passing variable ($str). I enter a test script such as "I like coke." and my returned value remains "I like coke." It appears the eregi_replace is the problem. Any idea why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] PHP/MySQL
New to this, trying to insert record into DB $Query = "INSERT INTO table_name (Obj,Descrip) VALUES (keyboard,Device to pound on when frustrated.)"; $Results = mysql_query($Query) or die ("Query FAILED"); I keep getting Failed Query messages here, any idea why? PHP/MySQL manuals do not have examples of how to do this. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] PHP Redirect / header("location: ")
I am trying to set up a redirect scirpt that in ASP was response.redirect(escape("newpage.asp")). I tried in PHP >> header("location: newpage.php") but all i got was an error message saying that my header content had already been sent. This PHP script was above the html script. Am I doing something wrong? Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Binary file transfers
I am uploading .Jpegs and GIFS but they end up being all messed up when I try to view them after a file transfer. However, txt file transfers work ok. Someone told me this is because images need to be transfered as binary files, not ascii files (like txt). Is this true, and if so, how do I correct for this? Thanks. SOURCE CODE _ <% if ($Action == "Submit") { /* define and list important vars */ $Userfile = $HTTP_POST_FILES['Userfile']['name']; $Type = $HTTP_POST_FILES['Userfile']['type']; $Size = $HTTP_POST_FILES[Userfile][size]; $TempLoc = $HTTP_POST_FILES[Userfile][tmp_name]; $FinalLoc = "website_com/uploads/$Userfile"; echo " File: $Userfile | Type: $Type | Size: $Size | TempLoc: $TempLoc FinalLoc: $FinalLoc "; /* confirm file not too big and permitted type */ if ($Size > 20) $FileError = "File size greater than 200 kb."; if (($Type != "text/plain") && ($Type != "image/jpeg") && ($Type != "image/gif") && ($Type != "image/pjpeg")) $FileError = "File not correct type (txt, jpg, gif only)."; /* move file to final destination on server if no errors */ if (!$FileError) move_uploaded_file($TempLoc, $FinalLoc); } else { echo " Load page"; } if ($FileError) echo "FILE NOT ACCEPTED: $FileError"; %> PHP Send File Send me a file!!! Testing page 200 kbytes max. Text, Jpeg, and Gif's only. Send this file: <% echo "Browser and OS: $HTTP_USER_AGENT IP Addr: $REMOTE_ADDR"; %> View the upload directory to see if your file is there. View this page's full source code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Comparing strings
Must have been a missing semi-colon it works now. Thanks. <% echo $Action; if ($Action == "Submit") { echo " Process form"; } else { echo " Do Nothing"; } %> Cc Zona wrote: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] (Phantom) wrote: > > > In PHP I have tried > > > > if ($Action == "Submit") but I get a parse error in that statement. > > What am I doing wrong? Thank you. I did an echo $Action to confirm > > that it's value is Submit. > > If the variable is set as you've confirmed, then that should work. If PHP > is reporting a parse error with that line number, note that the lines where > PHP stopped parsing isn't necessarily the line where the bad code resides. > Try checking back a few lines; you may have left off a semi-colon or > somesuch. Another idea: check that the variable's length is the expected 5 > chars; maybe there's some trailing whitespace that's causing the comparison > to fail (trim() is handy for avoiding this gotcha). If neither of those > solve the problem, try re-posting with a larger code snippet. > > -- > CC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Comparing strings
Bear with me, new to PHP and got a beginner's questions How do I run an if statement and the if statement compares a String? IN ASP (yes I Know, ASP is evil) I would have wrote if (String(Request("Action"))=="Submit") do this In PHP I have tried if ($Action == "Submit") but I get a parse error in that statement. What am I doing wrong? Thank you. I did an echo $Action to confirm that it's value is Submit. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]