Search Results

Search found 316 results on 13 pages for 'mysqli'.

Page 1/13 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to completely disable Mysqli

    - by Boon
    It seems the new hacker tool refref has been launched, and apparently it abuses a bug in the mysqli extension. Now I do not use mysqli at all for my websites, so i thought the best way to fight off this refref tool was to completely disable mysqli. These are the settings i have set in my php.ini. Is there a way I can disable mysqli completely with having to recompile PHP? ;extension=php_mysqli.dll [MySQLi] mysqli.max_persistent = -1 ;mysqli.allow_local_infile = On mysqli.allow_persistent = On mysqli.max_links = -1 mysqli.cache_size = 2000 mysqli.default_port = 3306 mysqli.default_socket = mysqli.default_host = mysqli.default_user = mysqli.default_pw = mysqli.reconnect = Off

    Read the article

  • MySQLi PHP: Check if SQL INSERT query was fully successful using MySQLi

    - by Jonathan
    Hi, I have this big function that gets a lot of different data and insert it into multiple tables.. Not all the data is always available so not all the SQL INSERT queries are successful. I need to check which SQL INSERT query was fully successful and which wasn't to the do something with this data (like inserting into a log table or similar). Just to give you an example of how I think it can be done: $sql = 'INSERT INTO data_table (ID, column1, column2) VALUES(?, ?, ?)'; if ($stmt->prepare($sql)) { $stmt->bind_param('iss', $varID, $var1, $var2); if ($stmt->execute()) { $success == TRUE; //or something like that } } I'm not completely sure this is the best way and if its always really show if the data was inserted into the table... Any suggestions??

    Read the article

  • Mysqli query only works on localhost, not webserver

    - by whamo
    Hello. I have changed some of my old queries to the Mysqli framework to improve performance. Everything works fine on localhost but when i upload it to the webserver it outputs nothing. After connecting I check for errors and there are none. I also checked the php modules installed and mysqli is enabled. I am certain that it creates a connection to the database as no errors are displayed. (when i changed the database name string it gave the error) There is no output from the query on the webserver, which looks like this: $mysqli = new mysqli("server", "user", "password"); if (mysqli_connect_errno()) { printf("Can't connect Errorcode: %s\n", mysqli_connect_error()); exit; } // Query used $query = "SELECT name FROM users WHERE id = ?"; if ($stmt = $mysqli->prepare("$query")) { // Specify parameters to replace '?' $stmt->bind_param("d", $id); $stmt->execute(); // bind variables to prepared statement $stmt->bind_result($_userName); while ($stmt->fetch()) { echo $_userName; } $stmt-close(); } } //close connection $mysqli-close(); As I said this code works perfectly on my localserver just not online. Checked the error logs and there is nothing so everything points to a good connection. All the tables exists as well etc. Anyone any ideas because this one has me stuck! Also, if i get this working, will all my other queries still work? Or will i need to make them use the mysqli framework as well? Thanks in advance.

    Read the article

  • PHP & MySQLi timeout

    - by Dt7
    Whenever I try to create a mysqli object, as in; $mysqli = new mysqli(host, user, pass, table); ...the page just loads for around a minute, then stops, showing all the content of the page up until that line. info() says that MySQLi (and MySQL if that matters) are enabled, and I can access the MySQL CLI. I'm also working on a local machine, not a remote server. I feel like I've missed something obvious. Can anyone shed some light on it? Edit: just for clarification, I am actually putting real values into the mysqli constructor :)

    Read the article

  • MySQLi Insert prepared statement via PHP

    - by Jimmy
    Howdie do, This is my first time dealing with MySQLi inserts. I had always used mysql and directly ran the queries. Apparently, not as secure as MySQLi. Anywho, I'm attempting to pass two variables into the database. For some reason my prepared statement keeps erroring out. I'm not sure if it's a syntax error, but the insert just won't work. I've updated the code to make the variables easier to read Also, the error is specifically, Error preparing statement. I've updated the code, but it's not a pHP error. It's a MySQL error as the script runs but fails at the execution of: if($stmt = $mysqli - prepare("INSERT INTO subnets (id, subnet, mask, sectionId, description, vrfId, masterSubnetId, allowRequests, vlanId, showName, permissions, pingSubnet, isFolder, editDate) VALUES ('', ?, ?, '1', '', '0', '0', '0', '0', '0', '{"3":"1","2":"2"}', '0', '0', 'NULL')")) { I'm going to enable MySQL error checking. I honestly didn't know about that. <?php error_reporting(E_ALL); function InsertIPs($decimnal,$cidr) { error_reporting(E_ALL); $mysqli = new mysqli("localhost","jeremysd_ips","","jeremysd_ips"); if(mysqli_connect_errno()) { echo "Connection Failed: " . mysqli_connect_errno(); exit(); } if($stmt = $mysqli -> prepare("INSERT INTO subnets (id, subnet, mask,sectionId,description,vrfld,masterSubnetId,allowRequests,vlanId,showName,permissions,pingSubnet,isFolder,editDate) VALUES ('',?,?,'1','','0','0','0','0','0', '{'3':'1','2':'2'}', '0', '0', NULL)")) { $stmt-> bind_param('ii',$decimnal,$cidr); if($stmt-> execute()) { echo "Row added successfully\n"; } else { $stmt->error; } $stmt -> close; } } else { echo 'Error preparing statement'; } $mysqli -> close(); } $SUBNETS = array ("2915483648 | 18"); foreach($SUBNETS as $Ip) { list($TempIP,$TempMask) = explode(' | ',$Ip); echo InsertIPs($Tempip,$Tempmask); } ?> This function isn't supposed to return anything. It's just supposed to perform the Insert. Any help would be GREATLY appreciated. I'm just not sure what I'm missing here

    Read the article

  • Extending MySQLi

    - by FRKT
    Hello, I've run into problems extending the MySQLi class. It won't let me add any properties. class MySQLii extends MySQLi { public $database; public function MySQLii($host, $username, $password, $database){ // Initialize MySQLi parent::MySQLi($host, $username, $password, $database); // Save database name $this->database = $database; } } $mysqlii = new MySQLii('localhost', 'root', 'password', 'database'); var_dump($mysqlii); object(MySQLii)#1 (17) { ["affected_rows"]= int(0) ["client_info"]= string(48) "mysqlnd 5.0.5-dev - 081106 - $Revision: 289630 $" ["client_version"]= int(50005) ["connect_errno"]= int(0) ["connect_error"]= NULL ["errno"]= int(0) ["error"]= string(0) "" ["field_count"]= int(0) ["host_info"]= string(42) "MySQL host info: Localhost via UNIX socket" ["info"]= NULL ["insert_id"]= int(0) ["server_info"]= string(6) "5.1.44" ["server_version"]= int(50144) ["sqlstate"]= string(5) "00000" ["protocol_version"]= int(10) ["thread_id"]= int(4019) ["warning_count"]= int(0) } Note the absence of the database property I added in the MySQLii constructor. Am I missing something?

    Read the article

  • MySQLi error handling

    - by Spoonface
    Is it possible to specify that MySQLi sends any errors and warnings to the PHP default 'error_log' directive? I can't seem to find any error options for the class specification, and I don't wish to handle errors manually like so: if ($result = $mysqli->query("...")) { } else handle $mysqli->error;

    Read the article

  • mysqli query not working when variable inserted

    - by Freelancer
    Hi Everyone, I need an extra pair of eyes! I have a super-simple query: $result = $mysqli->query("SELECT post_id FROM blog_posts WHERE post_uri = 'the-test-post' LIMIT 1"); $row = $result->fetch_array(); and this gives me the post_id. However, if I insert a variable for post_uri, the result is empty. Ways I tried of which none worked: $result = $mysqli->query("SELECT post_id FROM blog_posts WHERE post_uri = '".$post_uri."' LIMIT 1"); $result = $mysqli->query("SELECT post_id FROM blog_posts WHERE post_uri = ".$post_uri." LIMIT 1"); $result = $mysqli->query("SELECT post_id FROM blog_posts WHERE post_uri = $post_uri LIMIT 1"); I have similar query on another page working just right, so that confuses me even more. Help appreciated.

    Read the article

  • PHP MYSQLI query error?

    - by Chris Leah
    Hey This is my login script, using PHP5 and MYSQLi, I just had help spotting errors in my query, but still it will not let me login, even though the username and password are correct and in the database, it just keeps returning the error: your username and password do not match any in our db. But I know they do lol...could any body spot the problem? //Check if the form has been submitted if (isset($_POST['login'])) { //Check if username and password are empty if ($_POST['username']!='' && $_POST['password']!='') { //Create query to check username and password to database $validate_user = $mysqli->query('SELECT id, username, password, active FROM users WHERE = username = "'.$mysqli->real_escape_string($_POST['username']).'" AND password = "'.$mysqli->real_escape_string(md5($_POST['password'])).'"'); //We check if the query returns true if ($validate_user->num_rows == 1) { $row = $validate_user->fetch_assoc(); //Check if the user has activated there account if ($row['activated'] == 1) { $_SESSION['id'] = $row['id']; $_SESSION['logged_in'] = true; Header('Location: ../main/index.php'); } //Show this error if activation returns as 0 else { $error = '<p class="error">Please activate your account.</p>'; } } //Show this error if the details matched any in the db else { $error = '<p class="error">Your username and password are not in our database!</p>'; } } //Show this error if the username and password field have not been entered else { $error = '<p class="error">Please enter your username and password.</p>'; } }

    Read the article

  • Quick MySQLi security question

    - by Benjamin Falk
    I have a quick MySQLi security related question... For example, take a look at this code (gets in put from the user, checks it against the database to see if the username/password combination exist): $input['user'] = htmlentities($_POST['username'], ENT_QUOTES); $input['pass'] = htmlentities($_POST['password'], ENT_QUOTES); // query db if ($stmt = $mysqli->prepare("SELECT * FROM members WHERE username=? AND password = ?")) { $stmt->bind_param("ss", $input['user'], md5($input['pass'] . $config['salt'])); $stmt->execute(); $stmt->store_result(); // check if there is a match in the database for the user/password combination if ($stmt->num_rows > 0) {} } In this case, I am using htmlentities() on the form data, and using a MySQLi prepared statement. Do I still need to be using mysql_real_escape_string()?

    Read the article

  • MySQLi Prepared Statement Query Issue

    - by Benjamin Flak
    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": $user = 'admin'; $pass = 'admin'; if ($stmt = $mysqli->prepare("SELECT * FROM members WHERE username=? AND password=?")) { $stmt->bind_param("ss", $user, $pass); $stmt->execute(); echo $stmt->num_rows; } Any ideas why?

    Read the article

  • Problems using MySQL instead of MySQLi

    - by vaibhav
    I have a blog, which is on Drupal v6.14. Recently I changed my web hosting provider. My new hosting provider does'nt support MySQLi. So I have to use MySQL instead of MySQLi. All things worked fine for some days. But on a very fine morning, I found my blog is down and the error message was Mysql: Too Many Connections to the server. And this problem occurs several times a day now. I contacted my web hosting provider, they said, its a problem in your database. I don't trust this. My blog was working fine at old web server. Can it be a problem because of I moved to MySQL from MYSQLi.

    Read the article

  • Confusion using MYSQLI

    - by user1020069
    I just started using mysqli API for PHP. Apparently, every time an object of the class MYSQLI is instantiated, it can setup a connection to the database as it connects to the server unlike mysql_connect, which connects to the server first and then you are required to specify the database to query. Now this is a good problem if the db exists, in my case, the db does not exist on the first ever connection to the server/execution of the problem, hence I must connect without specifying the database, which is fine, since the msyqli constructor does not make this database mandatory. My challenge is essentially, how do I check if the database exists before attempting the first connection. The only way to really do this would be to establish a conection to the server and then use the result of the following query to gauge if the database exists: SELECT COUNT(*) AS `exists` FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMATA.SCHEMA_NAME="dbname" ; If this returns true, then the database exists, but now the challenge is how do I get the mysqli object to query this database rather than having to prefix the name of the database in the query. Thanks much

    Read the article

  • PHP mysqli wrapper: passing by reference with __call() and call_user_func_array()

    - by Dave
    Hi everyone. I'm a long running fan of stackoverflow, first time poster. I'd love to see if someone can help me with this. Let me dig in with a little code, then I'll explain my problem. I have the following wrapper classes: class mysqli_wrapper { private static $mysqli_obj; function __construct() // Recycles the mysqli object { if (!isset(self::$mysqli_obj)) { self::$mysqli_obj = new mysqli(MYSQL_SERVER, MYSQL_USER, MYSQL_PASS, MYSQL_DBNAME); } } function __call($method, $args) { return call_user_func_array(array(self::$mysqli_obj, $method), $args); } function __get($para) { return self::$mysqli_obj->$para; } function prepare($query) // Overloaded, returns statement wrapper { return new mysqli_stmt_wrapper(self::$mysqli_obj, $query); } } class mysqli_stmt_wrapper { private $stmt_obj; function __construct($link, $query) { $this->stmt_obj = mysqli_prepare($link, $query); } function __call($method, $args) { return call_user_func_array(array($this->stmt_obj, $method), $args); } function __get($para) { return $this->stmt_obj->$para; } // Other methods will be added here } My problem is that when I call bind_result() on the mysqli_stmt_wrapper class, my variables don't seem to be passed by reference and nothing gets returned. To illustrate, if I run this section of code, I only get NULL's: $mysqli = new mysqli_wrapper; $stmt = $mysqli->prepare("SELECT cfg_key, cfg_value FROM config"); $stmt->execute(); $stmt->bind_result($cfg_key, $cfg_value); while ($stmt->fetch()) { var_dump($cfg_key); var_dump($cfg_value); } $stmt->close(); I also get a nice error from PHP which tells me: PHP Warning: Parameter 1 to mysqli_stmt::bind_result() expected to be a reference, value given in test.php on line 48 I've tried to overload the bind_param() function, but I can't figure out how to get a variable number of arguments by reference. func_get_args() doesn't seem to be able to help either. If I pass the variables by reference as in $stmt->bind_result(&$cfg_key, &$cfg_value) it should work, but this is deprecated behaviour and throws more errors. Does anyone have some ideas around this? Thanks so much for your time.

    Read the article

  • How can I specify that Doctrine must use a mysqli-connection

    - by murze
    Hi, while executing a long script that uses Doctrine to access the db, I get an error 2006 server has gone away. I've already solved this problem on a website that doens't use Doctrine. The solution there was to use mysqli instead of the normal mysql driver. How can i tell Doctrine to use a mysqli-driver in order to avoid 2006-errors? Thanks!

    Read the article

  • mysqli query for no results do something else do something else

    - by Yousef Altaf
    I'm running a mysqli query. this is my code <?php $SM_pro_info="SELECT * FROM special_marketing_ads ORDER BY id desc LIMIT 4"; $QSM_pro_info = $db->query($SM_pro_info)or die($db->error); if($QSM_pro_info->num_rows ==1){ while($SM_pro=$QSM_pro_info->fetch_object()){ ?> <table width="208" border="0"> <tr> <td width="129" height="35" align="right"><span style="color:#361800; font-size:14px; font-weight:bold;"><?php echo $SM_pro->pro_title; ?></span></td> <td width="69" rowspan="2" align="center"><a rel="lightbox" href="includes/Cpanel/projectImages//images.jpg" ><img src="<?php echo $SM_pro->image_1; ?>" alt="" width="60" height="60" border="0" /></a></td> </tr> <tr align="right"> <td><span style="color:#361800; font-size:14px; font-weight:bold;">?????</span> : <span style="color:#da6e19; font-size:15px; font-weight:bold;"><?php echo $SM_pro->pro_purpose; ?></span></td> </tr> </table> <?php } }else{ echo"Your Ads here"; } ?> now all I want to do is if there is any results comeing from mysqli echo it if there is no results it should echo an image which is add your ads here. the point is I have 4 Ads so if there is 1 Ads in mysqli row and the others is empty so I want it to echo this single Ads and the other 3 Ads should be this image add your Ads here. any Help on this please?

    Read the article

  • PHP MySQLi and MySQLi_STMT: Which insert_id to use?

    - by Carvell Fenton
    Hello all, Both the MySQLi and MySQLi_STMT classes have an $insert_id property. If I am connected to my database using a MySQLi object (say $db), and then I perform an INSERT with a MySQLi_STMT object (say $stmt), to get the id of the last INSERT, should I use: $last_id = $db->insert_id; or $last_id = $stmt->insert_id; Or would they be the same, in which case it doesn't matter? I thought this might be a quick answer for someone, and save me the time of writing the test code to check it. Thanks in advance as always.

    Read the article

  • Mysqli connection trying with different users

    - by gerardo
    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 = $passwords->getIterator(); parent::__construct(self::$host, $itUser->current(), $itPass->current(), self::$prefix.self::$db); while($this->connect_errno && $itUser->valid()){ $itUser->next(); $itPass->next(); $this->change_user($itUser->current(), $itPass->current(), self::$prefix.self::$db); } if($this->connect_errno) throw new Exception("Error", $this->connect_errno); } $user and $pass are static variables containing arrays of users and passwords. If the first user fails to connect, I try with the next one. The problem here is with $this->connect_errno. It says it cannot find Mysqli. Is there any solution to this or should I create a Factory class?

    Read the article

  • fetch_all or fetch_assoc MySQLi statement

    - by all-R
    Hi, is it possible to use the fetch_all(), fetch_assoc() etc. from the the MySQLi_Result class with a prepared statement from the MySQLi_STMT class? I've done it using the query() method in the Mysqli class (and by escaping trough mysqli_real_escape_string()), but not using statements with binding parameters. I'm considering using PDO thanks!

    Read the article

  • MySQLi -- OO or Procedural?

    - by Kerry
    I know OO is the "way to go" but I'm thinking procedural might be easier to use in the wrapper I'm making. Any difference in performance between MySQLi Object Oriented vs Procedural?

    Read the article

  • ADOdb Lite versus MySqli

    - by Sofyan
    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,

    Read the article

  • SQL Injection When Using MySQLi Prepared Statements

    - by Sev
    If all that is used to do any and all database queries is MySQLi prepared statements with bound parameters in a web-app, is sql injection still possible? Notes I know that there are other forms of attack other than sql-injection, but my question is specific to sql-injection attacks on that particular web application only.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >