[PHP-DEV] Bug #13055 Updated: When GetImgSize/ ImageSX invoked - errroneous error msg From: cynic <email protected>
Date: 08/31/01

ID: 13055
Updated by: cynic
Reported By: mal <email protected>
Status: Bogus
Bug Type: GetImageSize related
Operating System: Win98SE & UNIX
PHP Version: 4.0.6
New Comment:

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.

Previous Comments:
------------------------------------------------------------------------

[2001-08-31 12:12:58] mal <email protected>

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 09:01:20] sniper <email protected>

Please ask support questions on the mailing lists:

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

Also reading the manual would help.

--Jani

------------------------------------------------------------------------

[2001-08-31 07:50:18] cynic <email protected>

user feedback:
*****************************

From: "Malcolm Clark" <mal <email protected>>
To: "Bug Database" <php-dev <email protected>>
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-30 12:07:23] sniper <email protected>

What is the error message you get?
And please add a SHORT standalone example script
which does not depend on databases.

--Jani

------------------------------------------------------------------------

[2001-08-30 06:23:00] mal <email protected>

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 <email protected>";
$C_mail_from = "mal <email protected>";
$C_mail_feedback = "feedback <email protected>";

// 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()) {...}
                        
                }
                
                
                
                
                
                
                
                
                
                
                
                

        }
?>

------------------------------------------------------------------------

Edit this bug report at http://bugs.php.net/?id=13055&edit=1

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>