mysqli

mysql insert problem

ive got a really weird problem. i have no clue why its not working. i create an user and get the id and insert a row based on that id in another table. the row gets inserted with that id but the other values however for that row are not inserted! $user_id = mysqli_insert_id($this->connection); $query = "INSERT INTO selections (user...

Is the method Doctrine_Table::find() deprecated?

Hi, I had a problem with the method Doctrine_Table::find(), since it's thorowing an exception of SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens I solved the problem by using Doctrine::getTable('City')->findOneById($id); instead and it works fine. When I tried to invistigate about t...

Unable to connect to MySQL through PHP script when using mysqli or PDO BUT mysql works.

I am facing a weird situation. When I am trying to connect to MySql database using a "mysql" connection, it works. mysql connection string -> mysql_connect($HOST, $USER, $PASSWORD, $DB); But the connection fails immediately fails when I use either "mysqli" or "PDO" mysqli connection string -> mysqli_connect($HOST, $USER, $PASSWORD, ...

How to dynamically generate SQL query based on user's selections?

I need to create a GUI, using which users can select several attributes which will be used to query the database to find suitable persons. I'm looking for ideas how to dynamically generate the database query according to user's choices. Query will contain several fields, but to get the idea I will include only three of those below as an...

Objects versus Arrays

I am working on a site at the moment, and there is a concentrated focus on efficiency and speed in loading, processing and such like. I'm using the mysqli extension to get my database bits and bobs, but I'm wondering what's the best / most efficient way of outputting my dataset? At the moment I'm using $mysqli->fetch_assoc() and a fore...

PHP mysqli::autocommit VS "START TRANSACTION"

In our database layer object, we have always managed transactions with "START TRANSACTION", "ROLLBACK" and "COMMIT" SQL statements executed via mysqli::query. Doing some research today, I discovered this mention in the MySQL Manual regarding using API level calls to manage a transaction VS using straight SQL: Important Many API...

dynamically change mysqli connection timeout in PHP

Hi, how can I dynamically change MySqli connection timeout using PHP? I found the following manual that you can set an option after a connection is opened, but it says it only support Windows since PHP 5.3.1: http://www.php.net/manual/en/mysqli.options.php I'm using PHP5.2.4, MySQLi (improved version) the default connection timeout is...

Problem with getting ID after inserting a record that has relation in Doctrine

Problem was solved check my answer Hi, I'm having a trouble with getting the id after inserting a new Record using PHP Doctrine Project. In inserting a new record in a table with no parent table (no foreign key) no problem happens. But when inserting a related record here comes the problem, that I get only the parent id which is use...

warning problem: expects parameter 1 to be mysqli_result

I get the following warning listed below and I was wondering how do I fix it Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given on line 65 The code is around this section of PHP code listed below. I can list the full code if needed. // function to retrieve average and votes function getRatingText(){ ...

MySQLi equivalent of mysql_result() ?

I'm porting some old PHP code from mysql to MySQLi, and I've ran into a minor snag. Is there no equivalent to the old mysql_result() function? Because I can't find one anywhere in the documentation, here on Stack Overflow, or anywhere else with Google... I know mysql_result() is slower than the other functions when you're working with...

ext/mysql charset support vs ext/mysqli charset

Hi, I read some articles that promoted the use of the new ext/mysqli in php due to it's support of character sets. I currently use ext/mysql and use SET NAMES UTF-8 to ensure all my data is stored as utf-8. isn't that charset support in ext/mysql or am I missing something larger? Thanks :) ...

Can't pass mysqli connection in session in php

I'm trying to pass a session with mysqli connection for multiple queries on the site, but when I try to do a query it outputs a warning "Couldn't fetch mysqli" $_SESSION['db']=new mysqli($host,$username,$password,$db); Is it impossible to pass a mysqli connection reference thru session? is there a different method to use? ...

using prepared mysqli statements to bind parameters into the SELECT section of a query

I am building a web app that imports data from data feeds in php/mysql. I import the data into a buffer/temp holding table. As each data format is different I choose the column to select based on the particular source. I am having trouble getting this query to work in this context : $stmt = $this->dbObj->prepare("SELECT mk.PK_phone_mak...

mysql never releases memory

I have a production server clocking about 4 million page views per month. The server has got 8GB of RAM and mysql acts as a database. I am facing problems in handling mysql to take this load. I need to restart mysql twice a day to handle this thing. The problem with mysql is that it starts with some particular occupation, the memory con...

PHP/PDO - Flush privileges

Hi, I'm doing some mysql server management with a script that flushes the MySQL users privileges when new privileges are added to a MySQL user. I'm using the PDO class to do my queries, but when I do a simple FLUSH PRIVILEGES; I get, for $connection->exec('FLUSH PRIVILEGES;'); and $connection->query('FLUSH PRIVILEGES;'); S...

Inserting into database with stmt and mysqli

Hi there i'm playing with stmt for the first time (looking at converting my code over after previously using standard mysqli functions through an extension class. However I can't seem to get it working. I'm using PHP 5.2.11 and mysql 4.1.22. I've got a table structure like so: CREATE TABLE IF NOT EXISTS `tags` ( `tag_id` smallint(3...

What is difference between mysql,mysqli and pdo ?

What is difference between mysql,mysqli and pdo ? Which one is the best suited to use with PHP-MYSQL? ...

PHP Mysqli inserting a row to a table with auto_increment column

Im working on a table that has 4 columns and the first one is an auto incrementing integer called id. If im going to insert into this table using mysqli prepared statements I keep having trouble inserting a query that works. Using PHPmyAdmin It tells me to give it NULL. Ive tried this: $query = "INSERT INTO tbl (id, col2, col3, col4) V...

Mysqli giving me problems: Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given in

I know that this code works on another site i've got but it's not playing ball today. I get three warnings: Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given in /homepages/14/d248783986/htdocs/subdomains/clients.bionic-comms.co.uk/httpdocs/carefree/process.php on line 33 Warning: mysqli_exec...

mysqli_error() expects exactly 1 parameter, 0 given

Hi, I am trying to get my head around mysql. Can someone tell my why this mysql query is not working? I am getting the following error: Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/freebet2/public_html/test.php on line 11 test.php <?php require_once($_SERVER['DOCUMENT_ROOT'].'/includes/db.ph...