|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-08-30 12:07 UTC] sniper@php.net
[2001-08-31 07:50 UTC] cynic@php.net
[2001-08-31 09:01 UTC] sniper@php.net
[2001-08-31 12:12 UTC] mal at sawds dot com
[2001-08-31 13:05 UTC] cynic@php.net
[2001-08-31 15:17 UTC] mal at sawds dot com
[2001-08-31 15:33 UTC] mal at sawds dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 19:00:02 2025 UTC |
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 ( ">" , "¤"); // 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™</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()) {...} } } ?>