adam291086 Posted September 26, 2007 Author Share Posted September 26, 2007 btw there is four parts to the tutorial, you have to click on the indivdual links to get to the next section. Link to comment https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355691 Share on other sites More sharing options...
Dragen Posted September 26, 2007 Share Posted September 26, 2007 yeah, that last error was my fault, sorry. I cut off the last closing bracket }. Just add } to the end of the code, on the line above ?> Link to comment https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355693 Share on other sites More sharing options...
adam291086 Posted September 26, 2007 Author Share Posted September 26, 2007 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 https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355696 Share on other sites More sharing options...
Dragen Posted September 26, 2007 Share Posted September 26, 2007 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 https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355708 Share on other sites More sharing options...
adam291086 Posted September 26, 2007 Author Share Posted September 26, 2007 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 https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355717 Share on other sites More sharing options...
Dragen Posted September 26, 2007 Share Posted September 26, 2007 does it not print out a mysql error after that? It should... Link to comment https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355720 Share on other sites More sharing options...
adam291086 Posted September 26, 2007 Author Share Posted September 26, 2007 no thats all i get on my screen Still here!Error inserting record(s) into the database: Link to comment https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355723 Share on other sites More sharing options...
adam291086 Posted September 26, 2007 Author Share Posted September 26, 2007 No all i get is Still here!Error inserting record(s) into the database: Link to comment https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355725 Share on other sites More sharing options...
Dragen Posted September 26, 2007 Share Posted September 26, 2007 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 https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355727 Share on other sites More sharing options...
adam291086 Posted September 26, 2007 Author Share Posted September 26, 2007 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 https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355731 Share on other sites More sharing options...
Dragen Posted September 26, 2007 Share Posted September 26, 2007 in the function this line is causing the error: $dbcnx = mysql_connect("localhost", "root", ""); I can only assume it's because you need to enter the correct details. (server host, username, password) Link to comment https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355732 Share on other sites More sharing options...
adam291086 Posted September 26, 2007 Author Share Posted September 26, 2007 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 https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355735 Share on other sites More sharing options...
adam291086 Posted September 26, 2007 Author Share Posted September 26, 2007 forget that , i have it work, just got a problem locating the table. THANKS SO MUCH. You have been a massive help Link to comment https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355737 Share on other sites More sharing options...
Dragen Posted September 26, 2007 Share Posted September 26, 2007 haha.. I'm just glad it's finally working! Link to comment https://forums.phpfreaks.com/topic/70630-fatal-error-call-to-undefined-method/page/2/#findComment-355739 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.