mysqli

PHP and MYSQLi - Bind parameters using loop and store in array?

Hi, It will be easier to explain with the next code (It's wrong, by the way): $selectGenre_sql = 'SELECT genreID FROM genres WHERE dbGenre = ?'; if ($stmt->prepare($selectGenre_sql)) { // bind the query parameters $stmt->bind_param('s', $genre); // bind the results to variables $stmt->bind_result($genres); // execute the ...

Having a problem with mysqli and prepared statments.

I have the following function and its always returning false. It does not even try to execute the statement, I know because I changed the $query = "aldfjaf lkjfsk" and it did not return an error for me. Any suggestions? class Mysql { private $conn; function __construct() { $this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB...

Why would print_r ($row); only be returning a number 1?

I am trying to learn PHP5 and am having a couple of problems with it. I am working with prepared statements and am trying to run the following code: <?php require_once 'includes/config.php'; $conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database.'); $query = "SELECT * FROM...

Having problems inserting and updating tables in a database with prepared statements

Very new to PHP5 and have some problems still. I figured out how to Select with prepared statements now trying to insert/update my code is as follows function input_lab_results($name, $image, $descrip) { $query = "INSERT INTO pat_table (pat_name, pat_image, pat_descrip, pat_doctor, pat_resident, pat_create, pat_modify) VALUES (?, ?, ...

Multiple mysqli connection problems

I am having some strange issues with mysqli connections. I was working on a page with mysqli, and it has been working fine all day. I then made a copy of this page, and stripped it down to debug a problem, and tested it as a different file. It worked fine connection wise. Upon trying to request the original file I was working on, I get ...

mysqli for php on Ubuntu 8.04 LAMP stack

Does anyone know how, on Ubuntu 8.04, with PHP 5 and MySQL 5.0, to enable/install the mysqli package/extensions? Preferably I'd like to preserve the existing installations, but, if necessary, I'll reinstall from scratch. I realise it's not, technically, programming-related but, I think (at a stretch, maybe) it's programming-enabling? h...

MySQL - pass database field through PHP function before returning result

The following code from http://php.morva.net/manual/en/mysqli-stmt.bind-result.php shows a mysqli query being prepared and executed. while ($stmt->fetch()) loop looks like it is generating the result resource. Can I change this to include a call to a function e.g. while ($stmt->fetch()) { foreach($row as $key => $val) { ...

mysqli why does this happens?

I have two subsequent mysqli statements, and the second returns: Fatal error: Call to a member function bind_param() on a non-object in ... Why this happens? Does this means that I need to open two different connection? Is there any way to avoid this (I love keeping the SQL connection details in one file)? Here the code: $db = ne...

parameters in MySQLi

Hi - I'm using PHP with MySQLi, and I'm in a situation where I have queries like SELECT $fields FROM $table WHERE $this=$that AND $this2=$that2 So far I've written some code that splices up an array that I give it, for example: $search = array(name=michael, age=20) //turns into SELECT $fields FROM $table WHERE name=michael AND age=2...

displaying the contents of a mysql query, only first field works

I am using a mysqli prepard query with php, the code is: $retreiveQuery = 'SELECT username, firstname, lastname FROM USERS WHERE username = ?'; if ($getRecords = $con->prepare($retreiveQuery)) { $getRecords->bind_param("s", $username); $getRecords->execute(); $getRecords->bind_result($username, $firstname, $lastnam...

Associative arrays and binding parameters

I've gotten a little confused with the PDO::prepare functions. I have something like this array('user_email'=>'[email protected]','user_pass'=>'password') and i'd like to translate it into something like this INSERT INTO user_info (user_email, user_pass) VALUES ([email protected], password) using parameterized queries with PDO (or mysqli,...

Looking for a good php mysqli class tutorial

Hi, I'm looking for a good tutorial that describes how to create your own complete mysqli connection class, maybe demonstrating catching and all that good stuff. If your wondering I have in fact done some some searching of my own, but I have not found any articles that really go into detail. ,Thanks ...

SELECT * FROM in MySQLi

My site is rather extensive, and I just recently made the switch to PHP5 (call me a late bloomer). All of my MySQL query's before were built as such: "SELECT * FROM tablename WHERE field1 = 'value' && field2 = 'value2'"; This made it very easy, simple and friendly. I am now trying to make the switch to mysqli for obvious security re...

What is a simple solution for dynamic mysqli bind_param arguments in PHP?

To build a bind_param dynamically, I have found this on other SO posts. call_user_func_array(array(&$stmt, 'bindparams'), $array_of_params); Can someone break this down in plain english for me? I get especially lost that the first argument is an array. ...

PHP/MySQLi: SET lc_time_names and DATE_FORMAT() into a mysqli query??

Hi, I use the next code to retrieve data from a table in the database: $check_sql = 'SELECT personID, name, DATE_FORMAT(persons.birthdate, "%d de %M, %Y"), birthplace, countryID FROM persons WHERE personID = ?'; if ($stmt->prepare($check_sql)) { $stmt->bind_param('i', $pid); $stmt->bind_result($personDB, $name, $birthdate, $birthpl...

Moving from mysql to mysqli or pdo?

Duplicate: mysqli or PDO - what are the pros and cons? I'm looking to move a website from mysql to either mysqli or pdo as primarily a learning tool, but also for performance increases if possible. I have read through http://php.net/manual/en/mysqli.overview.php and it seems like both would suit my needs, but it doesn't lean stro...

How do you use IN clauses with mysqli prepared statements

I’m moving some old code over to the new msqli interface using prepared statements, I’m having trouble with SQL statements containing the IN clause. I would just normally do this: $ids = '123,535,345,567,878' $sql = "SELECT * FROM table WHERE id IN ($ids)"; $res = mysql_query($sql); Converting this to mysqli and prepared statements I ...

Database Error

I have a site that gets just about 100 people everyday but I got this error message when log in as a user: Warning: mysqli::mysqli() [mysqli.mysqli]: (42000/1203): User mexautos_Juan already has more than 'max_user_connections' active connections in /home/mexautos/public_html/kiubbo/data/model.php on line 26 Warning: mysqli::query() [m...

PHP/MySQL: The right way creating a big website database based...

Hi, I'm creating a movies website, IMDB.com like.. I'm really new to PHP and programming at all but I have some books and StackOverflow of course :) I have already done lot of the work, but now I have more than 600 lines of code (PHO only) per page and more than 20 database tables only for storing and geting the movie data (many-to-many...

Use one bind_param() with variable number of input vars

I try to use variable binding like this: $stmt = $mysqli->prepare("UPDATE mytable SET myvar1=?, myvar2=... WHERE id = ?")) { $stmt->bind_param("ss...", $_POST['myvar1'], $_POST['myvar2']...); but some of the $_POST['...'] might be empty so I don't want to update them in the DB. It's not practical to take into account all the differen...