Jump to content

Fatal error: Call to undefined method:


adam291086

Recommended Posts

We are getting there, the echo message ''still here is now being displayed in the creat thumbnail code. I now get the error message

 

Fatal error: Call to a member function on a non-object in /homepages/12/d214897219/htdocs/adam/create_thumbnails.php on line 56

 

<?php
include("GallerySizer.php");
include("config.php");
DEFINE("IMAGE_FULL",'../adam/photos/');

// Album cover

$cover = $_FILES['image']['name'][$_POST['album_cover']];
if(!$_REQUEST['process']){
echo("Error! No images chosen for processing. <br />");
echo("Click <a href='index.html'>here</a> to start processing your images.");
die();
}elseif(!$_POST['album_id']){
echo("No album selected. Please <a href=\"\">choose an album</a> to upload images to.");
die();
}else{
for($i = 0; $i < count($_FILES['image']['tmp_name']); $i++){
	$fileName = $_FILES['image']['name'][$i];
	copy($_FILES['image']['tmp_name'][$i], IMAGE_FULL . $fileName);
	$thumb = new GallerySizer();
		if($thumb->getLocation($_FILES['image']['name'][$i])){
			if($thumb->loadImage()){
				echo("Still here!");
					if($thumb->getSize()){
						if($thumb->setThumbnail()){
							if($thumb->copyImage()){
								if($thumb->resizeImage()){
									$thumb->copyResize();
									$thumb->display(); 
								}
							}
						}
					}
			}else{
				echo("Invalid image/file has been uploaded. Please upload a supported file-type (JPEG/PNG)"); 
				unlink(IMAGE_FULL . $fileName);
				die();
			}
			insert_location($thumb);
		}else{
			echo("Error processing images: " . mysql_error());
		}

		// If image matches cover selection, update album cover
		if($cover == $_FILES['image']['name'][$i]){
			$sql = "UPDATE albums SET album_cover = '" . $thumb->getThumbLocation() . "' WHERE album_id = " . $_POST['album_id'];
			$result = @mysql_query($sql) or die("Error inserting records: " . mysql_error());
		} 
}
}

function insert_location(){
global $thumb;
$image_location=$thumb->getThumbLocation();
$thumb_location=$thumb->getThumbLocation();
$thumb_location=$thumb_obj->getThumbLocation();
$dbcnx = mysql_connect("localhost", "root", "");
mysql_select_db("album", $dbcnx);
$sql = "INSERT INTO photos values(0, '$_POST[photo_title]', '$_POST[photo_desc]', NOW(), '$image_location', '$thumb_location', $_POST[album_id])";
$result = mysql_query($sql, $dbcnx) or die("Error inserting record(s) into the database: " . mysql_error());
	if ($result){
		echo("Images successfully converted and stored! <br />Click <a href='../admin'>here</a> to continue.");
	}
}
?>

Link to comment
Share on other sites

switch this:

function insert_location(){
global $thumb;
$image_location=$thumb->getThumbLocation();
$thumb_location=$thumb->getThumbLocation();
$thumb_location=$thumb_obj->getThumbLocation();
$dbcnx = mysql_connect("localhost", "root", "");
mysql_select_db("album", $dbcnx);
$sql = "INSERT INTO photos values(0, '$_POST[photo_title]', '$_POST[photo_desc]', NOW(), '$image_location', '$thumb_location', $_POST[album_id])";
$result = mysql_query($sql, $dbcnx) or die("Error inserting record(s) into the database: " . mysql_error());
	if ($result){
		echo("Images successfully converted and stored! <br />Click <a href='../admin'>here</a> to continue.");
	}
}

with this:

function insert_location($thumb_obj){
$image_location = $thumb_obj->getImageLocation();
$thumb_location = $thumb_obj->getThumbLocation();
$dbcnx = mysql_connect("localhost", "root", "");
mysql_select_db("album", $dbcnx);
$sql = "INSERT INTO photos values(0, '$_POST[photo_title]', '$_POST[photo_desc]', NOW(), '$image_location', '$thumb_location', $_POST[album_id])";
$result = mysql_query($sql, $dbcnx) or die("Error inserting record(s) into the database: " . mysql_error());
	if ($result){
		echo("Images successfully converted and stored! <br />Click <a href='../admin'>here</a> to continue.");
	}
}

Link to comment
Share on other sites

Nearly there. It all process now but there is a problem. It process everything but i get the error message, which is generated by the php code

 

Still here!Error inserting record(s) into the database: 

 

This shouldn't happen as all the information requires is inputted. Any ideas why?

 

 

Link to comment
Share on other sites

okay try replacing the last function:

function insert_location($thumb_obj){
$image_location = $thumb_obj->getImageLocation();
$thumb_location = $thumb_obj->getThumbLocation();
$dbcnx = mysql_connect("localhost", "root", "");
mysql_select_db("album", $dbcnx);
$sql = "INSERT INTO photos values(0, '$_POST[photo_title]', '$_POST[photo_desc]', NOW(), '$image_location', '$thumb_location', $_POST[album_id])";
$result = mysql_query($sql, $dbcnx) or die("Error inserting record(s) into the database: " . mysql_error());
	if ($result){
		echo("Images successfully converted and stored! <br />Click <a href='../admin'>here</a> to continue.");
	}
}

with this:

function insert_location($thumb_obj){
$image_location = $thumb_obj->getImageLocation();
$thumb_location = $thumb_obj->getThumbLocation();
$dbcnx = mysql_connect("localhost", "root", "") or die('Error connectiong to database');
mysql_select_db("album", $dbcnx) or die('Error finding database table');
$sql = "INSERT INTO photos values(0, '$_POST[photo_title]', '$_POST[photo_desc]', NOW(), '$image_location', '$thumb_location', $_POST[album_id])";
$result = mysql_query($sql, $dbcnx) or die("Error inserting record(s) into the database: " . mysql_error());
	if ($result){
		echo("Images successfully converted and stored! <br />Click <a href='../admin'>here</a> to continue.");
	}
}

and see if you get anything different. I've added a couple error checks, just to try and narrow down the problem. It seems to be a mysql problem with the database.

Link to comment
Share on other sites

It says

 

Still here!Error connectiong to database

 

but there shouldn't be as the rest of the site works and connects to the database. Heres the config file it call upon.

 

<?php

include("test.php");




    



     // Number of images to display per row in gallery view     
     DEFINE("IMAGE_DISPLAY", 3);
     


/*****
      * Connects to database system
      */
   

$con;
$dbcnx = mysql_connect($db_server, $db_user, $db_pass) or die("Error connecting to database: " . mysql_error());
$dbsel = mysql_select_db($db_name, $dbcnx) or die("Error reading from database table: " . mysql_error());

/*****
   * Displays HTML output page.  The message argument, if passed, 
   * will be displayed to the user.  The title element, is passed,                    
   * replaces the page title, and the cell Boolean places the page 
   * $msg between <td></td>
   */  
   function displayPage($msg = "", $title="", $cell = true){
?>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo($title); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
   <tr>
  <td>
   <table width="60%" border="0" align="center" cellpadding="3" cellspacing="0">
     <tr>
    <td width="40%" valign="top"><h1><?php echo($title); ?></h1></td>
     </tr>
   </table>
   <table width="60%" border="0" align="center" cellpadding="5" cellspacing="0">
   <tr>
    <?php
     // Display opening <td> tag
     if ($cell)
      echo("<td>");
     echo($msg);
     
     // Display closing <td> tag
     if ($cell)
      echo("</td>");   
    ?>
   </tr>
   </table>
  </td>
   </tr>
</table>
</body>
<?php
  mysql_close($con);
}       
?>

 

And this is in test

<?php

$db_server ="";
     $db_user = "";
     $db_pass = "";
     $db_name = "";

$con = mysql_connect("$db_server","$db_user","$db_pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
?>

 

i have put in the details of the username and password but removed them from here

Link to comment
Share on other sites

I have added in the code below

 

function insert_location($thumb_obj){
$image_location = $thumb_obj->getImageLocation();
$thumb_location = $thumb_obj->getThumbLocation();

$con;
$dbcnx = mysql_connect($db_server, $db_user, $db_pass) or die("Error connecting to database: " . mysql_error());
mysql_select_db("album", $dbcnx) or die('Error finding database table');
$sql = "INSERT INTO photos values(0, '$_POST[photo_title]', '$_POST[photo_desc]', NOW(), '$image_location', '$thumb_location', $_POST[album_id])";
$result = mysql_query($sql, $dbcnx) or die("Error inserting record(s) into the database: " . mysql_error());
	if ($result){
		echo("Images successfully converted and stored! <br />Click <a href='../admin'>here</a> to continue.");
	}

 

but still getting the same error about database not connecting

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.