mysqli

Call to a member function prepare() on a non-object error.

This is the code I'm using to pass the database handle to my class: $db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); if ($db->connect_error) die('MySQL connection error (' . $db->connect_errno . ') ' . $db->connect_error); $linkgen = new Linkgen($db); echo $linkgen->getLinksLeft(); And this is the code in the Linkgen class: ...

PHP to MySQL SSL Connections

I have successfully setup an SSL enabled install of MySQL on one server on one network and can connect to it using SSL with the Linux command line mysql client on a different server on a different network, however every time I try to connect (using PHP 5.3.3) I keep getting: Warning: mysqli_real_connect(): (HY000/2026): SSL connection ...

Testing php / mysqli connection

I am looking for a way to test just the connection portion of a php / mysqli connection. I am migrating from a LAMP server build on Vista to the same on Ubuntu and am having fits getting mysqli to work. I know that all of the proper modules are installed, and PhpMyAdmin works flawlessly. I have migrated a site over and none of the mys...

php5.3 - mysqli_stmt:bind_params with call_user_func_array problem

I have the following line of code which worked in PHP 5.1, but isn't working in PHP 5.3. $input = array('ss','john','programmer'); call_user_func_array(array($mysqli_stmt, 'bind_param'), $input); In PHP 5.3, I get the following warning message: Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given ...

A prepared statement, `WHERE .. IN(..)` query and sorting — with MySQL

Imagine we have a query: SELECT * FROM somewhere WHERE `id` IN(1,5,18,25) ORDER BY `name`; and an array of IDs to fetch: $ids = array(1,5,18,25) With prepared statements it's adviced to prepare one statement and call it multiple times: $stmt = $mysqli->prepare('SELECT * FROM somewhere WHERE `id`=?;'); foreach ($ids as $id){ $stm...

mysqli superglobal connection object, more than one connection at time

Hi! I've been using this solution to get a superglobal mysqli connection: class blst_db { private static $mysqli; private function __construct(){} //no instantiation static function cxn() { if( !self::$mysqli ) { self::$mysqli = new mysqli(...); } return self::$mysqli; } //use blst_db::cxn()->prepare(.....

return output with php oop mysqli

Hello all i try to select stuff from the database and when i will return it so i can echo stuff out like $instance->titel $instance->content and like that, hope you understand, now i only got the id "1" echo out. here is my code <?php /** * Simon testClass */ class testClass { public $mysqli; public function __construct(...

mysqli prepare statements

Hi, I have just started to learn prepared statements and sqli to make the signup process on my website more secure and safe. Below is just the basic code I have written to get it working, it is sent from a html form, which calls a jquery function to validate the signup form and then issuse a result "Success" or "Fail". <?php session_s...

Which PHP extension should I use for my DB wrapper

Hi there! I'm building a database wrapper for my own use and I can't decide which PHP extension I should use, PDO or MySQLi. I'm only planning to use MySQL so I don't care about the support for other adapters with PDO. I've read a lot that PDO is becoming a 'standard' with PHP and perhaps I should use that? Then I think it's 'too much'...

why mysqli one pulling one row with foreach loop in php ?

Hi friends why mysqli one pulling one row with foreach loop in php ? Shouldn't it fetch arrays of all rows ? $link = new mysqli(DB_SERVER, DB_USER,DB_PASSWORD,DB_NAME) or die('error connecting'); $mob = query("SELECT mobile FROM members_db"); foreach ($mob as $numbers){ $mob_numbers = $numbers['mobile']; print_r($m...

PHP: Would prepared statements completely secure my website from MySQL injection?

I'm using prepared statements and MySQLi with my queries to protect against injection attacks. Would prepared statements remove the need for mysql_real_escape_string entirely? Is there anything else I should consider when securing my site? ...

Can I bind multiple values as a single parameter using MYSQLI and PHP?

Imagine I have the following SQL query: SELECT id,name FROM user WHERE id IN ('id1','id2','id3') Now imagine I need the array of ids to be supplied by PHP. So I have something like this: $idList = array('id1','id2','id3'); $query = "SELECT id,name FROM user WHERE id IN (?)"; $stmt = $db->prepare($query); $stmt->bind_param(/*Somethin...

Create mysql trigger via PHP?

I'm executing the following in PHP5.3: $sql = " CREATE TRIGGER `_photo_fulltext_insert` AFTER INSERT ON `photo` FOR EACH ROW INSERT INTO `_photo_fulltext` SELECT * FROM `photo` WHERE `id`=NEW.`id`; CREATE TRIGGER `_photo_fulltext_delete` AFTER DELETE ON `photo` FOR EACH ROW DELETE FROM `_photo_fulltext` WHERE `id`=OLD.`id`; DELIMITER |...

i have problem in mysql

Error Code: 1109 Unknown table 'chaindb.credit_trans' in field list i have error-code 1109 in call procedure in mysql help me,please ...

Commands out of sync when using mysqli and prepared statements

Hello, I am trying to do some calls, but the 2nd query fails with command 'Commands out of sync; you can't run this command now' error. The code looks like this: $sql="call listReport();"; $results = mysqli_query($link,$sql); $arr=array(); while($row=mysqli_fetch_array($results)) { array_push($arr,$row); } mysqli_free_result($res...

send email to multiple receptor php - mysqli

I'd like to know how to send mails to users who is already stored in my database so I want to select all from my database table and send them a mail and also is I want to send to the selected emails only how that can be done This is the relevant code of the admin interface: <?php $get_U_data = " select * from maling_list "; ...

MySQL ND SSL in PHP5.3.3

According to http://www.php.net/manual/en/mysqlnd.overview.php MySQLND now supports SSL Does anyone know of any examples of setup of an SSL connection with MySQLND? Is the assumption that you just use the existing mysqli route but under the hood it's using MySQLND? ...

PHP MySQL Query doesn't work, but works from terminal

Here's my code: $gid = (int) stripslashes($_POST['id']); echo $gid; $db = dbConnect(); $test = $db->query('update games set played = played + 1 where id = "$gid"'); echo $db->error; echo $db->errno; die(); } It works fine from the terminal, and it correctly prints out $gid, and no errors are returned. Am I missing something really obvi...

results return incorrectly from PHP class query when processed by another function

The following works: $user_list = new user_list(); $all_users_list = $user_list->getAllUsers(); The following doesn't work and I'm unsure as to why it doesn't: $user_list = new user_list(); The above returns: Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, object given on line 59 Classes for reference: c...

mysqli,php store procedure call

mysqli_query($link, "CALL my_first__status_call('Other',@out_value);SELECT @out_value"); This is my first sp program , my above SP throwing Error on execution , How to call the sp in mysqli php am getting the below error Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in ...