php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13055 When GetImgSize/ ImageSX invoked - errroneous error msg
Submitted: 2001-08-30 06:23 UTC Modified: 2001-08-31 15:33 UTC
From: mal at sawds dot com Assigned:
Status: Not a bug Package: GetImageSize related
PHP Version: 4.0.6 OS: Win98SE & UNIX
Private report: No CVE-ID: None
 [2001-08-30 06:23 UTC] mal at sawds dot com
I have isolated the problem domain in the following script. Required files are below it. Assuming you have a db created, the script duly INSERTs. Remove the comments from //$size... and I get this error,"No Database selected", and yet you can $db1->getdb(); to simultaneously echo the db chosen. I tried ImageSX hoping to find a way round, but alas....I'm here with a bug report.

<?
require ("config.ini");
require ("mysqldb.obj");

$img_path = "C:\Program Files\Apache Group\Apache\htdocs\img\images\marked\image6.png";
//$size    = GetImageSize($img_path);

$db1 = new mysqldb();
$db1->setsql("INSERT INTO images 
	(img_desc,img_fname,img_fsize,img_ftype,
	img_xval,img_yval,img_tn_grp,img_cat,
	img_angle,img_admit,img_up_date) 
	VALUES 
	(\"$img_desc\",\"$image_fname\",\"$uploaded_image_size\",
	\"$uploaded_image_type\",\"$img_xval\",\"$img_yval\",
	\"$img_tn_grp\",\"$img_cat\",\"$img_angle\",\"N\",\"$img_up_date\")
	"); 

if(!$db1->deladdmod()){echo $db1->err ;exit;}


// 

?>

config file
**********


<?

// FILE PATHS

$C_image_fpath		= "C:\\Program Files\\Apache Group\\Apache\\htdocs\\img\\images\\uploads\\orig\\";
$C_thumb_fpath		= "C:\\Program Files\\Apache Group\\Apache\\htdocs\\img\\images\\uploads\\thumbs\\";
// archive paths
$C_image_fpathA		= "C:\\Program Files\\Apache Group\\Apache\\htdocs\\img\\images\\archive\\orig\\";
$C_thumb_fpathA		= "C:\\Program Files\\Apache Group\\Apache\\htdocs\\img\\images\\archive\\thumbs\\";


// DATABASE

$C_host			= "localhost";
$C_db			= "photo";
$C_username		= "";
$C_password		= "";

$C_table1		="images";
$C_table2		="author";
$C_table3		="archive";

//  # MAPS in grid

$C_map_num		= 9;
	

// makemap.obj

$MARKER_RGB		= array (array("red","255","0","0"),
				 array("blue","0","0","255"));
$MARKER_FONT 		= "ARIAL.TTF";
$MARKER_FONT_SIZE 	= "10";
$MARKER_TYPE 		= array ( ">" , "&#164;");



// IMG FILES - supported file types and max upload fsize

$C_img_types		=	".jpg/.jpeg";
$C_max_fsize		=	"200";
$C_max_fsize_bytes	=	"204800";

// SITE

$C_site_name		= "PEAKAROUND";
$C_site_title		= "<B>THE SAWDS GALLERY&#153;</B>";
$C_site_title_txt 	= "THE SAWDS GALLERY";
//$C_nav_back		=	"";
$C_faq_txt		= "Please refer to the HELP pages.";


// MAIL

$C_mail_admin	= "mal@sawds.com";
$C_mail_from		= "mal@sawds.com";
$C_mail_feedback	= "feedback@peakaround.co.uk";


// LOGIC

$C_true 		= 1;	
$C_false 		= 0;

?>

mysqldb.obj
************
<?

	class mysqldb 
	{
	
		var $host;
		var $db;
		var $dbuser;
		var $dbpassword;
		var $sql;
		var $numberrows;
		var $dbopenstatus;
		var $dbconnection;
		var $err;
		var $qry;
		
	// Property Get & Set
	
		function gethost() {
			return $this->dbhost;
		}
		
		function sethost($req_host) {
			$this->dbhost = $req_host;
			
		}
		
		function getdb() {
			return $this->db;
		}
		
		function setdb($req_db) {
			$this->db = $req_db;
		}
		
		function getdbuser() {
			return $this->dbuser;
		}
		
		function setdbuser($req_user) {
			$this->dbuser = $req_user;
		}
		
		function getdbpassword() {
			return $this->dbpassword;
		}
		
		function setdbpassword($req_password) {
			$this->dbpassword = $req_password;
		}
		
		function getsql() {
			return $this->sql;
		}
		
		function setsql($req_sql) {
			$this->sql = $req_sql;
		}
		
		function getnumberrows() {
			return $this->numberrows;
		}
		
		function setnumberrows($req_numberresults) {
			$this->numberrows = $req_numberresults;
		}
	
		function setdbconnection($req_dbconnection) {
			$this->dbconnection = $req_connection;
		}
		
		function getdbconnection() {
			return $this->dbconnection;
		}
	
	// Constructor
	
		function mysqldb() {
		
			global $C_host, $C_db, $C_username, $C_password;
			global $C_true, $C_false;
			
			$this->sethost($C_host);
			$this->setdb($C_db);
			$this->setdbuser($C_username);
			$this->setdbpassword($C_password);
			$this->setdbconnection($C_false);

		}
		
	// Methods
	
		function opendbconnection() {

			global $C_true, $C_false;
			
			$this->dbconnection = mysql_connect("$GLOBALS[C_host]", "$GLOBALS[C_username]", "$GLOBALS[C_password]");
			if ($this->dbconnection == $C_true) {
				$this->db = mysql_select_db("$GLOBALS[C_db]");
				$this->setdbconnection($C_true);
			} else {
				$this->setdbconnection($C_false);
				$this->err = mysql_error();
				return false;
			}
			return true;
		}
		
		function closedbconnection() {

			if ($this->dbconnection = $C_true) {
				mysql_close($this->dbconnection);
			}
			
		}

		function selectquery() 
		{
			
			global $C_true, $C_false;

			if ($this->dbconnection == $C_false) {
				$this->opendbconnection();
			}

			$this->qry = mysql_query($this->sql);
			if (!$this->qry) {
				$this->err = mysql_error();
				return false;
			} 
			else 
			{
				$this->setnumberrows(mysql_num_rows($this->qry));
				
				if ($this->getnumberrows() > 0)
				{
					for($x = 0; $x < $this->getnumberrows(); $x++) 
					{
						$this->row[$x] = mysql_fetch_array($this->qry);                                
					}
				} 
				else 
				{
					return false;
				}
				return true;
			}
		}
		
		
		function deladdmod() 
		{
			
			global $C_true, $C_false;

			if ($this->dbconnection == $C_false) {
				$this->opendbconnection();
			}

			$this->qry = mysql_query($this->sql);
			if (!$this->qry) {
				$this->err = mysql_error()."eeeee";
				return false;
			} 
			return true; //needed for eg if(!$db1->deladdmod()) {...}
			
		}
		
		
		
		
		
		
		
		
		
		
		
		

	}	
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-30 12:07 UTC] sniper@php.net
What is the error message you get? 
And please add a SHORT standalone example script
which does not depend on databases.

--Jani

 [2001-08-31 07:50 UTC] cynic@php.net
user feedback:
*****************************

From: "Malcolm Clark" <mal@sawds.com>
To: "Bug Database" <php-dev@lists.php.net>
Date: Thu, 30 Aug 2001 19:12:10 +0100

> What is the error message you get?

No Database selected

> And please add a SHORT standalone example script
> which does not depend on databases.

I don't think this is possible, considering the above error msg emanates
from a db request. ( mysql_error(); )
I suggest using any mysql db on your system and changing  $C_db in
config.ini to the name of the test db you want to use. I've tried it here
and still get the problem. :(  Finally make up a simple INSERT statement or
something.

*****************************

next time, use the web interface for replies. direct link to your PR is included in every mail from the bug db.
 [2001-08-31 09:01 UTC] sniper@php.net
Please ask support questions on the mailing lists:

http://www.php.net/support.php

Also reading the manual would help.

--Jani

 [2001-08-31 12:12 UTC] mal at sawds dot com
Also reading the manual would help.

--Jani

Ok, so I'm no great programmer, I don't know the manual inside out (then who does?) and I didn't use your web interface, but really..if you want to promote people to get involved with open source stuff and to at least try to evolve it, do you really think a "RTFM" response was the correct one?



Malcolm Clark


 [2001-08-31 13:05 UTC] cynic@php.net
Did you really test that this script is the shortest one that reproduces the problem, and that it isn't a PEBKAC, i. e. a flaw in the program logic? 300 lines isn't what most people would call a short script.

 [2001-08-31 15:17 UTC] mal at sawds dot com
Basically, do what you want with it. I have a solution to circumvent the problem for my script. You may already know that it's an error with my logic and that I should've RTFM etc - I don't know! If this is not the case then WYSIWYG.
 [2001-08-31 15:33 UTC] mal at sawds dot com
Basically, do what you want with it. I have a solution to circumvent the problem for my script. You may already know that it's an error with my logic and that I should've RTFM etc - I don't know! If this is not the case then WYSIWYG.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 05:01:26 2019 UTC