Все вопросы: [mysqli]

127 вопросов

похожие теги: mysqli-fetch-arraymysqli-multi-query
1
голосов
2ответов
594 просмотров

What's the most efficient driver to use with ADODB to access a MySQL5 Database?

I've been using ADODB for PHP on several projects for quite some time, and I like it for the ease of use and the efficiency. I've never been too curious about the way that lib accesses data because you know...it just worked :) But today I realized I'm still relying on the legacy MySQL4 ADODB dri...

0
голосов
3ответов
2230 просмотров

case insensitive search in php

I use a little search script in my site. After post the search form, i get this variable: $var = $_GET[$q] ; $trimmed = trim($var); Then i try to search in database: $query = "select * from test where acc like \"%$trimmed%\""; $numresults=mysql_query($query); $numrows=mysql_num_rows($num...

0
голосов
1ответов
597 просмотров

saving to mysql database using php and mysqli

i'm trying to save data to database and i get an error i never saw before i have a hunch it has something to do with the db collation but I'm not sure whats wrong, here is the query: $query1 = "INSERT INTO scape.url (url,normalizedurl,service,idinservice) VALUES (url, normalizedurl, 4, 45454)";...

4
голосов
4ответов
7234 просмотров

php mysqli WHERE IN (?,?,? ...)

According to http://us2.php.net/manual/en/mysqli-stmt.bind-param.php, the different types are: i corresponding variable has type integer d corresponding variable has type double s corresponding variable has type string b corresponding variable is a blob and will be sent in packets How...

2
голосов
2ответов
1624 просмотров

PHP OOP extending class can't access database connection

Perhaps you can help. I have a main class that creates a MySql connection. Then I extend this class. I wasn't able to access the connection unless I did a parent::__construct(); and recently while doing this I got an error message that I was out of connections. So how do program this so it does...

0
голосов
1ответов
289 просмотров

insert data to the database, and then get an autogenerated int key in return

Couldn't find a method like the int executeUpdate(String sql, int autoGeneratedKeys) in php. I want to insert data to the database, and then get an autogenerated int key in return (the ID). Thanks :) Oh, and PS: it has to be a method from the mysqli class =)

-1
голосов
1ответов
318 просмотров

Pear Log MDB2 message length and errors

I recently set up a SQL logging framework with PEAR, and everything was working fine. However, I thought that the default length of the message field (VARCHAR 200) was a little short, so I changed my database structure in phpmyadmin to increase this to 512. However, I quickly realized that th...

1
голосов
2ответов
1859 просмотров

SSL Connections with ADODB

I have a project we are about to wrap up, but just got a request from the DBA to make all our connections SSL. So I switched the driver to mysqli in the object that turns out ADODB instances, but I don't see any native method to create secure connections. To make things more difficult, there is...

4
голосов
3ответов
2995 просмотров

Mysqli parameter binding issue

I need an extra set of eyes on this one. Any help will be greatly appreciated. This is a very simple search query, but for whatever reason I cannot find the bug. Well, I know where the bug is. I just can't get past it. Anyway..... I am taking a search value from a POST variable, setting that var...

7
голосов
2ответов
66635 просмотров

get array of rows with mysqli result

I need to get all the rows from result object. I’m trying to build a new array that will hold all rows. Here is my code: $sql = new mysqli($config['host'],$config['user'],$config['pass'],$config['db_name']); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()...

2
голосов
3ответов
9590 просмотров

PHP MySQLi Multiple Inserts

I'm wondering if prepared statements work the same as a normal mysql_query with multiple VALUES. INSERT INTO table (a,b) VALUES ('a','b'), ('c','d'); VS $sql = $db->prepare('INSERT INTO table (a,b) VALUES (?, ?); If I use the prepared statement in a loop, is MySQL optimizing the insert i...

1
голосов
1ответов
482 просмотров

How to use store_result() to get the data?

I'm having trouble trying to use $stmt->store_result() after executing a prepared statement. The manual says "Transfers a result set from a prepared statement", but to where? I would ideally like to use it, all nice and buffered in memory, like $mysqli->query() returns. The PHP documentatio...

12
голосов
6ответов
16343 просмотров

PHP mysqli reconnect problem

I am having trouble using the mysqli class in PHP and I haven't been able to find the answer anywhere. In my script a class creates a mysqli connection that it uses throughout it's functions. Afterward, this script forks. The connection is used by the children as well, but I'm running into the p...

2
голосов
5ответов
11655 просмотров

PHP and "turning on" mysqli

I'm having trouble finding documentation about how exactly to go about "turning on" mysqli. I'm running OS X SL and, as I understand it, since php5 is installed, the mysqli extension should already be there as well. Is this as simple as adding a LoadModule line to php.ini? If I need to re-co...

6
голосов
4ответов
6677 просмотров

Get autoincrement id after an insert query performed with a prepared statement

If I execute an insert query with a stored procedure with php and the mysqli_* functions, is there a way to retrieve the value of an autoincrement id field? mysqli->insert_id does not seem to work.

5
голосов
1ответов
6445 просмотров

Get the Actual SQL of a Prepared Statement with mysqli?

Is there any way to get the actual SQL that is the result of preparing a statement when using the mysqli extension? My problem: I am using prepared statements. In all cases, they SHOULD update a record. I am not catching any errors. However, when I check for affected rows, there are none. ...

3
голосов
2ответов
3447 просмотров

pdo_mysql vs mysqli when using Zend_Db

If I am using Zend_Db classes to abstract my queries from the backend database, does it make a difference which mysql driver I use, pdo_mysql vs. mysqli? My understanding of pdo_mysql is it is also to provide abstraction, so I'm assuming that if I am using Zend_Db, then I would not be taking adva...

62
голосов
11ответов
150810 просмотров

How to change mysql to mysqli?

Based on this code below I use for regular mysql, how could I convert it to use mysqli? Is it as simple as changing mysql_query($sql); to mysqli_query($sql);? <?PHP //in my header file that is included on every page I have this $DB["dbName"] = "emails"; $DB["host"] = "localhost"; $DB["user"...

5
голосов
5ответов
4281 просмотров

How to make a proper mysqli extension class with prepared statements?

I have scoured the web for a good example but I can't find anything. I am trying to extend the mysqli class to make a helper class that will abstract away some of the complexities. One of the main things I want to accomplish is to make use of prepared statements. I don't really know where to ...

12
голосов
5ответов
11974 просмотров

Using wildcards in prepared statement - MySQLi

I'm trying to run the following query, and I'm having trouble with the wildcard. function getStudents() { global $db; $users = array(); $query = $db->prepare("SELECT id, adminRights FROM users WHERE classes LIKE ? && adminRights='student'"); $query-&...

3
голосов
2ответов
3220 просмотров

How can I get this mysqli database class working?

I'll cut right to the chase. All I can achieve at this point with this class is a database connection. I am unable to make a query. Can you show me exactly how to get this working and/or show me how to recode it in a better way. <?php class database{ public $dbHost = ''; public $dbUser = '';...

7
голосов
1ответов
6866 просмотров

prepared parameterized query with PDO

New to this new and secure way of handling SQL's in PHP and MySql driven web based application, to secure the code from SQL injections. I am planning to start using mysqli with PDO. Can anyone please outline how should i get started and proceed. Any reference to any article will also be helpful....

2
голосов
3ответов
1013 просмотров

OOP php5 structure

I have been trying to make OOP PHP5 code. But I think my attempts are clumsy. These are my questions: Is their a better, more leaner way to include database config information? Can I somehow get around having to declare $db = new Db() in every function I make? Should I use PEAR as database abst...

1
голосов
3ответов
437 просмотров

mysql_num_rows error

I have problem with mysql_num_rows() function. I've checked query (it has proper syntax and I'm getting the result in sql) and connection to database and everything seems to be able to work. // some code here, connecting to database and working query to db $query = "SELECT ff_client.email FROM f...

2
голосов
2ответов
2057 просмотров

Prepared Statements in a Database class

The Problem So I'm writing my web based application and it dawns on me "Durr, your stuff is wide open to SQL injection and whatnot! Rewrite db class!" I'm currently re-writing my $db class and I am having a significant amount of trouble understanding how I'm supposed to implement prepared state...

-3
голосов
1ответов
2294 просмотров

All-in-one PHP / MySQL registration/login form isn't working

I am making an all in one registration / login script, which will first display the registration form if $_POST is not set. If it is, but the required fields are not filled, it redirects to the page again, re-setting $_POST. If all the fields are filled in, then if the name of the submit button $...

-1
голосов
1ответов
824 просмотров

Bind Results from a Left Join using mysqli

I'm recently changing to mysqli and while performing an update on a script, i couldn't manage to use the same SELECT information as i did before. How can I bind_results from a Left Join between 3 tables? This is the script: SELECT actor.id, actor.name, actor.gender, thumbs.id, thumbs.fi...

0
голосов
2ответов
3315 просмотров

insert values from checkbox in table using php + mysqli

I have 3 tables (actors, categories, actor_cats) in my db. I'm using a form to insert new info in the database (mysql). Most of the information goes into the actors table. But in a label "categories", i have a checkbox input type, with 3 fields that i get from the categories table [action (id1)...

0
голосов
1ответов
1749 просмотров

Correct usage of MySQL LOAD_FILE()

I apologize if this is a dense question, but I'm having a bit of trouble using MYSQL LOAD_FILE() in conjunction with prepared statements in order to upload an image BLOB. As a result, I'm having to resort to using to separate queries, one to prepare a statement for details, and another, which do...

0
голосов
1ответов
286 просмотров

How can I alternate between mysqli_real_escape_string and \nl?

I've been doing some reading on mysqli_real_escape_string(), and, after getting my content properly escaped, I'm having some trouble getting to display properly when I pull it out again. Here's the code I have: function update_section_content() { $name = mysqli_real_escape_string($this->...