Member Avatar

Hi I am trying to create a update function. But it not updating in the database. Please help me to fix. **Test-2.php** $whereString = ''; $bind = NULL; if(isset($_POST['Submit'])) { if($_POST) { $SCYQ64UKID = $_GET['SCYQ64UKID']; $SCYQ64AVGP = $_POST['SCYQ64AVGP']*100; $searchFields = array('SCYQ64EMAL'=>$_POST['SCYQ64EMAL'],'SCYQ64EV01'=>$_POST['SCYQ64EV01'],'SCYQ64EV02'=>$_POST['SCYQ64EV02'],'SCYQ64EV03'=>$_POST['SCYQ64EV03'],'SCYQ64EV04'=>$_POST['SCYQ64EV04'],'SCYQ64EV05'=>$_POST['SCYQ64EV05'],'SCYQ64EV06'=>$_POST['SCYQ64EV06'],'SCUSER'=>$_POST['SCUSER'],'SCYQ64AVGP'=>$SCYQ64AVGP,'SCYQ64TZ'=>$_POST['SCYQ64TZ'],'SCJOBN'=>gethostname(),'SCPID'=>'SSWEB','SCUPMJ'=>$_POST['SCUPMJ'],'SCUPMT'=>$_POST['SCUPMT']); if($post = array_filter($_POST)) { if($fields = array_intersect_key($searchFields, $post)) { $where = array(); $bind = array(); foreach($fields as $key=>$field) { $where[] = "$key LIKE '%$field%'"; $bind[":$key"] = $_POST[$key]; $gwhere[] = "$key=$field"; $gbind[":$key"] = $_POST[$key]; } //$whereString = ' WHERE ' . implode(' AND ', $where); $gwhereString = implode(',', $gwhere); } $Users = new Users($db); $query = $Users->smipleUpdate('FQ64000',$gwhereString,'SCYQ64UKID='.$SCYQ64UKID); } } } …

Member Avatar
+0 forum 12
Member Avatar

Hi I am trying to display count of a row using function with get values. Please help me to fix the issue **class** class Users { private $conn; private $db_name= "DATABASE"; public function __construct($db) { $this->conn = $db; } /*Join Two Tables with where condition and order by*/ public function getJoinRows($tablen1,$tablen2,$where,$order_by){ $query = $this->conn->prepare("select * FROM $this->db_name.$tablen1,$this->db_name.$tablen2 where $where ORDER BY $order_by DESC"); try { $query->execute(); return $query; }catch(PDOException $e) { die($e->getMessage()); } } /**/ public function transCount($tablen,$whereCondition) { $query = $this->conn->prepare("select count(*) from $this->db_name.$tablen where $whereCondition"); try{ $query->execute(); return $row_count = $query->fetchAll(); }catch(PDOException $e) { die($e->getMessage()); } } } …

Member Avatar
+0 forum 5
Member Avatar

I have created a function. if i provide correct username and password. i am getting a error message as **Sorry, that username / password is invalid !** can any one please help me to fix the issue. **login.php** <?php require 'include/init.php'; $general->logged_in_protect(); if(empty($_POST) === false) { $username = trim($_POST['username']); $password = trim($_POST['password']); if(empty($username)===true || empty($password)=== true) { $errors[] = 'Sorry, But we need your username and passowrd.'; } else { $login = $users->login($username, $password); if($login === false) { $errors[] = 'Sorry, that username / password is invalid'; } else { $_SESSION['user_'] = $login; header('Location: dashboard.php'); exit(); } } } ?> …

Member Avatar
+0 forum 3
Member Avatar

Hi I am trying to connection my database ODBC using function. I am getting an error **Connection error: could not find driver** **mycode is** <?php class Database{ // specify your own database credentials private $host = "servername"; private $db_name = "databsename.schemaname"; private $username = "username"; private $password = "password"; public $conn; // get the database connection public function getConnection(){ $this->conn = null; try{ $this->conn = new PDO("odbc:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password); }catch(PDOException $exception){ echo "Connection error: " . $exception->getMessage(); } return $this->conn; } } ?> Please help me to fix the issue.

Member Avatar
+0 forum 12
Member Avatar

Hi all, I've been working with PHP, using procedural methods, for several years now, and have begun to explore the object-oriented side of it. While it didn't take me long to understand the potential advantages that come with working in this manner, I'm still having some trouble wrapping my head around doing the things I used to do procedurally in an object-oriented manner. A lot of the tutorials cover the basic applications of classes, properties, and methods, but I'm having trouble applying them to projects I'm working on. For instance, I have a form, that I put a class together …

Member Avatar
+0 forum 15
Member Avatar

Greetings, I'm having problems with my output. Essentially I am just trying to print out any Cat who is over 3 years old and has Claws. But my output keeps printing out either nothing at all or the 3rd cat 3 times. I've struggled with this for hours trying to figure out why.. any ideas? This is my driver java file. It will compile and run just fine but it doesn't work like it is supposed to.. import java.util.Scanner; public class NathanialProg6 { public static void main(String[] args) { Scanner input = new Scanner(System.in); Cat cat1 = new Cat(); Cat …

Member Avatar
+0 forum 3
Member Avatar

please tell me in how many ways OBJECT ORIENTED PROGRAMMING is different from procedural programming in JAVA

Member Avatar
+0 forum 6
Member Avatar

I can't seem to get a response from my query method. I have a database connection from method ping_server and use mysqli as connector. Can anyone help me figure out why I cannot print results from mysqli_fetch_array. dbclass.php class db { private $connection; private $selectdb; private $lastQuery; private $config; function __construct($config) { $this->dbConfig = $config; } function __destruct() { } public function openConn() { try { if($this->dbConfig->connector == "mysqli") { $this->connection = mysqli_connect($this->dbConfig->hostname, $this->dbConfig->username, $this->dbConfig->password); $this->selectdb = mysqli_select_db($this->dbConfig->database,$this->connection); } } catch(exception $e) { echo'Caught Exception:', $e->getMessage(), "\n"; } } public function closeConn() { try { if($this->dbConfig->connector == "mysqli") { mysqli_close($this->connection); …

Member Avatar
+0 forum 4
Member Avatar

This started out as `I love PHP traits! I'm going to use them everywhere! ^_^` and now it has turned into a `Thought Exercise / Learning Experience >_<`. Consider the following example: trait TheErrorOfYourWays{ public function booboo(){ echo 'You had a booboo :('; } } trait SpectacularStuff1 { use TheErrorOfYourWays; } trait SpectacularStuff2 { use TheErrorOfYourWays; } class DoSomethingSpectacular { use SpectacularStuff1, SpectacularStuff2; } This results in (obviously): > Fatal error: Trait method booboo has not been applied, because there are collisions with other trait methods on DoSomethingSpectacular. **So my question: How do I resolve method conflicts in traits? Is …

Member Avatar
+2 forum 6
Member Avatar

Having just found 'traits' - see http://www.daniweb.com/web-development/php/threads/468928/php-trait-method-conflicts-trait-inheritance#post2043565 I was wondering whether they could be used to share a DB connection object across disparate classes, or would the old singleton or dependency injection methods still be the way to go? I'd value any views on this.

Member Avatar
+2 forum 2
Member Avatar

Hi All, I am trying to connect to a database OOP singleton method. I am getting an error "syntax error, unexpected 'function_construct'" and I unable to find the syntax error in the code. Any help with this would be appreciated. Thanks in advance David // Page: index.php <?php require_once 'classes/db.php'; echo '<pre>', print_r(DB::getInstance()->query('SELECT * FROM Users')->results()), '</pre>'; //classes/db.php <?php //classes/db.php class DB { private $_mysqli, $_query, $_results = array(), $_count=0; public static $instance; public static function getInstance(){ if (isset(self::$instance)){ self::$instance = new DB(); } return self::$instance; } public function_construct(){ $this->_mysqli = new mysqli('localhost','xxxx','xxxxx','db301847341'); if($this->_mysqli->connect_error) { die($this->_mysqli->connect_error); } } public function …

Member Avatar
+0 forum 5
Member Avatar

I would like some help with my connect class.This class is created by me it is my way of thinking so i would like to know why this class dossent get my variables and connect proprely to mysql. the code <?php /** * Exp:Connect to database in oop style @params host dbname username password */ class Connect { //private only available forthe current class private $host=null; private $dbname = null; private $username = null; private $password = null; function __construct($host,$dbname,$username,$password) { $this->host = $host; $this->dbname = $dbname; $this->username = $username; $this->password = $password; $host = "localhost"; $dbname = "testoop"; $username …

Member Avatar
+0 forum 6
Member Avatar

Hy I want to understand what is a better approach on problem solving point of view for a php project , a framework or the mvc pattern? I would like to add that I know that both principels are quite the same but with a minor diffrence that a framework was made by someone else and has his style applied to it and a mvc pattern you build your own classes and templates and create it in your own style. My concern regarding the mvc pattern is that a application build from scartch is harder to do and create a …

Member Avatar
+0 forum 5
Member Avatar

today a friend told me that Hunain, did you notice that OOP concepts like inhertance, polymorphism, interface etc aren't usuallt applied to ASP.net. so it made me confused and thought for a while, and yes he seems to be right ! i never used any of them adn even most complex asp.net developers never did, among my teachers or friends, is it so ?

Member Avatar
+0 forum 3
Member Avatar

Hi all, I've literally JUST dived into OOP and it's a totally different world. I've written some pretty awful code just to grasp OOP basics. The following code is all in the same file and runes fine, there are no warnings, errors, notices and so forth yet it doesn't work correctly... I think it's something dead simple and if it is I promise to facepalm as hard as I can. Thanks for any help in advance. # Code: # <?php error_reporting(E_ALL); class database{ protected $_link, $_result, $_numRows; public function __construct(){ $this->_link = mysqli_connect('localhost', 'root', '', 'studybubble') or die(mysqli_error()); } public …

Member Avatar
+0 forum 11
Member Avatar

I'm working on an ORM experiment, and I'm looking for ideas to help choose which path to take in it's development. I currently have an index showing how to use it, two interfaces, a database class, a table base class and two auto-generated classes (representing a database table). The first on my list is to implement the Update method (Read and Delete work). I'm also thinking of extending the BaseTable with methods, so the restrictions from MySQL are automatically used. It also needs a database interface check, so the database class can be swapped, as long as it is implementing …

Member Avatar
+1 forum 9
Member Avatar

Hello! So I currently have a class titled Appliciation which contains a method called start. <?php class Application { /* * Application class */ public function __construct($IceTray){ $this->IceTray = $IceTray; } /* Starts application */ public function start(){ /* Confiures error reporting */ $this->IceTray->Error->configure(); $Path = $IceTray->Path; include APPDIR.'/paths.php'; $Path->start(); } } I'm including this file that will only use the Path object. When the script is run I get this error: Fatal error: Call to a member function set() on a non-object in C:\wamp\www\IceTray\application\paths.php on line 16 So obviously the Path variable/object isn't in the scope of the included …

Member Avatar
+0 forum 5
Member Avatar

Hi All - I am trying create classes for db connection and I am getting the following error Thanks in advance D Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'XXXXXXX_david'@'localhost' (using password: YES) in /home/djenning/public_html/dbconnection/connection.php on line 20 Cannot connect to the database page: connection.php <?php class createConnection //create a class for make connection { var $host="localhost"; var $username="xxxxxxx_david"; // specify the sever details for mysql var $password="XXXXXXXX"; var $database="databaseclass"; var $myconn; function connectToDatabase() // create a function for connect database { $conn= mysql_connect($this->host,$this->username,$this->password); if(!$conn)// testing the connection { die ("Cannot connect to the database"); } else { $this->myconn = …

Member Avatar
+0 forum 22
Member Avatar

ok here is the login function from my class user which parent class is a Db connection file <?php require_once("DBConnection.php"); class User extends DBConnection { .... .... ... ... public function Login() { $sqlSelect = "select `UserName` from `user` where `UserName` = '$this->userName' and `Password` = '$this->password'"; $result = @mysql_query($sqlSelect, $this->get_Conn()); // $dataCount = mysql_num_rows($result); if(mysql_num_rows($result) == 0) { throw new Exception("Login Failed"); } $userData = mysql_fetch_assoc($result); extract($userData); $this->userId = $UserId; $this->firstName = $FirstName; $this->middleName = $MiddleName; $this->lastName = $LastName; $this->email = $Email; $this->userName = $UserName; $this->password = NULL; $this->loginStatus = true; $_SESSION['objUser'] = serialize($this); if($remember) { $struser = serialize($this); …

Member Avatar
+0 forum 9
Member Avatar

Here is the code: var Circle = function( radius ) { var _radius = radius, _area = function() { return Math.PI * _radius * _radius; }, _perimeter = function() { return 2 * Math.PI * _radius; }; this.radius = _radius; this.area = "Area" + _area(); this.perimeter = "Perimeter" + _perimeter(); this.setRadius = function( radius ) { _radius = radius; }; }; However I cannot get the this.setRadius() function to successfully mutate the private properties. For instance, I run this: var circle = new Circle(5); alert(circle.area); circle.setRadius(10); alert(circle.radius); And it outputs 78.blah which is correct, then it outputs a radius of …

Member Avatar
+0 forum 1
Member Avatar

Hello! I'm working on a mini framework and everything is going great, exvept this one part that I have gotten working but it brings more complications and it's extremely confusing to me. So I will summarize what is going on. Essentially I have a class (a controller, we'll call this class A) that is extending another class (Class B), in class A I want the ability to say `$this->fetch->view('main');` which I have gotten working, but it was of course taking place outside of class B and class A. I would like this to take place in class B somehow so …

Member Avatar
+0 forum 18
Member Avatar

Hi, I been learning **OOP** slowly. I'm stuck how to resolved an **function query() on a non object issue**. My files are very basic: This is my **db.php** file: <?php global $db; class foo_mysqli extends mysqli { public function __construct($host, $user, $pass, $db) { parent::__construct($host, $user, $pass, $db); if (mysqli_connect_error()) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } } } $db = new foo_mysqli('localhost', 'my_user', 'my_password', 'my_db'); $db->close(); ?> This is my **function.php** file <?php include("db.php"); function PM() { $sql = "SELECT * FROM posts"; $result = $db->query($sql) or die("It's not connecting"); while($row = $result->fetch_assoc($sql)) { …

Member Avatar
+0 forum 21
Member Avatar

hey all i am new to all this languages and Computer sciences so if you help me i am trying to write a code and its constantly giving me errors here is the code at line 10 , 102 , 115 tell me how to fix it.. waiting... #include<iostream.h> void get_input(double sal[][2], int numemps); void calc_net_sal(double sal[][2], int numemps); void find_unluckies(double sal[][2], int numemps, int lucky[]); void mark_if_unlucky(double sal[][2], int numemps, int lucky[], int upperbound, int empnbr); void print_unluckies(int lucky[], int numemps) void main(void) { const int arraysize=100; double sal[arraysize][2]; int lucky[arraysize] = {0}; int numemps; // getting input abt …

Member Avatar
+0 forum 6
Member Avatar

I am trying to create a function which adds an array to another array and replaces the data in the 1st array with the new data. For example, A=A+B. However, when I write my code as below, I get the error C2676:binary '[' : 'const Matrix' does not define this operator or a conversion to a type acceptable to the predefined operator. void Matrix::add(const Matrix&m){ for(int i=0; i<9; i++){ data[i]=data[i]+m[i]; } } Thanks in advanced for the help!

Member Avatar
+0 forum 2
Member Avatar

Hi I'm having issue of understand how to **echo** a variable when the `class` is `extended`. I have **2** files. This is my **index.php** file: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>OOP Example</title> <?php include("class.php"); ?> </head> <body> <?php $mitch = new person("Mitch Last"); echo "Mitch's full name: " . $mitch->get_name();"</br>"; $last = new coworker("Last Mitch"); echo "</br>Last's full name: " . $last->get_name();"</br>"; $slim = new coworker("Slim Jim"); echo "</br>Slim's full name: " . $slim->get_name();"</br>"; ?> </body> </html> This is my **class.php** file: <?php class person { // To defined adding class properties are optional var $name; …

Member Avatar
+4 forum 15
Member Avatar

In this example, what's the difference between creating a class variable from the "class Employee" & creating an object from the class GenQueue ?! What's the difference in uses and implementation? import java.util.LinkedList; class GenQueue { private LinkedList list = new LinkedList(); public void enqueue(E item) { list.addLast(item); } public E dequeue() { return list.poll(); } public boolean hasItems() { return !list.isEmpty(); } public int size() { return list.size(); } public void addItems(GenQueue q) { while (q.hasItems()) list.addLast(q.dequeue()); } } public class GenQueueTest { public static void main(String[] args) { GenQueue empList; empList = new GenQueue(); GenQueue hList; hList = …

Member Avatar
+0 forum 4
Member Avatar

Hi, I'm learning OOP and I'm having issue echoing an `attribute` function. This is my example: <?php class sandwich { function sandwich($hero) { echo "I like to eat $hero sandwich.<br>"; } } $a = new sandwich("roast beef"); $b = new sandwich("pastrami"); $c = new sandwich("turkey"); ?> When I echo it out: I like to eat roast beef sandwich. I like to eat pastrami sandwich. I like to eat turkey sandwich. Here is my `attribute function` with the same format: <?php class sandwich { var $attribute; function operation($hero) { $this->attribute = $hero; echo $this->attribute; } } $a = new sandwich("roast beef"); …

Member Avatar
+0 forum 11
Member Avatar

Hi, I want to know how did I came up with this error when I run my code: `Trying to get property of non-object in line 19.` What does it mean? I want to echo out `My favorite candy is M&M Peanuts.` But instead I echo out `My favorite candy is`. Here is my code: <?php class candy { public $MnM='M&M Peanuts'; public function __construct($MnM) { $this->MnM = $MnM; } public function get_MnM() { return $this->MnM; } } echo 'My favorite candy is '. $MnM->MnM.'.'; ?> Any Suggestions and explanation will help. I appreciate it. Thank!

Member Avatar
+0 forum 6
Member Avatar

with a lil bit of change in code ,it's functioning, but I want it to function with data members being private :-/ #include<iostream.h> #include<conio.h> class account{ public: int account_number; float balance; int passw; public: void display() { cout<<"Account number is:"<<account_number<<endl<< "Account balance is:"<<balance<<endl; } void user(int acc, float amou, int passy) { account_number=acc; balance=amou; passw=passy; } void validate(int acce, int passu) { account_number=acce; passw=passu; } }; void main() { int acno; float amount; int const n=1; account uxi[n]; int pass; for(int i=0;i<n;i++) { cout<<"Enter account number"; cin>>acno; cout<<"set the password for your account"; cin>>pass; cout<<"Enter the amount you want to …

Member Avatar
+0 forum 4
Member Avatar

I am not new to OOP I am tidying up a very large site of mine and trying to create a much better structure (more in keeping with the whole point of OOP). I have decided to use mysqli (please don't suggest PDO as I have decided againast it) which is new to me and am a little confused to say the least with a problem I am having with a basic select * query. In my database class I have the following functions (only the ones relevant to this thread): public function selectAll($table, $fields = '*', $where = NULL, …

Member Avatar
+0 forum 7

The End.