mysqli

mysql PDO how to bind LIKE

In this query select wrd from tablename WHERE wrd LIKE '$partial%' I'm trying to bind the variable '$partial%' with PDO. Not sure how this works with the % at the end. Would it be select wrd from tablename WHERE wrd LIKE ':partial%' where :partial is bound to $partial="somet" or would it be select wrd from tablename WHERE w...

Data truncation when retrieving data from MySQL database with prepared statements

I have a script that retrieves multiple products using prepared statements. Like putting loops into loops, I have prepared statements in prepared statements - so there is a prepared statement for retrieving all products, a prepared statement to retrieve all images for that product, a prepared statement to get all attributes for that prod...

Example of SELECT query with bind variables

I'm trying to bind input parameters into my SELECT query and then fetch the resulting rows, but MySQLi seems to be different to other APIs I'm used to and I'm getting lost in the PHP manual. Is the following approach correct? $sql = 'SELECT product_id, product_name, area_id FROM product WHERE product_id = ?'; $stmt = $myMySQLi-...

Invalid bind-variable name in Zend framework with Mysqli

Hi all, I was working on a application with Zend Framework and PDO_MYSQL Adapter. But my client server doesnt support PDO_MYSQL I changed the adapter to Mysqli and im getting Invalid bind-variable name error. How to resolve it thanks in advance. Regards Nizam ...

Someone please can see why the following prepared statment returns nothing?

$stmt = mysqli_prepare($link," SELECT * FROM ads INNER JOIN dept ON dept.id_dept = ads.in_dpt INNER JOIN members ON members.idMem = ads.from_Mem INNER JOIN sub_cat_ad ON id_sub_cat = ads.ads_in_Cat INNER JOIN cat_ad ON idCat_ad = sub_cat_ad.from_cat_ad WHERE ads_in_Cat = ? "); if(isset($_GET['fromSCat'...

Having a problem inserting into database

I have a stored procedure: CREATE PROCEDURE busi_reg (IN instruc VARCHAR(10), IN tble VARCHAR(20), IN busName VARCHAR(50), IN busCateg VARCHAR(100), IN busType VARCHAR(50), IN phne VARCHAR(20), IN addrs VARCHAR(200), IN cty VARCHAR(50), IN prvnce VARCHAR(50), IN pstCde VARCHAR(10), IN nm VARCHAR(20), ...

Does mysqli have support for ms sql?

Does mysqli have support for MS SQL? ...

mysqli bind_result/fetch problem

I am learning how to use prepared statements with php 5 mysqli objects and I am having trouble getting the basic result binding to work. I am following the example code from php.net but something isn't working, the bound results are always NULL. Here is what I have /* prepare statement */ if ($stmt = $DB->mysqli->prepare("SELECT `alias...

I have a problem with mysql and php

Hi I have a problem, this is my code: $db = new mysqli("localhost", "root", "", "blah"); $result1 = $db->query("select * from c_register where email = '$eml' and password = '$pass'"); if($result1->fetch_array()) { $auth->createSession(); $_SESSION['user'] = 'client'; promptUser("You have successfully...

Mysqli connection trying with different users

I'm trying to create a PHP class extending mysqli that is capable of connecting with another user if the connection fails. It is probably easier to explain with code: public function __construct() { $users = new ArrayObject(self::$user); $passwords = new ArrayObject(self::$pass); $itUser = $users->getIterator(); $itPass ...

Getting the record ID just added with mysql prepared statements

I'm inserting a record using PDO and saving the result in $result which I use as a boolean $result = $addRecord->execute(); if ($result){ //add successful } else { //add unsuccessful } I'd like to also get the record id just added. In the table, each record has an auto_incremented field called id. I tried doing this $new_id =...

Syntax for "RETURNING" clause in Mysql PDO

I'm trying to add a record, and at the same time return the id of that record added. I read it's possible to do it with a RETURNING clause. $stmt->prepare("INSERT INTO tablename (field1, field2) VALUES (:value1, :value2) RETURNING id"); but the insertion fails when I add RETUR...

I having a problem with the mysqli free() member function

Hi I have code where I connected to the database like so: $db = new mysqli("localhost", "user", "pass", "company"); Now when I query the database like so: //query calls to a stored procedure 'user_info' $result = $db->query("CALL user_info('$instruc', 'c_register', '$eml', '$pass', '')"); if($result->fetch_array()) { //use the ...

Mysqli results memory usage

Why is the memory consumption in this query continuing to rise as the internal pointer progresses through loop? How to make this more efficient and lean? $link = mysqli_connect(...); $result = mysqli_query($link,$query); // 403,268 rows in result set while ($row = mysqli_fetch_row($result)) { // print time, (get memory usage), -- ...

ADOdb Lite versus MySqli

Hello, I am working an a project to build an arcade site with PHP. I am considering using ADOdb Lite or MySqli. Which one is better for performance, speed and security? Thanks, ...

output all data from db to a php page

Hi, I'm a real beginner with PHP & mysql. Just for studying and for a simple example at school I would like to work this simple query and possibly output all the rows (or maybe even one) to a very basic output on a php page: <?php $user= "root"; $host="localhost"; $password=""; $database = "PetCatalog"; $cxn = mysqli_connect($host,$user...

Android SQLite Problem: Program Crash When Try a Query!

Hi i have a problem programming with android SDK 1.6. I'm doing the same things of the "notepad exaple" but the programm crash when i try some query. If i try to do a query directly in to the DatabaseHelper create() metod it goes, but out of this function it doesn't. Do you have any idea? this is the source: public class DbAdapter { p...

MySQLi Prepared Statement Query Issue

I'm relatively new to MySQLi prepared statements, and running into an error. Take this code: $user = 'admin'; $pass = 'admin'; if ($stmt = $mysqli->query("SELECT * FROM members WHERE username='$user' AND password='$pass'")) { echo $stmt->num_rows; } This will display "1", as it should. This next piece of code though, returns "0"...

mysqli insert problem

Hello i have this error: Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of elements in type definition string doesn't match number of bind variables in E:\wamp\www\classes\UserLogin.php on line 31 and i dont know what it is :/ here is my code function createUser($username, $password) { $mysql = connect(); if($st...

mysqli insert into database

Hello all i have this script and i will not insert into the database and i get no errors :S, do you know what it is? function createUser($username, $password) { $mysql = connect(); if($stmt = $mysql->prepare('INSERT INTO users (username, password, alder, hood, fornavn, efternavn, city, ip, level, email) VALUES (?,?,?,?,?,?,?...