php_begins
-
Posts
259 -
Joined
-
Last visited
Posts posted by php_begins
-
-
i need to convert the following path
$url=http://www.test.com/images/1/7/4/7/9/thumb.jpg
to
$updated_url= /home/vhosts/test.com/httpdocs/images/1/7/4/7/9/thumb.jpg
The directories in the url are created dynamically
Right now what i am doin is
$updated_url='/home/vhosts/'.$url.'/httpdocs/images/'.basename($url)
which gives me /home/vhosts/test.com/httpdocs/images/thumb.
But I also need to get the directories 1/7/4/7/9. It may be differ for different urls.
Can this be done through some form of string replacement or pattern matching method?
-
Thank you,Sorry for creating all the confusion..
-
I am still struggling a bit..here's what i tried.
<script type="text/javascript" language="javascript"> function dump() { document.getElementById('debug').innerHTML = document.innerHTML; } </script> <form action="#" name="form1"> <fieldset><legend>form</legend> <textarea rows="10" cols="20" name="textarea1" id="debug"> </textarea> <button type="button" onclick="dump()">Get CODE</button> </fieldset> </form>
-
I even tried this:
<script type="text/javascript" language="javascript"> function dump() { document.getElementById('debug').value = document.innerHTML; } </script> <textarea id='debug'></textarea>
-
I am still not able to get the html code of the current page..i am having some trouble in calling the javascript part. Is this correct.
<textarea id='code'><script type='text/javascript'>document.getElementById('code').innerHTML = document.documentElement.innerHTML;</script></textarea>
-
I have used the below function to crop and create the thumbnail, so that it doesn't look distorted.
function CroppedThumbnail($source_image_name,$destination_image_name,$specified_width,$specified_height) { $system=explode(".",$source_image_name); list($old_width, $old_height) = getimagesize($source_image_name); $ratio_orig = $old_width/$old_height; $fp = fopen($source_image_name, 'rb'); $buf = ''; while(!feof($fp)) { $buf .= fgets($fp, 4096); } fclose($fp); $myImage=imagecreatefromstring($buf); if($old_width < $specified_width && $old_height < $specified_height) { $dst_img=ImageCreateTrueColor($old_width,$old_height); imagecopyresampled($dst_img,$myImage,0,0,0,0,$old_width,$old_height,$old_width,$old_height); if (preg_match("/png/",$system[1])) { imagepng($dst_img,$destination_image_name); } else { imagejpeg($dst_img,$destination_image_name); } imagedestroy($dst_img); imagedestroy($myImage); } else { //In this section we will actually resize and crop it. if($specified_width/$specified_height > $ratio_orig) { $new_height = $specified_width/$ratio_orig; $new_width = $specified_width; } else { $new_width = $specified_height*$ratio_orig; $new_height = $specified_height; } $x_mid = $new_width/2; //horizontal middle $y_mid = $new_height/2; //vertical middle $bgcolor = imagecolorallocate($process, 255, 255, 255); imagefill($process, 0, 0, $bgcolor); $process = imagecreatetruecolor(round($new_width), round($new_height)); imagecopyresampled($process, $myImage, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height); $thumb = imagecreatetruecolor($specified_width, $specified_height); $bgcolor = imagecolorallocate($thumb, 255, 255, 255); imagefill($thumb, 0, 0, $bgcolor); imagecopyresampled($thumb, $process, 0, 0, ($x_mid-($specified_width/2)), ($y_mid-($specified_height/2)), $specified_width, $specified_height, $specified_width, $specified_height); if(preg_match("/png/",$system[1])) { imagepng($thumb,$destination_image_name); } else { imagejpeg($thumb,$destination_image_name); } imagedestroy($process); imagedestroy($myImage); } }
-
The quality of the image is still pretty poor. There is still distortion.
-
ok I finished copying the url image to my directory and applied the image_resize function to create the thumbnail.
First of all,it does not work according to the dimensions i give.For example, 80X80 gives me 80X66 thumbnail.
Secondly, the image gets distorted(stretched at times).
Is it possible to retain the original quality of image like how facebook does in its thumbnails.
Here is my resize function:
<? function img_resize($name,$filename,$new_w,$new_h) { $system=explode(".",$name); if (preg_match("/jpg|jpeg/",$system[1])){$src_img=imagecreatefromjpeg($name);} if (preg_match("/png/",$system[1])){$src_img=imagecreatefrompng($name);} if (preg_match("/gif/",$system[1])){$src_img=imagecreatefromgif($name);} $old_x=imageSX($src_img); $old_y=imageSY($src_img); if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); if (preg_match("/png/",$system[1])) { imagepng($dst_img,$filename); } elseif (preg_match("/gif/",$system[1])) { imagegif($dst_img,$filename); } else { imagejpeg($dst_img,$filename); } } ?>
I call it like this:
img_resize('images/'.$thumbnail_review_1,'images/thumb_'.$thumbnail_review_1,80,80);
-
ok I shall try using PHP GD. Thanks for your responses..
-
Thanks Andy and MJ...it took some time for me to grasp that issue..I have understood the concept now.
-
thanks for the suggestions.
I would like to go with the first option. I am having trouble copying them to my server and then applying some resize function to create the thumbnail. The tutorials I found in the net are somewhat complicated and not straightforward.
-
I have a form where you can enter a image url and it's title. It calls display.php which displays the image as well as the title.
But I want the image to be displayed as a thumbnail of size 150X100.
Do i have to store it in directory before I convert it and display? If so, can somebody tell me how to convert the image into a thumbnail?
Here is my code:
<table align="center" bgcolor="silver"> <form action="display.php" method ="post"> <tr> <td align="center"><b><font color="#214754" size="3">Reg</font></b></td> </tr> <tr> <td> Title: </td> <td><input type="text" size ="40" name="registry_title1" /></td> </tr> <tr> <td> Image URL: </td> <td><input type="text" size ="40" name="registry_img1" /></td> </tr> <tr> <td> <input type="submit" name="submit" value="submit" /> </td> </tr> </form> </table> </div>
here is the code for display.php
<? /* Get Registry details */ $registry_img1=$_POST['registry_img1']; $registry_title1=stripslashes($_POST['registry_title1']); ?> <html> <body> <table width='600' cellspacing='0' cellpadding='0' border='0' bgcolor='#ffffff' align='center'> <tr> <td style='padding-bottom:8px';><font style='font-size:18px;color:rgb(0, 0, 0);text-decoration:none'><a style='font-size:18px;color:rgb(0, 0, 0);text-decoration:none' href='#'><? echo ucfirst($url); ?> Registry</font></a></td> </tr> <tr> <td style='padding-bottom:10px;'> <a style='color:rgb(206, 0, 0);font-size:14px;font-weight:bold;line-height:18px;text-decoration:none' href='<? echo $registry_url1; ?>' target='_blank'><img style='padding-right:10px' border='0' align='left' alt='' src='<? echo $registry_img1; ?>'><? echo $registry_title1;?> </a> </td> </table> </body> </html>
-
To escape the single apostrophe's the php addslashes() function should work right? But while displaying it in my email, I would still the apostrophes to be shown.
-
sorry, I meant $content_html will dynamically generate the html source code which I am putting in the $body variable.
for example,
$content_html='<html><body><font size="1"> We're sending this email.It's been a while</font></body></html>';
How do i escape the apostrophe in that variable dynamically(since the html source is huge..it could contain many apostrophes)
And when I receive the email i would need the apostrophes to be there..
-
thanks,how do I escape it if i dynamically receive the html content.
for example,
$body=$content_html;
When the email is received I would like to have the apostrophes displayed.
-
I need to send emails with single apostrophes in the body of my email function. How do I do that without erroring out in my mail function.
<? $to = "myself@gmail.com"; $subject = "test"; $body='<html><body><font size="1"> We're sending this email.It's been a while</font></body></html>'; $message=$total; $from = "webmaster@example.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Admin <Admin@test.com>' . "\r\n"; // Send email if(mail($to,$subject,$body,$headers)) { // Inform the user echo "Your email has been sent"; } else { echo "MAIL not sent"; } ?>
-
hmmm..how do i test a 'email friendly mail' that is compatible... I do not know where to start from..
-
Hi, I need to send a html image as an email to people. Here is the link http://cs.txstate.edu/~sr1388/Test/..
When I send I send the email by copying the source code(from view source) of that page, everything looks the same except for the fact the registry and review tables dont get aligned side by side . I cannot find what issue is causing it.
This is what my email function looks like:
<? $content='view-source code here'; echo $content; $to = "me@gmail.com"; $subject = "test"; $body=$content; //$body="hello"; //$message=$total; $from = "webmaster@example.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; //$headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n"; $headers .= 'From: Admin <Admin@mysite.com>' . "\r\n"; // Send email if(mail($to,$subject,$body,$headers)) { // Inform the user echo "Your email has been sent"; } else { echo "MAIL not sent"; } ?>
-
Then if you have to use tables, it sounds like nested tables is about your only option, right?
<table border="1"> <tr> <td> <table border="1"> <tr> <td>First nested table</td> </tr> </table> </td> <td> <table border="1"> <tr> <td>Second nested table</td> </tr> </table> </td> </tr> </table>
Thanks Pikachu2000, that worked great!
-
How can CSS possibly interfere with a mail function? The two aren't in any way related.
What I meant was the whole code would go inside the body of a mail function and would be sent to different email addresses . I do not want css inside the body of the mail functiom since some email clients do not receive css very well.
Therefore it would be suitable in this case to have only html elements inside the code.
-
I have 4 tables in my code. i need 2 tables each aligned next to each other without using any kind of css(No css because it creates a problem with my mail function).
Here is my code below.
I need the first table aligned next to the second table , the third table aligned next to fourth table.
<table width="600" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff" align="center" > <tr> <td>Popular Features </td> </tr> <tr height="25"> <td height="25" bgcolor="#f5f5f5"><font color="#ce0000"> » </font><a href="www.test.com" target="_blank">Title 1</a> </td> </tr> <tr height="25"> <td height="25"><font color="#ce0000"> » </font><a href="www.test.com" target="_blank">Title 2</a> </td> </tr> <tr height="25"> <td height="25" bgcolor="#f5f5f5"><font color="#ce0000">» </font><a href="www.test.com" target="_blank">Title 3</a> </td> </tr> <tr height="25"> <td height="25"><font color="#ce0000">» </font><a href="www.test.com" target="_blank">Title 4</a> </td> </tr> <tr height="25"> <td height="25" bgcolor="#f5f5f5"><font color="#ce0000">» </font><a href="www.test.com" target="_blank">Title 5 </a> </td> </tr> <tr height="25"> <td height="25"><font color="#ce0000">» </font><a href="www.test.com" target="_blank">Title 6</a> </td> </tr> </table> <table width="600" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff" align="center"> <td width="300"><a href="http://blast.verticalscope.com/oi3-vs/scripts/script.php?id=12536&uid=2381352&messageId=1690&mid=2639" target="_blank"><img width="300" height="250" border="0" align="middle" alt="" src="http://img.verticalscope.com/atv.com/newsletters/images/09072011/Kawasaki-300x250.jpg"></a> </td> </table> <table width="600" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff" align="center"> <tr> <td>Reviews</tr> </td> </tr> <tr> <td> <a href="http://t0.gstatic.com/images?q=tbn:ANd9GcSgfnlqd9YfSAZ73KbO6p4jzScBCwFCBTWvLjyepmfTF-jYVokI" target="_blank"><img border="0" align="left" alt="" src="http://t0.gstatic.com/images?q=tbn:ANd9GcSgfnlqd9YfSAZ73KbO6p4jzScBCwFCBTWvLjyepmfTF-jYVokI">F1 </a> </td> </tr> <tr> <td> <a href="http://t0.gstatic.com/images?q=tbn:ANd9GcSgfnlqd9YfSAZ73KbO6p4jzScBCwFCBTWvLjyepmfTF-jYVokI" target="_blank"><img border="0" align="left" alt="" src="http://t0.gstatic.com/images?q=tbn:ANd9GcSgfnlqd9YfSAZ73KbO6p4jzScBCwFCBTWvLjyepmfTF-jYVokI">F2 </a> </td> </tr> </table> <table width="600" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff" align="center"> <tr> <td>Registry</tr></td> </tr> <tr> <td> <a href="http://t1.gstatic.com/images?q=tbn:ANd9GcQiYqLEBA3H4giuf4HbigPqpOiAMMivFF-Xy838nGacOBjntovCHQ" target="_blank"><img border="0" align="left" alt="" src="http://t1.gstatic.com/images?q=tbn:ANd9GcQiYqLEBA3H4giuf4HbigPqpOiAMMivFF-Xy838nGacOBjntovCHQ">L1 </a> </td> </tr> <tr> <td> <a href="http://t1.gstatic.com/images?q=tbn:ANd9GcQiYqLEBA3H4giuf4HbigPqpOiAMMivFF-Xy838nGacOBjntovCHQ" target="_blank"><img border="0" align="left" alt="" src="http://t1.gstatic.com/images?q=tbn:ANd9GcQiYqLEBA3H4giuf4HbigPqpOiAMMivFF-Xy838nGacOBjntovCHQ">L2 </a> </td> </tr> </table>
I have tried nesting of tables. Also if i reduce the width of table, the table gets aligned to the right.Could someone help me out with the code.
You can find the example at
http://cs.txstate.edu/~sr1388/Test/
-
well i am sending it to my email address..i just didnt want to display my email address here :-)
-
Hi I am having trouble sending emails with html content.
My $content variable is defined as follows:
$content='<html><body> lots of html data with tables and rows here </body></html>';
But when I execute the code, it says 'Mail sent', but I do not get any email.
if i just define $body="hello", it sends me the email.
Here is my code to send the email
<? $to = "test@gmail.com"; $subject = "test"; $body=$content; $from = "webmaster@example.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Admin <Admin@test.com>' . "\r\n"; // Send email if(mail($to,$subject,$body,$headers)) { // Inform the user echo "Your email has been sent"; } else { echo "MAIL not sent"; } ?>
-
Again, stop confusing PHP with HTML. PHP is a language that generates (for the most part) text output. PHP can be used to generate novels, emails, invoices, OR html documents. PHP doesn't care what it's generating and whatever is generated doesn't care that PHP was involved.well the page is called display.php..so whatever code is on that page(php or html) needs to be converted into html(like view source) and be displayed in a textarea field...
You are not at all interested in the PHP side of this equation. At all. Really, you're not. This is entirely an html/javascript question.
document.getElementById('idOfYourTextAreaHere').innerHTML = document.documentElement.innerHTML;
That's all you have to do. Run that javascript at the bottom of the page (or put it into a button) and as long as you have a textarea on the page with the proper ID then it will be filled with the page's entire content (minus the <html> and </html> tags and any doctype declarations).
I don't know why you need this rather than the "view source" that everyone else uses, but there's the solution.
-Dan
Thanks, sometimes you have to do what your boss tells you to do...so i m breaking my head over trying to do this with javascript(unfamiliar territory for me)
handle single quotes in select statement
in PHP Coding Help
Posted
how do i handle single quotes in sql query
this returns an error because the name contains single quotes like this:
Johnson's.