Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Pure VPN - Up to 27 Months
vgp
Updated:
Friday at 8:10 AM
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
May 30, 2026
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
PHP Help [Experts pls]
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="lkzombie" data-source="post: 20509911" data-attributes="member: 462352"><p style="text-align: center"><span style="font-size: 18px">Solved!!!! udaw karapu hamatama sthuthiy</span></p> <p style="text-align: center"><img src="http://ayushflowergiftsportal.com/product_images/fa9bb2bd9c83db58e2bc13f59eb74754mixed-roses-and-lilly-bunch-500x500.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p>[PHP]</p><p><?php</p><p>/** </p><p> * ------------------------------------------------------------------</p><p> * Author : Sumal T.Jayaranga</p><p> * Date Created : 2016-07-01</p><p> * Last Modified :</p><p> * Brief :</p><p> * ------------------------------------------------------------------</p><p>**/</p><p>include_once get_include_path().'cls/database/cls_dbconnection.php';</p><p>include_once get_include_path().'cls/misc/cls_images.php';</p><p>include_once get_include_path().'cls/misc/cls_session.php';</p><p>include_once get_include_path().'cls/business/cls_users.php';</p><p></p><p>class _ads</p><p>{</p><p> public $_adid = "";</p><p> public $_userid = "";</p><p> public $_subcatid = "";</p><p> public $_typeid = "";</p><p> public $_title = "";</p><p> public $_description = "";</p><p> public $_price = "";</p><p> public $_city = "";</p><p> public $_pictures = null;</p><p></p><p> </p><p> public $_message = "";</p><p> </p><p> </p><p> public function _open()</p><p> {</p><p> try</p><p> {</p><p> $classDB = new database();</p><p> $dbcon = $classDB->_getDBconnection();</p><p> $resultset = null;</p><p> </p><p> if($dbcon)</p><p> {</p><p> $resultset = $dbcon->prepare("SELECT * FROM tbl_ads WHERE _adid=:_adid AND _status=1;");</p><p> $resultset->execute(array(':_adid'=>$this->_adid));</p><p> </p><p> $rows = $resultset->fetch(PDO::FETCH_ASSOC);</p><p> </p><p> $this->_adid = $rows['_adid'];</p><p> $this->_userid = $rows['_userid']; </p><p> $this->_subcatid = $rows['_subcatid'];</p><p> $this->_typeid = $rows['_typeid'];</p><p> $this->_title = $rows['_title'];</p><p> $this->_description = $rows['_description'];</p><p> $this->_price = $rows['_price'];</p><p> $this->_city = $rows['_city'];</p><p> </p><p> $resultset = null;</p><p> $resultset = $dbcon->prepare("SELECT * FROM tbl_ads_images WHERE _adid=:_adid;");</p><p> $resultset->execute(array(':_adid'=>$this->_adid));</p><p> </p><p> if(!$resultset->rowCount()==0)</p><p> {</p><p> $this->_pictures = $resultset;</p><p> }</p><p> </p><p> </p><p> </p><p> $dbcon = null;</p><p> $classDB->close_db();</p><p> return(true);</p><p> }</p><p> }</p><p> catch(exception $e)</p><p> {</p><p> $this->_message="Unexpected error:_open";</p><p> return (false);</p><p> }</p><p> }</p><p> </p><p> public function _save($userinfo="")</p><p> {</p><p> try</p><p> {</p><p> $classDB = new database();</p><p> $classImage = new _images();</p><p> $dbcon = $classDB->_getDBconnection();</p><p> $resultset = null;</p><p> </p><p> if($dbcon)</p><p> {</p><p> $dbcon->beginTransaction();</p><p> </p><p> //Check user</p><p> $resultset = $dbcon->prepare("SELECT * FROM tbl_users WHERE _userid=:_userid AND _status=1;");</p><p> $resultset->execute(array(':_userid'=>$this->_userid));</p><p> </p><p> if($resultset->rowCount()!==1)</p><p> {</p><p> $this->_message="Invalid user!!"; </p><p> $dbcon->rollBack();</p><p> return (false);</p><p> } </p><p> </p><p> //Generate new id</p><p> $resultset = $dbcon->prepare("SELECT _adid FROM tbl_parameters;");</p><p> $resultset->execute();</p><p> </p><p> $rows = $resultset->fetch(PDO::FETCH_ASSOC);</p><p> $this->_adid = $rows['_adid']+1;</p><p> </p><p> $resultset=null;</p><p> </p><p> //Update new id</p><p> $resultset = $dbcon->prepare("UPDATE tbl_parameters SET _adid=:_adid;");</p><p> $resultset->execute(array(':_adid'=>$this->_adid));</p><p> </p><p> if($resultset->rowCount()!==1)</p><p> {</p><p> $this->_message="System error: Parameter cannot be updated."; </p><p> $dbcon->rollBack();</p><p> return (false);</p><p> exit;</p><p> } </p><p> </p><p> $resultset=null;</p><p> </p><p> $resultset = $dbcon->prepare("INSERT INTO tbl_ads (_adid, _userid, _subcatid, _typeid, _title, _description, _price, _city, _status) VALUES (?,?,?,?,?,?,?,?,1);");</p><p> </p><p> $resultset->bindParam(1, $this->_adid); </p><p> $resultset->bindParam(2, $this->_userid);</p><p> $resultset->bindParam(3, $this->_subcatid); </p><p> $resultset->bindParam(4, $this->_typeid); </p><p> $resultset->bindParam(5, $this->_title); </p><p> $resultset->bindParam(6, $this->_description); </p><p> $resultset->bindParam(7, $this->_price); </p><p> $resultset->bindParam(8, $this->_city); </p><p> </p><p> $resultset->execute();</p><p> </p><p> if($resultset->rowCount()!=1)</p><p> {</p><p> $this->_message = 'Duplicate rows';</p><p> $dbcon->rollBack();</p><p> return(false); </p><p> }</p><p> </p><p> $resultset = null;</p><p> </p><p> </p><p> //Update image table</p><p> $tmpFilePath = '';</p><p> $filename = '';</p><p> $i = 0;</p><p> $uploadingpath = get_include_path().'images';</p><p> $allowedFileTypes = array("image/jpg","image/jpeg","image/bmp","image/gif","image/png");</p><p> </p><p> $resultset = $dbcon->prepare("INSERT INTO tbl_ads_images (_adid, _imagepath, _order) VALUES (?,?,?);");</p><p> $resultset->bindParam(1, $this->_adid);</p><p> $resultset->bindParam(2, $filename);</p><p> $resultset->bindParam(3, $i);</p><p> </p><p> for($i=0; $i<count($this->_pictures['name']); $i++) </p><p> {</p><p> $tmpFilePath = $this->_pictures['tmp_name'][$i];</p><p> </p><p> if($tmpFilePath == "")</p><p> {</p><p> $this->_message = 'Duplicate rows';</p><p> $dbcon->rollBack();</p><p> return(false); </p><p> }</p><p> </p><p> $fileType = $this->_pictures['type'][$i];</p><p> $ext = end((explode(".", $this->_pictures['name'][$i])));</p><p> $filename = $_SESSION['_user']['id'].'-'.time().'-'.$i.'.'.$ext;</p><p> $shortname = $this->_pictures['name'][$i];</p><p> $filePath = "$uploadingpath/uploaded/$filename";</p><p> </p><p> </p><p> if(!in_array($fileType,$allowedFileTypes))</p><p> {</p><p> $this->_message = 'Image type not allowed! Please upload JPG, JPEG, BMP, GIF or PNG images';</p><p> $dbcon->rollBack();</p><p> return(false);</p><p> }</p><p> </p><p> if ($this->_pictures['error'][$i] > 0)</p><p> {</p><p> $this->_message = 'Invalid Image! Unreadable or Damaged picture';</p><p> $dbcon->rollBack();</p><p> return(false);</p><p> }</p><p></p><p> if(!move_uploaded_file($tmpFilePath, $filePath)) </p><p> {</p><p> $this->_message = 'Internal Error! Please contact webmaster';</p><p> $dbcon->rollBack();</p><p> return(false);</p><p> }</p><p> </p><p> //100px resized images</p><p> $classImage->_load("$uploadingpath/uploaded/$filename");</p><p> $classImage->_resizeToWidth(100);</p><p> $classImage->_save("$uploadingpath/processed/100/$filename");</p><p> </p><p> //400px resized images</p><p> $classImage->_load("$uploadingpath/uploaded/$filename");</p><p> $classImage->_resizeToWidth(400);</p><p> $classImage->_save("$uploadingpath/processed/400/$filename");</p><p> </p><p> //800px resized images</p><p> $classImage->_load("$uploadingpath/uploaded/$filename");</p><p> $classImage->_resizeToWidth(800);</p><p> $classImage->_save("$uploadingpath/processed/800/$filename"); </p><p> </p><p> $resultset->execute(); </p><p> </p><p> }</p><p> </p><p> </p><p> $dbcon->commit();</p><p> Return (True);</p><p> exit;</p><p> }</p><p> else</p><p> {</p><p> $this->_message="No active database connection ";</p><p> return (false);</p><p> exit;</p><p> }</p><p> }</p><p> catch(exception $e)</p><p> {</p><p> $this->_message="Unexpected error:_open ".$e;</p><p> //$dbcon->rollBack();</p><p> return (false);</p><p> exit;</p><p> }</p><p> </p><p> </p><p> }</p><p> </p><p> public function _update()</p><p> {</p><p> </p><p> }</p><p> </p><p> public function _delete()</p><p> {</p><p> </p><p> }</p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p>}</p><p>?></p><p>[/PHP]</p></blockquote><p></p>
[QUOTE="lkzombie, post: 20509911, member: 462352"] [CENTER][SIZE="5"]Solved!!!! udaw karapu hamatama sthuthiy[/SIZE] [IMG]http://ayushflowergiftsportal.com/product_images/fa9bb2bd9c83db58e2bc13f59eb74754mixed-roses-and-lilly-bunch-500x500.jpg[/IMG][/CENTER] [PHP] <?php /** * ------------------------------------------------------------------ * Author : Sumal T.Jayaranga * Date Created : 2016-07-01 * Last Modified : * Brief : * ------------------------------------------------------------------ **/ include_once get_include_path().'cls/database/cls_dbconnection.php'; include_once get_include_path().'cls/misc/cls_images.php'; include_once get_include_path().'cls/misc/cls_session.php'; include_once get_include_path().'cls/business/cls_users.php'; class _ads { public $_adid = ""; public $_userid = ""; public $_subcatid = ""; public $_typeid = ""; public $_title = ""; public $_description = ""; public $_price = ""; public $_city = ""; public $_pictures = null; public $_message = ""; public function _open() { try { $classDB = new database(); $dbcon = $classDB->_getDBconnection(); $resultset = null; if($dbcon) { $resultset = $dbcon->prepare("SELECT * FROM tbl_ads WHERE _adid=:_adid AND _status=1;"); $resultset->execute(array(':_adid'=>$this->_adid)); $rows = $resultset->fetch(PDO::FETCH_ASSOC); $this->_adid = $rows['_adid']; $this->_userid = $rows['_userid']; $this->_subcatid = $rows['_subcatid']; $this->_typeid = $rows['_typeid']; $this->_title = $rows['_title']; $this->_description = $rows['_description']; $this->_price = $rows['_price']; $this->_city = $rows['_city']; $resultset = null; $resultset = $dbcon->prepare("SELECT * FROM tbl_ads_images WHERE _adid=:_adid;"); $resultset->execute(array(':_adid'=>$this->_adid)); if(!$resultset->rowCount()==0) { $this->_pictures = $resultset; } $dbcon = null; $classDB->close_db(); return(true); } } catch(exception $e) { $this->_message="Unexpected error:_open"; return (false); } } public function _save($userinfo="") { try { $classDB = new database(); $classImage = new _images(); $dbcon = $classDB->_getDBconnection(); $resultset = null; if($dbcon) { $dbcon->beginTransaction(); //Check user $resultset = $dbcon->prepare("SELECT * FROM tbl_users WHERE _userid=:_userid AND _status=1;"); $resultset->execute(array(':_userid'=>$this->_userid)); if($resultset->rowCount()!==1) { $this->_message="Invalid user!!"; $dbcon->rollBack(); return (false); } //Generate new id $resultset = $dbcon->prepare("SELECT _adid FROM tbl_parameters;"); $resultset->execute(); $rows = $resultset->fetch(PDO::FETCH_ASSOC); $this->_adid = $rows['_adid']+1; $resultset=null; //Update new id $resultset = $dbcon->prepare("UPDATE tbl_parameters SET _adid=:_adid;"); $resultset->execute(array(':_adid'=>$this->_adid)); if($resultset->rowCount()!==1) { $this->_message="System error: Parameter cannot be updated."; $dbcon->rollBack(); return (false); exit; } $resultset=null; $resultset = $dbcon->prepare("INSERT INTO tbl_ads (_adid, _userid, _subcatid, _typeid, _title, _description, _price, _city, _status) VALUES (?,?,?,?,?,?,?,?,1);"); $resultset->bindParam(1, $this->_adid); $resultset->bindParam(2, $this->_userid); $resultset->bindParam(3, $this->_subcatid); $resultset->bindParam(4, $this->_typeid); $resultset->bindParam(5, $this->_title); $resultset->bindParam(6, $this->_description); $resultset->bindParam(7, $this->_price); $resultset->bindParam(8, $this->_city); $resultset->execute(); if($resultset->rowCount()!=1) { $this->_message = 'Duplicate rows'; $dbcon->rollBack(); return(false); } $resultset = null; //Update image table $tmpFilePath = ''; $filename = ''; $i = 0; $uploadingpath = get_include_path().'images'; $allowedFileTypes = array("image/jpg","image/jpeg","image/bmp","image/gif","image/png"); $resultset = $dbcon->prepare("INSERT INTO tbl_ads_images (_adid, _imagepath, _order) VALUES (?,?,?);"); $resultset->bindParam(1, $this->_adid); $resultset->bindParam(2, $filename); $resultset->bindParam(3, $i); for($i=0; $i<count($this->_pictures['name']); $i++) { $tmpFilePath = $this->_pictures['tmp_name'][$i]; if($tmpFilePath == "") { $this->_message = 'Duplicate rows'; $dbcon->rollBack(); return(false); } $fileType = $this->_pictures['type'][$i]; $ext = end((explode(".", $this->_pictures['name'][$i]))); $filename = $_SESSION['_user']['id'].'-'.time().'-'.$i.'.'.$ext; $shortname = $this->_pictures['name'][$i]; $filePath = "$uploadingpath/uploaded/$filename"; if(!in_array($fileType,$allowedFileTypes)) { $this->_message = 'Image type not allowed! Please upload JPG, JPEG, BMP, GIF or PNG images'; $dbcon->rollBack(); return(false); } if ($this->_pictures['error'][$i] > 0) { $this->_message = 'Invalid Image! Unreadable or Damaged picture'; $dbcon->rollBack(); return(false); } if(!move_uploaded_file($tmpFilePath, $filePath)) { $this->_message = 'Internal Error! Please contact webmaster'; $dbcon->rollBack(); return(false); } //100px resized images $classImage->_load("$uploadingpath/uploaded/$filename"); $classImage->_resizeToWidth(100); $classImage->_save("$uploadingpath/processed/100/$filename"); //400px resized images $classImage->_load("$uploadingpath/uploaded/$filename"); $classImage->_resizeToWidth(400); $classImage->_save("$uploadingpath/processed/400/$filename"); //800px resized images $classImage->_load("$uploadingpath/uploaded/$filename"); $classImage->_resizeToWidth(800); $classImage->_save("$uploadingpath/processed/800/$filename"); $resultset->execute(); } $dbcon->commit(); Return (True); exit; } else { $this->_message="No active database connection "; return (false); exit; } } catch(exception $e) { $this->_message="Unexpected error:_open ".$e; //$dbcon->rollBack(); return (false); exit; } } public function _update() { } public function _delete() { } } ?> [/PHP] [/QUOTE]
Insert quotes…
Verification
Haya warak paha keeyada? (haya wadi kireema paha)
Post reply
Top
Bottom