Re: [PHP] Watermark with GD
At 3:05 PM -0400 10/29/10, Gary wrote: I am trying to get the watermark to work, however I am having a problem in that the image is being called from a database (image sits in images file). The script in question is this $image = imagecreatefromjpeg($_GET['src']); However it produces an error message of Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: Filename cannot be empty in /home/content/a/l/i/alinde52/html/imagesDetail.php on line 233 I have tried various methods, for example: ($_GET ['images/'] or ($_GET ['images/$row_WADAimages["image_id"]]. Can anyone shed some light on this for me. Thank you Gary Gary: Several things. 1. Getting an image from a database? You mean that you are getting the path of the image in the file system, right? Side note: You could place the image inside the database using a BLOB and do away with the path all together. That has the benefit of being portable -- you simply move the database to where ever you want it. The downside is that the database becomes very large, but no more so that the file system. There are pro's and con's in storing actual images in a database. 2. Using a GET is not the way to get the path. Instead, you have to retrieve the path from the database table where the path is stored -- and that requires a MySQL query similar to "SELECT * FROM WHERE id=". There are lot's of examples of how to pull data from a database. 3. After getting the path, then you can create the watermark like so: http://webbytedd.com/b/watermark/ Hope this helps, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] a loop constructing the URLs and make PHP to fetch up to 100 pages [ a seven liner]
dear list - good Morning! i want to parse the site - and get the results out of it: http://www.educa.ch/dyn/79363.asp?action=search therefore i need to loop over the line 2 - don ´ i!? http://www.educa.ch/dyn/79363.asp?action=search'); $regex = '/Page 1 of (.+?) results/'; preg_match($regex,$data,$match); var_dump($match); echo $match[1]; ?> in order to get the details of the pages - http://www.educa.ch/dyn/79376.asp?id=4438 http://www.educa.ch/dyn/79376.asp?id=53 and so forth - well i need a foreach statement in line two - don´ t i!? just help me with this seven-liner ;) on a sidenote: measuring code in terms of how many lines it took to write is a Perl-coder-attitude. Only Perl programmers care about that and i find it hard it is to read Perl code. love to hear from you ___ GRATIS! Movie-FLAT mit über 300 Videos. Jetzt freischalten unter http://movieflat.web.de -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Watermark with GD
"tedd" wrote in message news:p06240800c8f1d19b9...@[192.168.1.2]... > At 3:05 PM -0400 10/29/10, Gary wrote: >>I am trying to get the watermark to work, however I am having a problem in >>that the image is being called from a database (image sits in images >>file). >> >>The script in question is this >> >>$image = imagecreatefromjpeg($_GET['src']); >> >>However it produces an error message of >> >>Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: Filename >>cannot be empty in /home/content/a/l/i/alinde52/html/imagesDetail.php on >>line 233 >> >>I have tried various methods, for example: ($_GET ['images/'] or ($_GET >>['images/$row_WADAimages["image_id"]]. >> >>Can anyone shed some light on this for me. >> >>Thank you >> >>Gary > > Gary: > > Several things. > > 1. Getting an image from a database? You mean that you are getting the > path of the image in the file system, right? > > Side note: You could place the image inside the database using a BLOB and > do away with the path all together. That has the benefit of being > portable -- you simply move the database to where ever you want it. The > downside is that the database becomes very large, but no more so that the > file system. There are pro's and con's in storing actual images in a > database. > > 2. Using a GET is not the way to get the path. Instead, you have to > retrieve the path from the database table where the path is stored -- > and that requires a MySQL query similar to "SELECT * FROM WHERE > id=". There are lot's of examples of how to pull data from a > database. > > 3. After getting the path, then you can create the watermark like so: > > http://webbytedd.com/b/watermark/ > > Hope this helps, > > tedd > > -- > --- > http://sperling.com/ > tedd Thank you for your reply. I was under the impression that the image is stored in a folder called images, in fact the images file do go in, however I have the DB set up for longblob, averaging about 20kb each, so now I am unsure. I exported the sql so perhaps you can tell me. Table structure for table `images` -- CREATE TABLE IF NOT EXISTS `images` ( `image_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `caption` varchar(50) NOT NULL, `wheretaken` varchar(100) NOT NULL, `description` text NOT NULL, `file_name` varchar(25) NOT NULL, `image_file` longblob NOT NULL, `submitted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`image_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1447 ; When I call the images, which works fine, I do need to specify the path that leads to the images folder. Am I being redundant in this structure. This is the script that I use to call the images. I have pulled out some of the html that styles the data. 0) { // Show if recordset not empty ?> src="images/" " Thank you for your help. Gary __ Information from ESET Smart Security, version of virus signature database 5576 (20101029) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Watermark with GD
"Tamara Temple" wrote in message news:7f666311-4bc8-4064-8c70-4f2597e7b...@gmail.com... > On Oct 29, 2010, at 2:44 PM, Gary wrote: >> "Adam Richardson" wrote in message >> news:aanlkti=kenxt7yewrztcm4+hyifrlqhozxse7ufmq...@mail.gmail.com... >> On Fri, Oct 29, 2010 at 3:05 PM, Gary wrote: >>> I am trying to get the watermark to work, however I am having a problem >>> in >>> that the image is being called from a database (image sits in images >>> file). >>> >>> The script in question is this >>> >>> $image = imagecreatefromjpeg($_GET['src']); >>> >>> However it produces an error message of >>> >>> Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: Filename >>> cannot be empty in /home/content/a/l/i/alinde52/html/ imagesDetail.php >>> on >>> line 233 >>> >> >> First things first. It looks like there's nothing in $_GET['src']. >> From where are you getting the value 'src'? >> >> Adam >> >> ** >> Adam >> >> Thanks for your reply, that is my question, what is to replace ['src'] >> if I >> am calling the image from a database. >> >> Gary > > I'd really need to know more about this application to help. If you are > calling the image from a database (does this mean you have the image's > file spec saved in the database, or you actually storing the image data > in the database?), you need to use a query to do that. Is the > imagesDetail.php script being called by something else that already > queried the database and put the file spec in the src query string > argument? Before you dump the query string argument directly into the > imagecreatefromjpeg() funciton, you should verify that it exists: > > if (isset($_GET['src'[) && (!empty($_GET['src'[) { > $src = $_GET['src']; > if (fileexists($src)) { > $image = imageceatefromjpeg($src); > if ($image === FALSE) { > # process error from imagecreatefromjpeg > } > } else { > # process missing image > } > } else { > # process missing query string parameter > } > > This is all prediated on the idea that something is calling your > imageDetail.php script with the source path for the image in question. If > that is not the case, and you need to in fact query the database for the > source path of the image, then you need to do a database query. > > Not knowing anything about how your database is set up, I'll take a stab > at a generic method of doing it. > > Somehow, imageDetail.php needs to know what image to get. Let's assume > you are calling it from a gallery that has several images displayed. Part > of the information needed is some what to identify the image's record in > the database. Let's assume you have images stored with an id, that is not > null and autoincrements when you store a new image. Here's a sample > schema: > > CREATE TABLE `photos` ( > `id` INT AUTO_INCREMENT NOT NULL, > `src` VARCHAR(255) NOT NULL, > `created` TIMESTAMP NOT NULL DEFAULT 0, > `updated` TIMESTAMP NOT NULL DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP > PRIMARY KEY (`id`) > ); > > Of course, you would probably want to store a lot more info about an > image, but this will do for explanation. > > Let's say you have a gallery shown at your application's index.php > program. In the html it generates, you may have something like this for > any particular thumbnail: > > > > > This is making some assumptions: > * you have image thumbnails for each image stored in the subdirectory > thumbs/ > * you've figured out somehow that the id for thumbs/imageABC.jpg is 25 > > When the user clicks on the image, they get taken to your imageDetail.php > script, with the query string paramter id set to 25. > > In PHP you would then do: > > if (isset($_GET['id'] && (!empty($_GET['id'] && is_numeric($_GET['id']) { > $id = $_GET['id']; > $sql = "SELECT * FROM `photos` WHERE id=".$id." LIMIT 1"; > $result = mysql_query($sql,$db); > if ($result) { > $imagedata = mysql_fetch_array($result,MYSQL_ASSOC); > $src = $imagedata['src']; > if (isset($src) && !empty($src) && fileexists($src)) { > $image = imagecreatefromjpeg($src); > > # do stuff with image > > } else { > > # handle invalid src data > > } > } else { > > # handle error from query > > } > } else { > > # handle invalid id paramter on script > > } > > > Note: some people like to handle error conditions before moving on to > working with the successful state. It's a matter of style. Either works. > > Hope this helps. > > Tamara > Tamara Thanks for your reply. The image is already called, (and if you read the response I posted to tedd, you'll see I am now not sure how it is). I also posted the code that calls the image if that sheds any light. I am digesting all the information to get it to work, if any of the code changes your answer, I would love to hear it! Thank you again. Gary __ Information from ESET Smart Security, version of virus signature database 5576 (20101029) __ The message was checked by ESET Smart Security. http
Re: [PHP] Watermark with GD
At 10:31 AM -0400 10/30/10, Gary wrote: I was under the impression that the image is stored in a folder called images, in fact the images file do go in, however I have the DB set up for longblob, averaging about 20kb each, so now I am unsure. I exported the sql so perhaps you can tell me. Gary: Impressions don't cut it -- you should *know* if the actual images are in the file system or in the database. Find that out before we can proceed. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Watermark with GD
"tedd" wrote in message news:p06240804c8f1eaf38...@[192.168.1.2]... > At 10:31 AM -0400 10/30/10, Gary wrote: >> >>I was under the impression that the image is stored in a folder called >>images, in fact the images file do go in, however I have the DB set up for >>longblob, averaging about 20kb each, so now I am unsure. I exported the >>sql >>so perhaps you can tell me. > > Gary: > > Impressions don't cut it -- you should *know* if the actual images are in > the file system or in the database. Find that out before we can proceed. > > Cheers, > > tedd > > > -- > --- > http://sperling.com/ tedd The images do go into the images folder, what I am now unclear about is where they are being called from. Gary __ Information from ESET Smart Security, version of virus signature database 5576 (20101029) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Watermark with GD
On Sat, 2010-10-30 at 11:50 -0400, Gary wrote: > "tedd" wrote in message > news:p06240804c8f1eaf38...@[192.168.1.2]... > > At 10:31 AM -0400 10/30/10, Gary wrote: > >> > >>I was under the impression that the image is stored in a folder called > >>images, in fact the images file do go in, however I have the DB set up for > >>longblob, averaging about 20kb each, so now I am unsure. I exported the > >>sql > >>so perhaps you can tell me. > > > > Gary: > > > > Impressions don't cut it -- you should *know* if the actual images are in > > the file system or in the database. Find that out before we can proceed. > > > > Cheers, > > > > tedd > > > > > > -- > > --- > > http://sperling.com/ > > tedd > > The images do go into the images folder, what I am now unclear about is > where they are being called from. > > Gary > > > > __ Information from ESET Smart Security, version of virus signature > database 5576 (20101029) __ > > The message was checked by ESET Smart Security. > > http://www.eset.com > > > > > OK, what it looks like is that the path to your image file is being stored in the database, and you're outputting that path inside of an tag when you output the HTML. That's fine, and is the method I use all the time. Now, back to the original question. You want to overlay some text on it as a watermark? For that, you need to use the GD functions. First, use GD to load in the image. Note that the path you use to open the image here won't be the same as the one you have in the DB. That's because the one in the DB is the path that is available to web browsers to reference your image, which is uses relative to your web page. For example, if your page was at http://www.someplace.com/somefolder/page/php, and the image tag looked like the browser path to the images would be http://www.someplace.com/somefolder/image.jpg , but the script path to your image would be very different, such as one of the following: * c:\xampp\htdocs\websitename\somefolder\images\image.jpg (xampp on windows) * /var/www/html/websitename/somefolder/images/image.jpg (linux) * /srv/www/websitename/somefolder/images/image.jpg (linux) * /home/websitename/somefolder/images/image.jpg (linux) Those are only examples, and may not necessarily be the exact setup you have on your server, you should find out exactly what the server is running. You can also reference it via a relative path, which is relative to the PHP script. With GD, you can either save a duplicate of the image with the watermark on, with a useful name such as watermark_image.jpg, or you can output it directly with the proper headers. If you do choose the latter route, you should ideally make a separate image script for making the watermark image, and in your image tag, call it with something like: The id can be whatever id you've got for the image in your database, and then in your image.php script, make the DB call that grabs the information for that image, and create the watermark. Just remember to make sure you send the right headers or your image won't show! Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Watermark with GD
On Oct 30, 2010, at 9:31 AM, Gary wrote: "tedd" wrote in message news:p06240800c8f1d19b9...@[192.168.1.2]... At 3:05 PM -0400 10/29/10, Gary wrote: I am trying to get the watermark to work, however I am having a problem in that the image is being called from a database (image sits in images file). The script in question is this $image = imagecreatefromjpeg($_GET['src']); However it produces an error message of Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: Filename cannot be empty in /home/content/a/l/i/alinde52/html/ imagesDetail.php on line 233 I have tried various methods, for example: ($_GET ['images/'] or ($_GET ['images/$row_WADAimages["image_id"]]. Can anyone shed some light on this for me. Thank you Gary Gary: Several things. 1. Getting an image from a database? You mean that you are getting the path of the image in the file system, right? Side note: You could place the image inside the database using a BLOB and do away with the path all together. That has the benefit of being portable -- you simply move the database to where ever you want it. The downside is that the database becomes very large, but no more so that the file system. There are pro's and con's in storing actual images in a database. 2. Using a GET is not the way to get the path. Instead, you have to retrieve the path from the database table where the path is stored -- and that requires a MySQL query similar to "SELECT * FROM WHERE id=". There are lot's of examples of how to pull data from a database. 3. After getting the path, then you can create the watermark like so: http://webbytedd.com/b/watermark/ Hope this helps, tedd -- --- http://sperling.com/ tedd Thank you for your reply. I was under the impression that the image is stored in a folder called images, in fact the images file do go in, however I have the DB set up for longblob, averaging about 20kb each, so now I am unsure. I exported the sql so perhaps you can tell me. Table structure for table `images` -- CREATE TABLE IF NOT EXISTS `images` ( `image_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `caption` varchar(50) NOT NULL, `wheretaken` varchar(100) NOT NULL, `description` text NOT NULL, `file_name` varchar(25) NOT NULL, `image_file` longblob NOT NULL, `submitted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`image_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1447 ; When I call the images, which works fine, I do need to specify the path that leads to the images folder. Am I being redundant in this structure. This is the script that I use to call the images. I have pulled out some of the html that styles the data. 0) { // Show if recordset not empty ?> src="images/" " Thank you for your help. Gary is this the imageDetail.php script? From what it appears in the code, `image_file` is holding the file name rather than the actual image. Yet you have `image_file` defined as a longblob, which would make sense if you were storing the actual image data in the data base rather than on the file system. As Ashley noted, you can do it either way. I notice you also have a field `file_name` -- what is this used for? It sounds like your design is a bit off -- neither one way or the other. The php shown doesn't look complete enough, though -- where is the img tag and such? Also, going in and out of php on each line is kind of a waste and looks sloppy. If i read that code right, it would emit something like this: caption text src="images/pathtoimagefile" description text where taken text description text Look at the html that's emitted from the script and see if that's what you get. Can you post or pastebin more of the .php script so I can see more of what is going on? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] questions about if statements regarding a checkbox
hello, I'd like to know the proper code to use in a php script that processes a form with a checkbox in order to send one email if the checkbox has been checked and another email if the checkbox hasn't. I tried if($check == true) and I tried putting the word "true" in double quotes, and both of them caused the "unexpected variable" syntax error. The only problem is, all I could think to use was that line of code I just used, I'm not sure what the proper syntax is for checkbox when using the if statement to send one email when the checkbox is checked and a different email when it's not checked. I'm wanting to send an email to the site admin with the information given by the person who filled out the form that contains the checkbox. Thanks, Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about if statements regarding a checkbox
On Sat, Oct 30, 2010 at 10:05 PM, Ben Brentlinger wrote: > hello, > > I'd like to know the proper code to use in a php script that processes a > form with a checkbox in order to send one email if the checkbox has been > checked and another email if the checkbox hasn't. I tried if($check == > true) and I tried putting the word "true" in double quotes, and both of them > caused the "unexpected variable" syntax error. The only problem is, all I > could think to use was that line of code I just used, I'm not sure what the > proper syntax is for checkbox when using the if statement to send one email > when the checkbox is checked and a different email when it's not checked. > I'm wanting to send an email to the site admin with the information given > by the person who filled out the form that contains the checkbox. > // checkboxes are only set if checked if (isset($_GET['checkbox_name'])) { // checkbox is checked, so send one mail mail($to = 'o...@email.com', $subject = 'Really cool email'); } else { // checkbox isn't checked, so send a different email mail($to = 'differ...@email.com', $subject = 'Just as cool email'); } Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] questions about if statements regarding a checkbox
If check it will submit the value of 'on' So If($_POST['test'] == "on') { Do this }else{ Do this } Richard L. Buskirk -Original Message- From: Ben Brentlinger [mailto:b...@benbrent.com] Sent: Saturday, October 30, 2010 10:05 PM To: php-general@lists.php.net Subject: [PHP] questions about if statements regarding a checkbox hello, I'd like to know the proper code to use in a php script that processes a form with a checkbox in order to send one email if the checkbox has been checked and another email if the checkbox hasn't. I tried if($check == true) and I tried putting the word "true" in double quotes, and both of them caused the "unexpected variable" syntax error. The only problem is, all I could think to use was that line of code I just used, I'm not sure what the proper syntax is for checkbox when using the if statement to send one email when the checkbox is checked and a different email when it's not checked. I'm wanting to send an email to the site admin with the information given by the person who filled out the form that contains the checkbox. Thanks, Ben -- 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
Re: [PHP] questions about if statements regarding a checkbox
On 2010-10-30, at 10:28 PM, wrote: > > > > > If check it will submit the value of 'on' > > So > > If($_POST['test'] == "on') > { > Do this > }else{ > Do this > } > > > Richard L. Buskirk > > > -Original Message- > From: Ben Brentlinger [mailto:b...@benbrent.com] > Sent: Saturday, October 30, 2010 10:05 PM > To: php-general@lists.php.net > Subject: [PHP] questions about if statements regarding a checkbox > > hello, > > I'd like to know the proper code to use in a php script that processes a > form with a checkbox in order to send one email if the checkbox has been > checked and another email if the checkbox hasn't. I tried if($check == > true) and I tried putting the word "true" in double quotes, and both of > them caused the "unexpected variable" syntax error. The only problem > is, all I could think to use was that line of code I just used, I'm not > sure what the proper syntax is for checkbox when using the if statement > to send one email when the checkbox is checked and a different email > when it's not checked. I'm wanting to send an email to the site admin > with the information given by the person who filled out the form that > contains the checkbox. > > > Thanks, > > Ben > > -- > 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 > http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] include html
Hello, I am looking for a solution to inject some dynamic html into an iframe and rework the css from the results. Is there a way to do this in PHP? I am not talking about just using the src attribute of the iframe either. Basically, I want to call on a web page, grab the html code, replace the tag with my own and insert it into an iframe on my page. I am sure this is not as complicated as I am making it, but I have been trying with Ajax for the past couple of days and no luck. So I was wondering if there was a php alternative to do this with. Or if it is even possible or ok to do so. I am building a website for a tshirt company that uses another company to get garments and promo items to print on. The client wants to just have those pages load on top of their website, but wants the layout to go with their look and feel. their css. We have the go ahead from the other companies to do so as well. TIA, Karl DeSaulniers Design Drumm http://designdrumm.com
Re: [PHP] questions about if statements regarding a checkbox
I tried that, but I'm getting the syntax error that says "unexpected T_IF". Probably because I'm trying to process this information directly in an email rather letting a mysql database handle the data, which I find harder to set up when writing a script from scratch than it would be to code a php script to send the data in an email. On 10/30/2010 22:28, ad...@buskirkgraphics.com wrote: If check it will submit the value of 'on' So If($_POST['test'] == "on') { Do this }else{ Do this } Richard L. Buskirk -Original Message- From: Ben Brentlinger [mailto:b...@benbrent.com] Sent: Saturday, October 30, 2010 10:05 PM To: php-general@lists.php.net Subject: [PHP] questions about if statements regarding a checkbox hello, I'd like to know the proper code to use in a php script that processes a form with a checkbox in order to send one email if the checkbox has been checked and another email if the checkbox hasn't. I tried if($check == true) and I tried putting the word "true" in double quotes, and both of them caused the "unexpected variable" syntax error. The only problem is, all I could think to use was that line of code I just used, I'm not sure what the proper syntax is for checkbox when using the if statement to send one email when the checkbox is checked and a different email when it's not checked. I'm wanting to send an email to the site admin with the information given by the person who filled out the form that contains the checkbox. Thanks, Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] search is not case insensitive
Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = "SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C". "WHERE A.id = B.user_id AND B.appointment_id = C.id ". "AND LOWER(C.description) LIKE '%".strtolower($search_for)."%' AND C.start_time > $start_time AND C.start_time < $end_time ORDER BY C.start_time"; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php