mysqli

Errors on server! Need another set of eyes over simple php mysqli.

Hello, i have the following php code selecting user details from a mysql db $mysql = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database'); $stmt = $mysql->prepare('SELECT personalinfo.userid, personalinfo.firstname, personalinfo.lastname FROM personalinfo INNER JOIN applications O...

PHP warning help?

I keep getting the following error listed below and I was wondering how do I correct this error. Warning: mysqli_close() expects exactly 1 parameter, 0 given in Here is the code listed below. <?php require_once ('./mysqli_connect.php'); // Connect to the db. function make_list ($parent) { global $tasks; echo '<ol>'; foreach ($...

Are mysqli_multi_query php function connect 1 time to db or each query?

Hey Guys, Just wonder if the function mysqli_multi_query connect just 1 time to the database or each query? ...

MySQL connection in PHP

Hello everyone. MySQL connection in PHP can be established in two ways: $mysql = new mysqli('localhost', 'user_name', 'password', 'database_name'); or $link = mysqli_connect('localhost', 'user_name', 'password'); mysqli_set_charset($link, 'utf8'); mysqli_select_db($link, 'database_name'); Which one is better? ...

Can't Insert Data Into Tables Containing Auto Increment Primary Key Using PHP Prepared Statements

I know I have that my connection to the database works, and a test I did using no auto-increment id worked fine for me. The code below refuses to work and I can't find a a way around it. My table has 3 columns, ID (auto increment), name and value. What do I need to change in order to get this to work? Thanks in advance //create placeh...

Zend_DB - Use native MySQL adapter instead of MySQLi or PDO?

The server I'm porting to doesn't have PDO nor Mysqli extensions enabled ( though it is running PHP5 ). I don't see any MySql.php class in Zend/Db/Adapter - is there some convention to using native MySQL? Or some sort of workaround? Perhaps using an older version of Zend? And I don't have access to modify the php.ini. ...

Mysqli Prepared Statement Problem in bindParam()

Hi guys. Just as usual i was looking around best practices with PHP, and prepared statements seems the kind of stuff i should now how do with my eyes closed. So i started playing around with some examples i've found. I've got this error when running the script: Fatal error: Call to a member function bindParam() on a non-object in...

Retrieving Multiple Result sets with stored procedure in php/mysqli

I have a stored procedure that has multiple result sets. How do I advance to the 2nd result set in mysqli to get those results? Let's say it's a stored proc like: create procedure multiples( param1 INT, param2 INT ) BEGIN SELECT * FROM table1 WHERE id = param1; SELECT * FROM table2 WHERE id = param2; END $$ The PHP is something li...

Insert record failing! php mysqli

Hello, i have a mysql database... CREATE TABLE `applications` ( `id` int(11) NOT NULL auto_increment, `jobref` int(11) NOT NULL, `userid` int(11) NOT NULL, `q1` text NOT NULL, `q2` text NOT NULL, `q3` text NOT NULL, `sub_q1` text, `sub_q2` text, `sub_q3` text, `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TI...

PHP mysqli_fetch_field data type

Hi folks, I need some help tracking down a bit of nitty gritty information on the information in the fetch_field method of a mysqli result object. Specifically the type property - from the documentation it would seem that this field returns an integer... Great! I just can't seem to find a table that will let me translate the number t...

Getting list of items in mysqli query

Hello, I currently have a list of things to update in the given mysqli query: $insert = mysqli_query($db,"UPDATE `tbl_perms` SET `1` ='" . mysqli_real_escape_string($db,$_POST['permsA_1']) . "', `2` ='" . mysqli_real_escape_string($db,$_POST['permsA_2']) . "', `3` ='" . mysqli_real_escape_string($db,$_POST['permsA_3']) . "', ...

only list jobs if current time > expiry time (php mysqli)

hello :) I am trying to list out all records from a database that have not expired. i have a jobs listing site being developed, i have code to grab all the 'active' job details from the database and list out. $mysql = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database'); $stmtJ ...

PHP - Get a single result using mysqli

I have descided to change from mysql to mysqli part way through a project - and run into this hicup. What is the best way to achieve this: //check if username is taken $result = mysql_result(mysql_query("SELECT COUNT(*) FROM user WHERE username='".$username."'")); I can not find an exact version of mysql_result I have tried this: $re...

Returning specific rows using prepared statements

I have a problem where my prepared statement appears to only be returning the number of rows returned rather than the value of the row. Below is my code. I did try google for this but it doesn't tell me anything! If someone could tell me what I am doing wrong and how to fix it I would be very appreciative. Thanks $query2 = 'SELECT * FRO...

Problems with my prepared statement update

$query = "UPDATE kids_entry SET entries=? WHERE parentsemail=?"; $stmt1 = mysqli_prepare($connection, $query); mysqli_stmt_bind_param($stmt1, 'is',$entries,$parentsemail); mysqli_execute($stmt1); if(mysqli_stmt_affected_rows($stmt1) != 1) die("issueasdass"); mysqli_stmt_close($stmt1); The above code does work for me on another page b...

Mysqli query with a SET variable statment (ie multiple queries)

I want to set a variable to use in a mysqli query. This doesn't quite work. Prior to mysqli I used to set query calls. I played around with db->multi_query($sql) with no luck. Anyone out there have an idea how to make this work including a set statement? $sql = 'SET @rownum := 0;'; $sql .= 'SELECT @rownum :=@rownum + 1 AS Rank, User...

Using MDB2 and MySQLi together (Good or bad?)

I want to use the PEAR Mail_queue package which requires the PEAR MDB2 package for database abstraction. I currently use MySQLi for all my database queries and dont really desire using MDB2. Would it be bad practice to use both MDB2 and MySQLi in my PHP applications at the same time? Can anyone give me a good reason to use MDB2 over ...

PHP: Injection protection using prepared statements

Hi, I am familiar with using PHP to perform mySQL queries. However, I have been using reg exps as protection against injection attacks. After reading several questions/answers here on SO, I've decided to opt for prepared statements instead. There's two options available (let me know if there are more): mysqli prepared statements PDO ...

MySQLi - Server returned unknown type 246

Hi there, I've been working on a content managed site that's been working fine on localhost. I've just uploaded the files to my mediatemple server.. and am seeing some pretty interesting results: Warning: mysqli_stmt::bind_result() [mysqli-stmt.bind-result]: Server returned unknown type 246. Probably your client library is incompatible...

Mysql change number in column

Here is an easy question for someone. When using mysql, how do you increase or decrease the number in a particular cell by a specified amount with a single query. For example i have a product table with 5 x product a. I sell 1 item and i want to update the field. I want to do it with one query, not get the number add to it and then updat...