PHP - Imagettftext() Failure
I'm writing a Dynamic image, that display's a user's Name, but for some reason, the kills stat won't print. I made a .php file using the same parsing method, but using echo, and it worked fine. I also know it's not an issue with X,Y, Size, float, anything like that because I tried replacing "$kill" with "Test," and it printed fine.
Here is the actual image: And here is the code for it: <?php Header ('Content-type: image/jpeg'); Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT'); Header('Pragma: no-cache'); // get CMID variable from the url $cmid = $_GET['cmid']; // create the image using your own background $image = imagecreatefromjpeg("background.jpg"); // dimensions of the image used $img_width = 600; $img_height = 9; // set the colours $cool = imagecolorallocate($image, 81, 86, 96); $black = imagecolorallocate($image, 0, 0, 0); $white = imagecolorallocate($image, 255, 255, 255); $red = imagecolorallocate($image, 255, 0, 0); $grey = imagecolorallocate($image, 204, 204, 204); $green = imagecolorallocate($image, 206, 129, 18); $blue = imagecolorallocate($image, 0, 0, 255); $yellow = imagecolorallocate($image, 225, 225, 0); // set the font and print text $font = 'Verdana.ttf'; /* // counter - CHMOD your counter file to 777 $viewss = file("views.txt"); $views = $viewss[0]; $views++; $fp = fopen("views.txt", "w"); fwrite($fp, $views); fclose($fp); $counter = "$views"; // View Output imagettftext($image, 7, 0, 16, 117, $yellow, $font, "Views:$counter"); */ // Attempt to make web content grabber. function get_url_contents($url){ $crl = curl_init(); $timeout = 5; curl_setopt ($crl, CURLOPT_URL,$url); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); $ret = curl_exec($crl); curl_close($crl); return $ret; } // Web content grabber execution. $returned_content = get_url_contents('http://uberstrike.cmune.com/Profile?cmid=' . $cmid); // Parsing the returned content for Clan Tag. $namestart = strpos($returned_content, '<span style="color: #FEC42C; font-size: 20px; font-weight: bold;">'); $nameend = strpos($returned_content, '</span>', $namestart); $name = substr($returned_content, $namestart, $nameend-$namestart); // Stripping the parsed Clan Tag of HTML elements. $name = html_entity_decode(strip_tags($name)); // Clan and name output. imagettftext($image, 7, 0, 53, 7, $yellow, $font, "$name"); // Parsing the returned content for Global Rank. $rankstart = strpos($returned_content, '<h2 style="font-size:14px; font-weight:bold; text-indent:0px; margin-left:25px;">'); $rankend = strpos($returned_content, '<br />', $rankstart); $rank = substr($returned_content, $rankstart, $rankend-$rankstart); // Stripping the parsed Global Rank of HTML. $rank = html_entity_decode(strip_tags($rank)); // Filtering Rank to only show the value number, not text or formatting in between. $rank = str_replace ("G", "", $rank); $rank = str_replace ("l", "", $rank); $rank = str_replace ("o", "", $rank); $rank = str_replace ("b", "", $rank); $rank = str_replace ("a", "", $rank); $rank = str_replace ("R", "", $rank); $rank = str_replace ("n", "", $rank); $rank = str_replace ("k", "", $rank); $rank = str_replace (":", "", $rank); $rank = str_replace (" ", "", $rank); // Rank Output. imagettftext($image, 7, 0, 220, 7, $yellow, $font, "$rank"); $killstart = strpos($returned_content, '<h3 style="color: #FEC42C;">All time record</h3>'); $killend = strpos($returned_content, '</tr>', $killstart); $kill = substr($returned_content, $killstart, $killend-$killstart); // Stripping the parsed kill of HTML. $kill = html_entity_decode(strip_tags($kill)); // Filtering kill to only show the value number, not text or formatting in between. $kill = str_replace ("K", "", $kill); $kill = str_replace ("i", "", $kill); $kill = str_replace ("l", "", $kill); $kill = str_replace ("A", "", $kill); $kill = str_replace ("t", "", $kill); $kill = str_replace ("m", "", $kill); $kill = str_replace ("e", "", $kill); $kill = str_replace ("r", "", $kill); $kill = str_replace ("o", "", $kill); $kill = str_replace ("d", "", $kill); $kill = str_replace ("c", "", $kill); $kill = str_replace ("s", "", $kill); $kill = str_replace (" ", "", $kill); // Kill Stats output. imagettftext($image, 7, 0, 410, 7, $yellow, $font, "$kill"); // IP Logger $logfile= 'iplog.html'; $IPlog = $_SERVER['REMOTE_ADDR']; $logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://www.ip2location.com/demo.aspx?ip='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a>'; $fplog = fopen($logfile, "a"); fwrite($fplog, $logdetails); fwrite($fplog, "<br>"); fclose($fplog); // output and destroy imagepng($image); imagedestroy($image); ?> I tried using the same parsing code for the $kill stat, and it works fine: http://dynfosig.com/Phoenix_uploads/clangadget/Test.php?cmid=563853 <?php // get CMID variable from the url $cmid = $_GET['cmid']; function get_url_contents($url){ $crl = curl_init(); $timeout = 5; curl_setopt ($crl, CURLOPT_URL,$url); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); $ret = curl_exec($crl); curl_close($crl); return $ret; } $returned_content = get_url_contents('http://uberstrike.cmune.com/Profile?cmid=' . $cmid); $killstart = strpos($returned_content, '<h3 style="color: #FEC42C;">All time record</h3>'); $killend = strpos($returned_content, '</tr>', $killstart); $kill = substr($returned_content, $killstart, $killend-$killstart); // Stripping the parsed kill of HTML. $kill = html_entity_decode(strip_tags($kill)); // Filtering kill to only show the value number, not text or formatting in between. $kill = str_replace ("K", "", $kill); $kill = str_replace ("i", "", $kill); $kill = str_replace ("l", "", $kill); $kill = str_replace ("A", "", $kill); $kill = str_replace ("t", "", $kill); $kill = str_replace ("m", "", $kill); $kill = str_replace ("e", "", $kill); $kill = str_replace ("r", "", $kill); $kill = str_replace ("o", "", $kill); $kill = str_replace ("d", "", $kill); $kill = str_replace ("c", "", $kill); $kill = str_replace ("s", "", $kill); $kill = str_replace (" ", "", $kill); // Kill Stats output. echo $kill; ?> * Moderator Note: Please do not remove code snippets from the question. Similar TutorialsHi, I have a small code to display some data from mysql db as .png image, however the image loads but it doesn't show any data on it. php: <? $username=""; $password=""; $database=""; $host=""; $player_name=$_GET['player_name']; mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database. Be sure the databasename exists and online is."); $player_name = stripslashes($player_name); $player_name = mysql_real_escape_string($player_name); $query="SELECT * FROM characters WHERE name='$player_name'"; $result=mysql_query($query); $i=mysql_num_rows($result); if ($i == 1) { $name=mysql_result($result,0,"name"); $OnServer=mysql_result($result,0,"OnServer"); $hours=mysql_result($result,0,"hours"); header('Content-Type: image/png;'); $im = @imagecreatefrompng('1.png') or die("Cannot select the correct image. Please contact the webmaster."); $text_color = imagecolorallocate($im, 197,197,199); $text_username = "$name"; $text_hours = "$hours"; $text_online = "$OnServer"; $font = 'visitor2.ttf'; imagettftext($im, 2, 0, 39, 15, $text_color, $font, $text_username); imagettftext($im, 2, 0, 160, 15, $text_color, $font, $text_hours); imagettftext($im, 2, 0, 297, 15, $text_color, $font, $text_online); imagepng($im); imagedestroy($im); } else echo('Username is not in our database. Please try again.'); mysql_close(); ?> html: Code: [Select] <html> <head> <title>My title here</title> </head> <h1>Signature configuration.</h1> <p>Hello and welcome to the image configuration page.<br /> Before you can make your signature, we need in-game name, exact as it is.</p> <form action="signature.php" method="get"> Playername: <input type="Submit"> </form> </body> </html> sql dump: http://pastebin.com/zXHgCDpt Any ideas? (it's 6am in here so I probably missed something obvious, sorry about that) <? $username="root"; //Your MySQL Username. $password="pass"; // Your MySQL Pass. $database="clan"; // Your MySQL database. $host="127.0.0.1"; // Your MySQL host. This is "localhost" or the IP specified by your hosting company. $player_name=$_GET['player_name']; // This gets the player his name from the previous page. /* Next, we will make a connection to the mysql. If it can't connect, it'll print on the screen: Unable to select database. Be sure the databasename exists and online is. */ mysql_connect($host,$username,$password); // Connection to the database. @mysql_select_db($database) or die( "Unable to select database. Be sure the databasename exists and online is."); //Selection of the database. If it can't read the database, it'll give an error. /* To protect MySQL injection. */ $player_name = stripslashes($player_name); $player_name = mysql_real_escape_string($player_name); $query="SELECT * FROM `playerdata` WHERE user = '$player_name' LIMIT 1"; // Gets all the information about the player. $result=mysql_query($query); $i=mysql_num_rows($result); // Here we are counting how many rows this result gives us. /* We will now put the player's information into variables so we can use them more easily. */ /* DON'T FORGET: The names should be exact the same as in your mysql db.*/ if ($i == 1) // If the user has been correct, then it'll give us 1 row. If its 1 row, then it'll proceed with the code. { $Playername=mysql_result($result,0,"user"); // Gets the username of the player and put it in the variable $Playername. $Money=mysql_result($result,0,"kills"); // Gets the money of the player and put it in the variable $Money. $Score=mysql_result($result,0,"deaths"); // Gets the score of the player and put it in the variable $Score. // Creating of the .png image. header('Content-Type: image/png;'); $im = @imagecreatefrompng('mypicture.png') or die("Cannot select the correct image. Please contact the webmaster."); // Don't forget to put your picture there. $text_color = imagecolorallocate($im, 197,197,199); // RED, GREEN, BLUE --> Go to www.colorpicker.com, select a nice color. Copy the R/G/B letters provided by colorpicker and put them here. $text_username = "$Playername"; // This gets the information about player name to be showed in the picture. $text_score = "$Score"; // Same as above ^^ $text_money = "$Money"; // Same as above ^^ $font = 'myfont.ttf'; //Upload your custum font to the directory where this file is placed. Then change the name here. /* USAGE OF THE imagettftext: First ($im) shouldn't be changed. (16) is the text-size. (0) is the angle of your text. Change it, and you'll see what's going on. (20) is de X-coordinate of the text. (36) is the Y-coordinate of the text. */ imagettftext($im, 16, 0, 20, 36, $text_color, $font, $text_username); // Prints the username in the picture. imagettftext($im, 16, 0, 72, 69, $text_color, $font, $text_score); // Prints the score in the picture. imagettftext($im, 16, 0, 72, 99, $text_color, $font, $text_money); // Prints the money in the picture. imagepng($im); imagedestroy($im); } else echo('Username is not in our database. Please try again.'); // If the username doesn't exist (so the row is 0) then it'll give en error. mysql_close(); ?> Imagettftext() - Just can't get it to work Hi ALL I'm trying to create a simple font tester. Imagettftext() looks perfect but I can't get it to work. I'm using this piece of code from php.net. Nothing is output and I get an error message in Firefox: The image "http://www.ttmt.org.uk/test/index.php" cannot be displayed because it contains errors. The font is available in the same location as the php file. http://www.ttmt.org.uk/test/index.php Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>untitled</title> </head> <body> <?php // Set the content-type header('Content-Type: image/png'); // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); // The text to draw $text = 'Testing...'; // Replace path by your own font path $font = 'corbelb.ttf'; // Add the text imagettftext($im, 20, 0, 10, 20, $black, $font, $text); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); ?> </body> </html> i have this code: $wap_image_filename = $wap_profile_pic."-wap.jpg"; $image =0; if($mimetype=='IMAGE/PNG') { $image = imagecreatefrompng($profile_pic); imagejpeg($image,$wap_image_filename , 100); } else if($mimetype=='IMAGE/JPG') { $image = imagecreatefromjpeg($profile_pic); imagejpeg($image,$wap_image_filename , 100); } //resize photo with 100% quality $this->resizeImage($profile_pic,$wap_image_filename,300,300,100); $filename = $wap_image_filename; $date_card_image = imagecreatetruecolor(400, 500); //$date_card_image gives resource id $bg_col = imagecolorallocate ( $date_card_image, 200, 200, 200 ); imagefill ( $date_card_image, 0, 0, $bg_col); $source = imagecreatefromjpeg($filename); //$source gives a resource id# list($ppwidth, $ppheight) = getimagesize($filename); // Resize imagecopyresized($date_card_image, $source , 0, 40, 0,0, 400, $ppheight, $ppwidth, $ppheight); $uc_color = ImageColorAllocate ($date_card_image,10, 10, 10); $info_color = ImageColorAllocate ($date_card_image,42, 134, 186); $white = imagecolorallocate($date_card_image, 255, 255, 255); $black = imagecolorallocate($date_card_image, 0, 0, 0); $blue = imagecolorallocate($date_card_image, 0, 0, 128); $font = '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansCondensed-Bold.ttf'; $text = $this->getUniqueCode(); // Add the text imagettftext($date_card_image, 24, 0, 55, 30, $blue, $font, $text); [COLOR="Red"]//get warning on this line 227[/COLOR] the warning i get is: Warning: imagettftext(): Could not find/open font in /home/helloises/traffic_2/phoenix/plugins/rainbowCodePlugin/lib/model/RcProfileTable.php on line 227 please can some one help me fix this? thank you Hello i have some code which is suppose to create a simple captcha image...the code was working fine until it was moved from one location to another...now what it does is the image is created...but for some reason, it's not displaying the text. Here is my code : Code: [Select] <?php session_start(); $image = imagecreate(100, 50); $background = imagecolorallocatealpha($image, 204, 204, 204, 127); $text = imagecolorallocate($image, 0, 0, 0); imagettftext($image, 20, 0, 30, 30, $text, 'Gabriola.ttf', $_SESSION['captcha']); $lines = 20; for($i = 0; $i <= $lines; $i++){ $x1 = rand(1, 100); $y1 = rand(1, 100); $x2 = rand(1, 100); $y2 = rand(1, 100); imageline($image, $x1, $y1, $x2, $y2, $text); } header('content-type: image/jpeg'); imagejpeg($image); ?> this code does create the gray box and displays the 20 lines but no text. when i echo out the $_SESSION['captcha'] on the page it displays the number generated (generated in another file)....i've even replaced that with a string and it doesn't work...the interesting thing about it is that it works on local machine but not on a hosted page...what could possibly cause this?...all the files were changed so the .ttf file is also within the same file as this page Hi All, I am getting this problem for one of my site that i am developing . When I insert special characters string like thi's ~!@#$%^&*()_+| the code is unable to convert it into right image with all text on it when the chosen font in trajanpro.ttf, but when I change the font with Ariel it work's fine. If anyone want to check this problem then you can check at this link http://www.centralstationery.com/produc ... ate_id=231 Click the text on card and a pop up will open and then change the font to Ariel then the image on card will be converted into right text. The code is imageSaveAlpha($image, true); ImageAlphaBlending($image, false); $bgcolor = imagecolorallocate($image, 200, 200, 200); $transparentColor = imagecolorallocatealpha($image, 200, 200, 200, 127); imagefill($image, 0, 0, $transparentColor); // pick color for the text $fontcolor = imagecolorallocate($image, $red, $grn, $blu); // fill in the background with the background color imagefilledrectangle($image, 0, 0, $width, $height, $transparentColor); $x = 0; $y = $fontsize; imagettftext($image, $fontsize, 0, $bx, $by, $fontcolor, $font, $quote); $final_image=DIR_USER_EDITOR.$new_image; // output image to the browser imagepng($image, $final_image); // delete the image resource imagedestroy($image); Thanks in advance Hi I'm creating a program that creates an image from an input using imagettftext(). Is there a way I can force a new line if the text exceeds the permitted image width? Thanks in advance Ste
I need to draw various font sizes onto a canvas to create a web service. Wanting to protect my HD assets, the intent is to use PHP to populate the image with the necessary text, and then scale down the image before presenting it to the user. <?php $img = imagecreatetruecolor(750, 530); $black = imagecolorallocate($img, 0, 0, 0); $gray = imagecolorallocate($img, 125, 125, 125); $white = imagecolorallocate($img, 255, 255, 255); $font = realpath('../fonts/micross.ttf'); $size = 12; $spacing = 20; for ($x = 0; $x <= 25; $x++) { $box = imageftbbox($size + $x/10, 0, $font, "The longer the phase the more apparent the size difference should be"); $boxWidth = $box[2] - $box[0]; imagefilledrectangle($img, 5, $x*$spacing+5, $boxWidth+5, ($x+1)*$spacing+5, $gray); imagefttext($img, $size + $x/10, 0, 5, $spacing*($x+1), $white, $font, "The longer the phase the more apparent the size difference should be Font Size ".($size+($x/10))); } imagejpeg($img); imagedestroy($img); ?> You can see how despite the font size steadily increasing by 0.1, it sporadically jumps at what seem at first like random intervals, however if you increase the number of loops and log the data, you can see that it alternates between increasing every 0.7, and 0.8. Unfortunately that doesn't help me any, just some insight. if($last != $boxWidth) { $last = $boxWidth; echo $boxWidth." ".($size+($x/10))."<br>"; }
This outputs the current width and font size each time the text width changes. Well, I have been tryna figure this out for days but it wont seem to work. The base image appears fine but it wont write the text or the avatar on it. Code: [Select] <?php //Do Not Cache header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); //Getting Variables $user = "Dusaro"; $rank = "Administrator"; $a = "0"; if(isset($_GET['a'])) { if(!empty($_GET['a'])) { $a = $_GET['a']; } } if(isset($_GET['u'])) { if(!empty($_GET['u'])) { $user = $_GET['u']; } } if(isset($_GET['r'])) { if(!empty($_GET['r'])) { $rnk = $_GET['r']; } else{$rnk='Administrator';} } else{$rnk='Administrator';} if(isset($_POST['u'],$_POST['r'],$_POST['a'])) { if(!empty($_POST['u'])) { $user=$_POST['u']; } if(!empty($_POST['r'])) { $rnk = $_POST['r']; } if(!empty($_POST['a'])) { $a = $_POST['a']; } } //Setting up Image $image = imagecreatefrompng("base.png"); $avatar = imagecreatefrompng($a.".png"); $font = "US101.TTF"; imagecopymerge($image, $avatar, 0, 0, 0, 0, 100, 100, 100); $color = imagecolorallocate($image, 0,0,0); ImageTTFText ($image, "15", 0, 230, 0, $color, $font,$user); ImageTTFText ($image, "14", 0, 257, 96, $color,$font,$rnk); //Displaying Image header("Content-type: image/png"); imagepng($image); imagedestroy($image); imagedestroy($avatar); ?> can any1 help? Hi, I am creating an image with a random number to use as a capcha. I've done the image creation before and had it working but now I have a font path error. However......I know my font path is the same...I didn't change it and it was working perfectly. What I changed was I made the image creation piece of code into a function...so I could return a value and use the function as a capcha....can you not use this image creation stuff in a function? The difficulty is getting hold of the random number to verify someone typed it correctly. If you have any ideas I'm open to other methods. My code is: function capcha(){ $capchatxt = rand(10000,99999); $font = '/includes/balloon.ttf'; $textarray = imagettfbbox(30, 0, $font, $capchatxt); $width = $textarray[2]-$textarray[0]; $height = $textarray[3]-$textarray[7]; $image = imagecreate($width+10,$height+10); $background = imagecolorallocate ($image, 255,227,232); $colour = imagecolorallocate($image, 0, 154, 239); // blue; $pink = imagecolorallocate($image, 239, 0, 144); // crimson pink; $peach = imagecolorallocate($image, 255, 227, 232); // pale pink; // Add the text imagettftext($image, 30, 0, 5, $height+5, $pink, $font, $capchatxt); header('Content-type: image/png'); imagepng($image); imagedestroy($image); return $capchatxt; } At the moment: The function and the font file are in the same folder. The file which is calling the function is in a different folder. BTW - Forgot to mention that right now I'm using localhost (xampp)...not a real server. Thanks for the help. IceKat I'm not sure what I am doing wrong but I am attempting to create a hook system that I can use with modules... Could someone please take a look at the code and point me in the right direction? I've never really dealt with OOP so please be detailed in your response. There are no errors, it's just not working as expected. <?php new System(); class System { public function __construct() { $this->admin = new Admin( &$this ); } public function add_hook( $tag, $method, $class ) { $this->hooks_added[$tag][] = array( 'method' => $method, 'class' => $class ); } public function do_hook( $tag, $msg ) { if( !isset( $this->hooks_registered[$tag] ) ) $this->hooks_registered[$tag] = $msg; else $this->fatal_error( "1002." . __LINE__, "Duplicate hook tags defined." ); if( isset( $this->hooks_added[$tag] ) && is_array( $this->hooks_added[$tag] ) ) { foreach( $this->hooks_added[$tag] as $hook ) { $hook['class']->$hook['method'](); } } } public function fatal_error( $num = "Undefined", $title = "Undefined", $msg = "Undefined" ) { $html = 'Error ' . $num . ': ' . $title; echo $html; } } class Admin { public $_system; public $admin_menu = array( 0 => array( "name" => "Link 1", "params" => "a=link1" ), 5 => array( "name" => "Link 2", "params" => "a=link2" ) ); public function __construct( $_system ) { $this->_system = $_system; $this->dashboard = new Dashboard( &$_system ); $this->build_menu(); } private function build_menu() { $this->_system->do_hook( "admin_menu", "Modify the administrative menu." ); ksort( $this->admin_menu ); $html = '<ul>'; foreach( $this->admin_menu as $link ) { $html .= '<li>' . $link['name'] . '</li>'; } $html .= '</ul>'; echo $html; } public function add_menu_item( $name, $params, $sort ) { if( isset( $this->admin_menu[$sort] ) ) { $this->add_menu_item( $name, $params, (int) $sort + 1 ); } else { $this->admin_menu[$sort] = array( "name" => $name, "params" => $params ); } } } class Dashboard extends Admin { public $_system; public function __construct( $_system ) { $this->_system = $_system; $this->_system->add_hook( "admin_menu", "custom", &$this ); } public function custom() { $this->add_menu_item( "Dashboard", "a=dashboard", 0 ); } } ?> Thanks I've got a very simple script that records IP address of every page view. Here is the script: $ip = $_SERVER['REMOTE_ADDR']; $query = "INSERT INTO tracking VALUES ('', '1', '$ip')"; echo $query; echo ("<hr>"); if (mysql_query($query)) { echo ("INSERT OK"); } else { echo ("INSERT failed"); } FYI: the 1st value is "auto_increment" in the DB, therefore blank ('') in the query string, and the 2nd value "1" is just for the page number 1, as this script will be on other pages, with different numbers. Now, when I go to this page, it outputs the query, and hr, and then "INSERT failed" and sure enough, no record gets added to the DB. The strangest thing is, is that when I copy the query that the page shows, and paste it into mysqlPHPadmin's "SQL" section and run it, it executes fine, and a record gets added to the DB, however the page is unable to do that. Any ideas? PS: the connection (which I didn't paste in here) is fine, that's definitely not the problem. After working with the sample imagecreatefromjpeg provided in the PHP manual, I successfully got a result (after clearing my cache) from Quoteimagecreatefromjpeg($im, $file); I've gotten a good education after navigating this function over the past week, and loaded it with ECHO messages to give me insight. Everything was going fine. And then, this ONE test image came along. Apparently, the image (which is as good aj peg as I can find) FAILS the if(!im) test. When I used echo $im; i discovered that when images pass through the function, they receive a "Resource" name. Images that FAIL are NOT named. This image gets a Resource name, yet FAILS. Is there a problem with my logic? A problem with the image? What would cause this? How can I verify? Upon testing my PayPal IPN script, the paypal payment was recieved from payer to buyer, however the IPN script did not go any further than line 17... and therefore did not log any of the payment info into the designated mysql table, nor did it update anything else. The following error was logged in the "error_log": Quote PHP Warning: fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: unable to connect to ssl://www.paypal.com:443 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in /home/mysite/public_html/paypal_listener.php on line 17 This is the line in question on my IPN script: $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); Completely new ground to me, but do i need to be getting the admins who host my site to enable this? I read somewhere that: Quote The PHP function fsockopen() may not work because of firewall restrictions on the outgoing connections. Any light on the issue would be brilliant here, bit lost. I am working on an e banking web app. So i was stuck on the transferring to the same bank page.. I have spent a lot of time to check where the errors are to no avail. The issue is the code doesnt work it gives a blank page... This is 12.php for the post action
<?php
if(!isset($_SESSION['login'])) f (isset($_POST['transfer'])) {
$db['db_host'] = "localhost";
foreach($db as $key => $value){ $connection = mysqli_connect(DB_HOST, DB_USER,DB_PASS,DB_NAME);
$query = "SET NAMES utf8";
if(!$connection) {
send query
//check query
$lastname = $_POST['lastname'];
if($rfirstname !== $firstname && $rlastname !== $lastname && $rmiddlename !== $middlename && $raccountNumber !== $account_number)
echo'<script>swal.fire("FAILED!!", " The Account Number doesnt match the Account Name. Check Well", "error");</script>';
if($totalTrans > $row5['balance']) }
}//while balance $transLimit = $row6['transLimit']; $acctype = $row6['acctype'];
}// end of while transLimit
$sqla = "SELECT * FROM customer WHERE username = '".$SESSION['login']."'";
if($otp !== $rowa['otp'])
$sqlc = "SELECT * FROM customer WHERE username = {$username}";
$time_now = strtotime($otpTime);
if($rfirstname == $firstname && $rlastname == $lastname && $rmiddlename == $middlename && $raccountNumber == $account_number && $totalTrans < $transLimit && $totalTrans <= $row['balance'] && $otp == $row['otp'] && (time() - $time_now < 3 * 60))
$sql10 = "update customer set balance = $balance + $transAmount
$db_username = $rowf['username'];
$msg = " <!DOCTYPE html><body>Dear <h1> $db_username, </h1>
$headers = "";
$status1 = '<button class="button">CREDIT</button>'; $status2 = '<button class="button2">DEDIT</button>';
$sqlm = "SELECT * FROM customer WHERE username = {$username}";
$sql11 = "insert into transactions where account_number = '$raccountNumber'
// $result11 = $connection->query($sql11);
$sql12 = "insert into transactions where username = '$username'
$result12 = mysqli_query($connection, $sql12);
}//end of ehile
$firstname = $row15['firstname'];
$sql16 = "SELECT * FROM customer WHERE account_numberr = $raccountNumber ";
$msg = " <!DOCTYPE html><body>Dear <h1> $rfirstname $rlastname $rmiddlename </h1>
$headers = "";
}//end while 1 }
}//while
Then my html form in transfer.php is <form method="POST" class="form-horizontal mt-4" action="">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="form-group row">
<div class="form-group mt-2 mb-0 row">
</form> </div> I will be glad if u can help me. Thanks in advance
echo(" <form method = \"get\" action = \"DeleteApp.php?pname=\" . $Applications['Name'] . \"> <input value='Delete' type='submit' /> </form> "); Why is this redirecting to: DeleteApp.php?. Instead of what you can obviously see what it's supposed to redirect to. My code is a total failure. Any ideas? <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"] ["size"] < 4000000)) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />That means your picture is not right somehow...<br />"; } else { $i=1; while($i<=5000) { if (file_exists("./photos/" $POST['lname'] . "_" . $i . "_" . $_FILES["file"]["name"]])) { $i++; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "photos/" $POST['lname'] . "_" . $i . "_" . $_FILES["file"]["name"]); $i=5000; } } } else { echo "Invalid file... Only 4MB and jpeg/gifs allowed."; } $con = mysql_connect( 'localhost', 'root', 'password') if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("submition", $con) $sql = "INSERT INTO 'submition' ('fname','lname','address1','address2','city','stat_prov_reg','postal_zip','country','email','newsletter') VALUES ('"$POST['element_1_1']."' , '"$POST['element_1_2']."' , '"$POST['element_2_1']."' , '"$POST['element_2_2']."' , '"$POST['element_2_3']."' , '"$POST['element_2_4']."' , '"$POST['element_2_5']."' , '"$POST['element_2_6']."' , '"$POST['element_3']."' , '"$POST['element_7']."')"; mysql_query($sql) or die('Bad Query'); mysql_close($con); ?> <div align="center"> - <a href="http://apps.facebook.com/fourxfourexperience/'>Go Back</a> - </div> With the following code
<?php ?> There is still an error output of syntax error on line 11, please help, what's wrong with my code The script in question works perfectly on my WAMP installation. It is designed to help a computer-challenged historian publish to the web using text CSV files without her having to use FTP or edit html files. The largest data set is about 400KB. The script is using TEXTAREA form input and uploading via POST. Smaller files upload okay. The larger ones fail with a blank screen (empty html) and usually only a few hundred bytes missing. Example: 380KB data POST fails with 367KB stored on remote host. No error message is saved to the remote host directory. I suspected suhosin.post.max_value_length as it is set to 64K, but more than four times that amount is being stored on the remote host. Can suhosin.post.max_value_length still be the problem? The remote host is running: PHP 5.2.5 Apache 2.2.11 Linux O/S PHPINFO(): max_execution_time - 30 max_input_time - 60 memory_limit - 64M post_max_size - 16M upload_max_filesize - 16M suhosin.post.max_value_length - 65384 Any suggestions much appreciated. Hi all, I have a session problem on my development site. Whenever I go to my login screen at www.mydomain.com/my/path/index.php, i get the following error messages: Quote Warning: session_start() [function.session-start]: open(/tmp/sess_f89c3850adf5a752b13f5c6b9022d8c4, O_RDWR) failed: Permission denied (13) in /home/account/public_html/shop_lite/admin/index.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/account/public_html/shop_lite/admin/index.php:2) in /home/account/public_html/shop_lite/admin/index.php on line 2 However, when I go to mydomain.com/my/path/index.php, the error messages aren't there. I am very confused. We don't have an SSL (which google suggested it could be) or any whitespace between the opening php tag. I have chmoded the /tmp directory to 777 but to no avail. Any ideas? My opening code is below: Code: [Select] <?php session_start(); require_once("includes/db_connector.php"); include("includes/cms_class.php"); include("includes/login_class.php"); loginForwarder(); $issue = checkLoginIssue(); if (isset($_POST["login"])) { loginUser($_POST["email"], $_POST["password"]); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/my_template.dwt.php" codeOutsideHTMLIsLocked="false" --> |