Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
E

ELMAGLAYA

@ELMAGLAYA
About
Posts
6
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Why my fetch row method just repeats the first record multiple times (same count as my number of fields in the table)
    E ELMAGLAYA

    Thanks Ashwin for giving me ideas. I really appreciate it. I have managed to fix it.Please see my code below for main program. ===================================== $dbUser=DB::getInstance(); $dbUser->processQuery("SELECT * FROM users"); echo count($dbUser->getResultSet()); foreach($dbUser->getResultSet() as $rows){ echo $rows['username']; }

    Web Development database mysql question

  • Why my fetch row method just repeats the first record multiple times (same count as my number of fields in the table)
    E ELMAGLAYA

    Can you help me please what is the proper way. Thanks.

    Web Development database mysql question

  • Why my fetch row method just repeats the first record multiple times (same count as my number of fields in the table)
    E ELMAGLAYA

    I've tried code this below but it gives me one record and it repeats 7 times. Wrong output. Can anyone has a good heart to figure it out please. Please see my complete code below. I'm just a newbie in programming. Sorry. Thank you. =================================== OUTPUT: 1111111 =================================== _conn=new PDO("mysql:host=$this->_hostdb;dbname=$this->_namedb",$this->_userdb,$this-_passdb); $this->_conn- >setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); if($this->_conn){ echo "Connected Successfully!
    "; } } catch (Exception $ex) { echo ("Connection Failed!")."
    ".$ex->getMessage(); } } public static function getInstance(){ if(!isset(self::$_instance)) { return self::$_instance=new DB(); } } public function processQuery($sql){ try{ $q=$this->_conn->prepare($sql); $q->execute(); $q->setFetchMode(PDO::FETCH_ASSOC); return $this->rowResult=$q->fetch(); } catch (Exception $ex) { return ("Failed!")."
    ".$ex->getMessage(); } } public function getResultSet(){ return $this->rowResult; } //MAIN PROGRAM $dbUser=DB::getInstance(); $user=$dbUser->processQuery("SELECT * FROM users"); for($i=0;$irowResult);$i++){ echo $user['id']; } ?>

    Web Development database mysql question

  • How to fix this error $_SESSION:Notice: Undefined offset: 0
    E ELMAGLAYA

    Thank you sir.

    Linux, Apache, MySQL, PHP help php tutorial

  • Outputting ROW QUERY result to main program
    E ELMAGLAYA

    Hi, I'm a newbie in OOP. Can you please help me how to fix this code below because it gives me an infinite output. I want to output or echo my fetched data to my main program. Thanks. =========================================== class DB { private $_hostdb = 'localhost'; private $_namedb = 'imsdb'; private $_userdb = 'root'; private $_passdb = ''; private $_conn; private static $_instance; private $_rowResult; private function __construct(){ try{ $this->_conn=new PDO("mysql:host=$this->_hostdb;dbname=$this->_namedb",$this->_userdb,$this->_passdb); $this->_conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); if($this->_conn){ echo "Connected Successfully!
    "; } } catch (Exception $ex) { echo ("Connection Failed!")."
    ".$ex->getMessage(); } } public static function getInstance(){ if(!isset(self::$_instance)) { return self::$_instance=new DB(); } } public function processQuery($sql){ try{ $q=$this->_conn->prepare($sql); $q->execute(); $q->setFetchMode(PDO::FETCH_ASSOC); return $this->_rowResult=$q->fetch(); //Is this correct?? } catch (Exception $ex) { echo ("Failed!")."
    ".$ex->getMessage(); } } } //MAIN PROGRAM -> OUTPUT gives me an infinite data which is wrong $dbUser=DB::getInstance()->processQuery("SELECT * FROM users"); while($dbUser){ echo $dbUser['username']; }

    Linux, Apache, MySQL, PHP database help mysql tutorial question

  • How to fix this error $_SESSION:Notice: Undefined offset: 0
    E ELMAGLAYA

    Hi sorry I am just a baby in PHP. I want to get the value of $_SESSION['username'] but it gives me this error : Notice: Undefined offset: 0. Please see my code below. Your help will be greatly appreciated. Thanks. "; echo $_SESSION[0]; //I want an output "andrew" but it fails.

    Linux, Apache, MySQL, PHP help php tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups