[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

01/17/2005 at 07:30PM PST, ID: 21278110
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

strange error on PHP 4.3.5 (works fine on 4.3.1)

Asked by theprankstanator in PHP and Databases

Hey Guys,

I have a script that  runs fine on a local server (PHP 4.3.10) and a remote server (also 4.3.10) but on the clients server (4.3.5RC4) it gives me an undefined function error... very strange, heres the code;

**********************************************************************
<?php
 ini_set('display_errors', 1);
 error_reporting(E_ALL &~E_NOTICE);
 
 include('header.php');
 include('menu.php');
 include('../config.php');
 
 function resampimagejpg($psize, $sourcefile, $pdestfile, $g_imgcomp) {
     $g_srcfile=$sourcefile;
     
     if(file_exists($sourcefile)) {
          //Get data from source image
          $g_is=getimagesize($sourcefile);
          $p = pathinfo($sourcefile);
          switch ($p['extension']) {
               case 'gif':
                    $img_src=imagecreatefromgif($sourcefile);
                    break;
               case 'jpg':
               case 'jpeg':
                    $img_src=imagecreatefromjpeg($sourcefile);
                    break;
               case 'png': // line 33, apparent errorneous line
                    $img_src=imagecreatefrompng($sourcefile);
                    break;
               default:
                    return false; //Can't handle other formats
          }
               //Create preview sized image
          if ($g_is[0] > $psize or $g_is[1] > $psize) { //Only shrink, don't enlarge to fit
               $g_fw=$psize;
               $g_fh=$psize;
               if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh)) {
                    $g_iw=$g_fw;
                    $g_ih=($g_fw/$g_is[0])*$g_is[1];
               } else {
                    $g_ih=$g_fh;
                    $g_iw=($g_ih/$g_is[1])*$g_is[0];
               }
               $img_dst=imagecreatetruecolor($g_iw,$g_ih);
               imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_is[0], $g_is[1]);
          } else { //Just copy the image
               $img_dst = $img_src;
          }
          imageinterlace($img_dst, 1);
          imagejpeg($img_dst, $pdestfile, $g_imgcomp);
          imagedestroy($img_dst);
          return true;
     } else {
          return false;
     }
}
 
 
 //Check that there was actually an upload before proceeding
if (count($_FILES) > 0 and array_key_exists('image', $_FILES)) {
     if (is_uploaded_file($_FILES['image']['tmp_name'])) {
          if ($_FILES['image']['name'] != '')
          {
               $pic_name = "1_" . date("d_m_Y_H_i") . "_" . $_FILES['image']['name'];
          } else {
               exit; //Can't really do anything if we don't have a filename
          }
          $uploaddir = '../images/phones/';
          $thumbnaildir = '../images/phones/thumbs/';
          $sourcefile = $uploaddir.$pic_name;
          move_uploaded_file($_FILES['image']['tmp_name'], $sourcefile);
          $pdestfile = "{$thumbnaildir}tn_{$pic_name}";

          $g_imgcomp = $img_comp;
          $psize = $img_max_width;
          resampimagejpg($psize, $sourcefile, $pdestfile, $g_imgcomp);
     }
}
 
 if ($dbc = @mysql_connect($db_host, $db_user, $db_pass)) {
                                                if (!mysql_select_db($db_name)) {
                                                                        die('<p>Could not connect to the database because: <b>' . mysql_error() . '</b></p>');
                                                }
                        } else {
                                                die('<p>Could not connect to the database because: <b>' . mysql_error() . '</b></p>');
                        }
      
 $query1 = "SELECT * from phone_man ORDER BY name" or die(mysql_error());
 $r = mysql_query($query1) or die(mysql_error());
 $row = mysql_fetch_assoc($r);
        
 echo '<div class="main">';
 echo '
 <p><h1>Add a Phone</h1></p>';
 
 if (!isset($_POST['submit'])) {
 echo '
 <form name="add_phone" method="post" action="phones_add.php" enctype="multipart/form-data">
 <table width="80%" border="0">
 <tr>
 <td width="100">Name:</td>
 <td><input type="text" name="name" size="50" /></td>
 </tr>
 <tr>
 <td width="100">Manufacturer:</td>
 <td><select name="man">
 <option value="Select...">Select...</option>';
 do {
       echo'<option value="'.$row['name'].'">'.$row['name'].'</option>';
 }
 while($row = mysql_fetch_assoc($r));
 
 echo '</select></td>
 </tr>
 <tr>
 <td width="100">Features and Info:</td>
 <td><textarea name="body" cols="50" rows="10"></textarea></td>
 </tr>
 <tr>
 <td width="100">Image:</td>
 <td><input type="file" name="image" /></td>
 </tr>
 <tr>
 <td width="100">Price:</td>
 <td><input type="text" name="price" size="50" /></td>
 </tr>
 <tr>
 <td width="100">Network:</td>
 <td><input type="radio" name="network" value="cdma" /> CDMA<br />
 <input type="radio" name="network" value="gsm" /> GSM<br /></td>
 </tr>
 <tr>
 <td width="100"><input type="submit" name="submit" value="Add Phone" /></td>
 <td><input type="reset" name="reset" value="Clear Form" /></td>
 </tr>
 </table>
 </form>';
}
if (isset($_POST['submit'])) {
$p_name = addslashes($_POST['name']);
$p_man = addslashes($_POST['man']);
$p_body = addslashes($_POST['body']);
$p_image = addslashes($pic_name);
$p_price = addslashes($_POST['price']);
$p_network = addslashes($_POST['network']);

                        $query = "INSERT into phones (name, body, image, price, man, network) VALUES ('{$p_name}', '{$p_body}' , '{$p_image}', '{$p_price}', '{$p_man}' , '{$p_network}')";

                        if (@mysql_query ($query)) {
                                                header('Location: thanks.php');
                        } else {
                                                echo 'An error occured while entering the data, the error was ' . mysql_error() . ' and the query was ' . $query . '';
                        }
}
echo '</div>';
ob_end_flush();
include('footer.php');
?>
*****************************************************************

The exact error is;

Fatal error: Call to undefined function: imagecreatefromjpeg() in /home/intouch/public_html/admin/phones_add.php on line 33

This is really urgent, any help is so muchly appreciated!!!!! :)

Christian
[+][-]01/17/05 08:41 PM, ID: 13069577

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP and Databases
Sign Up Now!
Solution Provided By: aib_42
Participating Experts: 2
Solution Grade: A
 
 
[+][-]01/17/05 08:48 PM, ID: 13069605

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/06/05 07:05 AM, ID: 14377983

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]01/08/06 03:38 AM, ID: 15641270

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/13/06 11:27 AM, ID: 15694614

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91