98 Topics

Member Avatar for
Member Avatar for tony75

HI I'm working with a php script and connecting via PDO to a database My php file retrieves all data from datebase when I selected one radio button for example 2GB usb driver. This is my html code <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>form php pdo</title> </head> <body> …

Member Avatar for tony75
0
521
Member Avatar for dalilice

Hello, I have a little problem. This is what I want to achive: I have 2 mysql tables (categories, channels), the channel table has a cat_id in it. I want to update/edit a product and place it in another category but the code that I've made shows just one catedory …

Member Avatar for LastMitch
0
367
Member Avatar for rhodoscoder

<?php // post_view.php require 'connection.php'; $id =$conn->lastInsertId('id'); $stmt = $conn->prepare('SELECT * FROM posts WHERE id = LAST_INSERT_ID(id) LIMIT 1'); $stmt->execute(array('id' => 'LAST_INSERT_ID(id)')); while($row = $stmt->fetchAll(PDO::FETCH_ASSOC)) { //$row is an array object? that has one array in index 0 print_r($row); echo '<h2>'.$row[':title'].'</h2>'; //echo '<em>Posted '.date('F j<\s\up>S</\s\up>, Y', $row['date']).'</em><br/>'; echo nl2br($row[':body']).'<br/>'; echo …

Member Avatar for LastMitch
0
127
Member Avatar for rhodoscoder

<?php function html_escape($input) { return htmlspecialchars($input, ENT_COMPAT | ENT_HTML401, 'utf-8'); } require 'connection.php'; if(!empty($_POST)) { $ustmt=$conn->prepare('UPDATE posts SET title = :title, body=:body, WHERE id = :id'); $lpstid = $_GET['id']; $ustmt->bindValue('title', $_POST['title']); $ustmt->bindValue('body',$_POST['body']); $update_stmt->bindValue('id' , $lpstid); $ustmt->execute(); while($row = $update_stmt->fetch()){ print_r($row); } if($ustmt) redirect('post_view.php?id='.html_escape($_GET['id'])); } $sstmt = $conn->prepare('SELECT (title,body) FROM posts …

Member Avatar for diafol
0
207
Member Avatar for Eagle.Avik

why is the code below is not working? $sql = "SELECT password, fullname, active FROM ".$mysql_table.""; $sql = $sql . "WHERE username = :username, password = :password"; $statement = $pdo->prepare($sql); $statement->bindValue(':username', $_POST['username']); $statement->bindValue(':password', md5($_POST['password'])); $statement->execute();

Member Avatar for minitauros
0
554
Member Avatar for Eagle.Avik

hi, i am building a cms, when a user(already logged in) post anything, the script will check if the user is already exist or not if not it will create a new account(only save username and useremail) for the cms, so i can keep track of users. ok, so i …

Member Avatar for simplypixie
0
906
Member Avatar for dany12

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 …

Member Avatar for pritaeas
0
1K
Member Avatar for joshmac

I have this search method that doesn't seem to work, and I am not sure why. I need an extra pair of eyes to see why my search query brings back false results. Thanks in advance. public function search($data) { $person = $data['person']; $bind = [ ":person" => "%$person%" ]; …

Member Avatar for joshmac
0
944
Member Avatar for everton.retweets

Hi Everyone... I have been digging around the web for the last two days trying to fix this problem myself, but have come to the realization that I need some help. I have a mysql query that selects all country names from my country db, (works as described) I then …

Member Avatar for phorce
0
731
Member Avatar for titos97

On the form user enter rego no where it search database and display the output what i am looking is, if the entered data not match its should display " Record not found." <?php $search_Rego = ($_POST['RegoNo']); try { //open the database $db = new PDO('sqlite:iSearch.sqlite'); $result = $db->query("SELECT Fname …

Member Avatar for minitauros
0
361
Member Avatar for pritaeas

The following snippet shows how you can use binding in your queries when using PDO. For starters, here's the table structure I've used: CREATE TABLE `mytable` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) DEFAULT NULL, `email` varchar(255) DEFAULT NULL, `dob` date DEFAULT NULL, `level` int(11) DEFAULT NULL, PRIMARY …

3
1K
Member Avatar for joshmac

I am not a jquery guru in any sense, so I am seeking some help with the below code. What I am trying to do, is populate two input fields, based on what is selected from a dropdown field via a database call. When I select a term from the …

Member Avatar for joshmac
0
969
Member Avatar for kaneo

I don't know what I'm doing wrong here, but I'm having hard time trying to insert data from a form into the database.The $_session['username'] is set and the database is included and working Here is my table CREATE TABLE IF NOT EXISTS `accounts` ( `accid` int(11) NOT NULL AUTO_INCREMENT, `acc_number` …

Member Avatar for kaneo
0
352
Member Avatar for joshmac

I few weeks ago, I posted some code that I need help converting to MySQLi, now I need some help converting it to PDO. The code allows you to enter queries and commands and brings back the column headings and the information that I am looking for into a table. …

Member Avatar for joshmac
0
3K
Member Avatar for code_rum

Below is my code.. $stmt->execute($params) is not getting executed $name = $_REQUEST['name2']; $surname = $_REQUEST['surname2']; $add = $_REQUEST['add2']; $pdo = new PDO( "mysql:host = localhost;dbname = employee", "xxx", ""); $stmt = $pdo->prepare( 'INSERT INTO test_differ VALUES( :name2 , :surname2 , :add2 )' ); $params = array( ':name2' => $name, ':surname2' …

Member Avatar for code_rum
0
172
Member Avatar for Squidge

Hi All, I am using pritaeas found here: http://www.daniweb.com/web-development/php/code/430455/configurable-table-class I am pulling in the data and my brain has taken a vacation. I am using $arr = $dsn->getRecord('memeber', array('user_id' => 2)); But cannot for the life of me pull the data out. I get duplication as well from the data: …

Member Avatar for pritaeas
0
146
Member Avatar for tacticalweb

I just uploaded my current project on a free PHP hosting website and when i and my friend visited the website i got from PDO (MySQL) the error SQLSTATE[08004] [1040] Too many connections. I use a Singleton class to manage the PDO (so i create only 1 PDO instance to …

Member Avatar for tacticalweb
0
275
Member Avatar for LastMitch

Hi I am learning **PDO**. I already got my **PDO-DB** ready. The query works because it does fetch data when I echo out the data but I don't know how to echo out the data from the database to the dropdown list. I try to echo out this way (it …

Member Avatar for LastMitch
0
881
Member Avatar for ebc3142

I'm using this PDO query to fetch all the data I need from Value and dateid: $pdo = new PDO('mysql:host=localhost;dbname=contisec_portal', 'root', ''); $date = date("o-m-d"); $stmt = $pdo->query("SELECT stock_names.Value,stock_names.Fileid,date_header.dateid FROM stock_names,date_header WHERE SEDOL = '$stocksel' AND date_header.fileid = stock_names.FileID"); Does anybody know how I can sort the two columns into …

Member Avatar for ebc3142
0
142
Member Avatar for ebc3142

I'm trying to use this code to populate my drop down menu from a mysql table: <select name="fileselect"> <?php $pdo = new PDO('mysql:host=localhost;dbname=contisec_portal', 'root', ''); $stmt = $pdo->prepare("SELECT dateid FROM date_header"); $stmt = $pdo->execute(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo "<option value='" . $row['dateid'] . "'>" . $row['dateid'] . "</option>"; …

Member Avatar for diafol
0
6K
Member Avatar for rosse88

Okay, so I am not entirely sure how to fix this. Im attempting to make a tag feature for my site but I am getting: Fatal error: Call to a member function prepare() on a non-object in /Users/Home/Sites/functions/users.php on line 10 Here is the code that relates to this. First …

Member Avatar for rosse88
0
246
Member Avatar for ebc3142

Hi, I have these methods in my user class which check whether a username already exists and if not, inserts it into the database: //This function checks to see if the username entered already exists Private function check_user_exists() { $stmt = $this->_db->prepare('SELECT * FROM client_login WHERE Username = ?'); $stmt->execute(array($this->_username)); …

Member Avatar for veedeoo
0
290
Member Avatar for coolvasu

Hi everybody, i have problem in my php code (it just showing nothing....means no error no results).......can anybody tell me what is wrong with this code.....i'm new to PHP........here is my code <?php try { $config=array( 'DB_USERNAME'=>'root', 'DB_PASSWORD'=>'' ); $conn=new PDO('mysql:host=localhost;dbname=scc',$config['DB_USERNAME'],$config['DB_PASSWORD']); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo rand_id(); } catch(Exception $e) { echo …

Member Avatar for coolvasu
0
339
Member Avatar for cheelo007

Is there a service available to have someone translate your code from mysql to PDO or Mysqli? Pay service or free. I just know I'm in over my head. Thank you.

Member Avatar for cheelo007
0
165
Member Avatar for Clanstrom

Hi, I am chaging from mysql_* to PDO and I found this tutorial in [Here](http://net.tutsplus.com/tutorials/php/php-database-access-are-you-doing-it-correctly/) And, so far let's say I chose this query to update a database. $id = 5; $name = "Joe the Plumber"; try { $pdo = new PDO('mysql:host=localhost;dbname=someDatabase', $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $pdo->prepare('UPDATE someTable …

Member Avatar for Atli
0
290
Member Avatar for romanromeo89

Hello I'm running a php function to get some user information from mysql using pdo. The problem is that i don't get the results i want. This is my php code: <?php require_once('db_connect.php'); function mila(){ global $dbh; // Set dummy variables $required_id=1; // Select table with query $sth = $dbh->prepare("SELECT …

Member Avatar for diafol
-1
219
Member Avatar for masocha

l need to generate a dynamic PDO update query. l am not sure of the behaviour where we have the same placeholder name in th update and WHERE clause for example UPDATE users SET name = 'Master User' WHERE name = 'Dev User' As you can see placeholder name will …

Member Avatar for diafol
0
65
Member Avatar for diafol

Hi All. Have been messing around with PDO for a while, but have come across a bit of a quandry. I like the prepare - execute method for fetching data, but I needed to check if an update query actually did update or not. Now not having mysql_affected_rows() to hand, …

Member Avatar for diafol
0
1K
Member Avatar for pritaeas

Below is a documented code example showing how to use the [PDO](http://php.net/pdo) classes/objects to connect and query your database (and check for errors). If there are any questions, or you want to see different features, let me know. UPDATE: I've encountered a problem with PDO and bit fields (MySQL). If …

Member Avatar for sammry
2
3K
Member Avatar for gilgil2

Hi I have the following code being used to insert some data into a MySql database, all the error checks etc. are done before and those are fine, and the code returns connected successfully but nothing is put into the database, nor does the database check for duplicate usernames, because …

Member Avatar for iamthwee
0
2K

The End.