ThomasBalaban Posted March 22, 2014 Share Posted March 22, 2014 Normally I avoid asking for help but I am really confused. This is working on another site of mine. Pretty much a user enters their information and it auto generates using this code onto a image and then saves it. I am getting a different result then on the other and I am not sure why. working: http://www.drwayneandersen.com/display-cert/?cert_name=testNon: http://stopchallengechoose.com/testing-cert-display/?cert_name=testing Working: <?php require_once("http://www.drwayneandersen.com/wp-load.php"); require('./wp-blog-header.php'); //get_header(); $current_user = wp_get_current_user(); $email=$current_user->user_email; //echo "CURRENT TOP".$current_user->user_email; //ini_set('display_errors', 1); // you can set to 0 for production version //error_reporting(E_ALL); //echo "In the file"; function LoadJpeg() { //create the background image //if (file_exists($filename)) { // echo "The file $filename exists"; //} else { // echo "The file $filename does not exist"; //} $cert_id=30; if(isset($_REQUEST['cert_name'])){ $certname = $_REQUEST['cert_name']; } if(isset($_REQUEST['cert_id'])){ $cert_id = $_REQUEST['cert_id']; } if ($cert_id == 90) { $im = imagecreatefromjpeg('http://www.drwayneandersen.com/wp-content/uploads/2013/03/DrACertificate90Day.jpg'); $filename ="http://www.drwayneandersen.com/wp-content/uploads/2013/03/DrACertificate90Day.jpg"; } else if ($cert_id == 60) { $im = imagecreatefromjpeg('http://www.drwayneandersen.com/wp-content/uploads/2013/03/DrACertificate60Day.jpg'); $filename ="http://www.drwayneandersen.com/wp-content/uploads/2013/03/DrACertificate60Day.jpg"; } else { $im = imagecreatefromjpeg('http://www.drwayneandersen.com/wp-content/uploads/2013/02/cert.jpg'); $filename ="http://www.drwayneandersen.com/wp-content/uploads/2013/02/cert.jpg"; } /* See if it failed */ if(!$im) { /* Create a black image */ $im = imagecreatetruecolor(150, 30); $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 30, $bgc); /* Output an error message */ imagestring($im, 1, 5, 5, 'Error loading FILE ' . $filename, $tc); } $textcolor = imagecolorallocate($im, 89, 88, 93); $font = '/home1/drwaynea/public_html/arial.ttf'; imagettftext($im, 55, 0, 370, 1050, $textcolor, $font, $certname); // createCert($clientGoalImage[0], $im, $textColor, $fontfile, $clientGoalStatement[0], $galleryArray, $galleryCtr, $source); return $im; } header('Content-Type: image/jpeg'); $img = LoadJpeg(); $filePath='certs/'.$email.'/cert'.$cert_id.'.jpg'; $ckdirname = ("certs/" . "$email" . "/"); if (!(file_exists($ckdirname))) { mkdir("certs/" . "$email", 0777); } imagejpeg($img, $filePath); imagejpeg($img); imagedestroy($img); //get_footer(); ?> Not working <?php require_once("http://www.stopchallengechoose.com//wp-load.php"); require('./wp-blog-header.php'); //get_header(); $current_user = wp_get_current_user(); $email=$current_user->user_email; //echo "CURRENT TOP".$current_user->user_email; //ini_set('display_errors', 1); // you can set to 0 for production version //error_reporting(E_ALL); //echo "In the file"; function LoadJpeg() { //create the background image //if (file_exists($filename)) { // echo "The file $filename exists"; //} else { // echo "The file $filename does not exist"; //} $cert_id=30; if(isset($_REQUEST['cert_name'])){ $certname = $_REQUEST['cert_name']; } if(isset($_REQUEST['cert_id'])){ $cert_id = $_REQUEST['cert_id']; } if ($cert_id == 90) { $im = imagecreatefromjpeg('http://stopchallengechoose.com/wp-content/uploads/2014/03/certtesting.jpeg'); $filename ="http://stopchallengechoose.com/wp-content/uploads/2014/03/certtesting.jpeg"; } else if ($cert_id == 60) { $im = imagecreatefromjpeg('http://stopchallengechoose.com/wp-content/uploads/2014/03/certtesting.jpeg'); $filename ="http://stopchallengechoose.com/wp-content/uploads/2014/03/certtesting.jpeg"; } else { $im = imagecreatefromjpeg('http://stopchallengechoose.com/wp-content/uploads/2014/03/certtesting.jpeg'); $filename ="http://stopchallengechoose.com/wp-content/uploads/2014/03/certtesting.jpeg"; } /* See if it failed */ if(!$im) { /* Create a black image */ $im = imagecreatetruecolor(150, 30); $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 30, $bgc); /* Output an error message */ imagestring($im, 1, 5, 5, 'Error loading FILE ' . $filename, $tc); } $textcolor = imagecolorallocate($im, 89, 88, 93); $font = '/tank/www/users/medideascc/medideascc.pairserver.com/arial.ttf'; imagettftext($im, 55, 0, 370, 1050, $textcolor, $font, $certname); // createCert($clientGoalImage[0], $im, $textColor, $fontfile, $clientGoalStatement[0], $galleryArray, $galleryCtr, $source); return $im; } header('Content-Type: image/jpeg'); echo "<p>".$img."</p>"; $img = LoadJpeg(); $filePath='certs/'.$email.'/cert'.$cert_id.'.jpg'; $ckdirname = ("certs/" . "$email" . "/"); if (!(file_exists($ckdirname))) { mkdir("certs/" . "$email", 0777); } imagejpeg($img, $filePath); imagejpeg($img); imagedestroy($img); //get_footer(); ?> Quote Link to comment Share on other sites More sharing options...
trq Posted March 22, 2014 Share Posted March 22, 2014 Why are you using a url with require_once ? That won't work on most servers and is VERY inefficient and slow anyway. Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted March 23, 2014 Share Posted March 23, 2014 (edited) require_once("http://www.stopchallengechoose.com//wp-load.php"); There is a double slash after domain name require_once("http://www.stopchallengechoose.com/wp-load.php"); But this is all you should need to include it require('./wp-load.php'); Edited March 23, 2014 by QuickOldCar Quote Link to comment Share on other sites More sharing options...
ThomasBalaban Posted March 24, 2014 Author Share Posted March 24, 2014 I made the above changes and I am still getting the same error. I am quiet perplexed by this. Thanks for the help by the way! Quote Link to comment Share on other sites More sharing options...
ThomasBalaban Posted March 24, 2014 Author Share Posted March 24, 2014 Fixed. Thanks for the help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.