Search Results

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

Page 8/13 | < Previous Page | 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • PHP & MySQL form question.

    - by peakUC
    How do I allow all users to have there username field empty without having them to enter a username when they submit the form using PHP and MySQL? Here is part my PHP and MySQL code. $username = mysqli_real_escape_string($mysqli, $purifier->purify(htmlentities(strip_tags($_POST['username'])))); if(isset($_POST['username'])) { // Make sure the username address is available: $u = "SELECT * FROM users WHERE username = '$username' AND user_id <> '$user_id'"; $r = mysqli_query ($mysqli, $u) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($mysqli)); if (mysqli_num_rows($r) == TRUE) { // Unavailable. echo '<p class="error">Your username is unavailable!</p>'; $username = NULL; } else if(mysqli_num_rows($r) == 0) { // Available. $username = mysqli_real_escape_string($mysqli, $purifier->purify(htmlentities(strip_tags($_POST['username'])))); } }

    Read the article

  • PHP | SQL syntax error when inserting array

    - by Philip
    Hi guys, I am having some trouble inserting an array into the sql database. my error is as follows: Unable to add : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '06:45:23,i want to leave a comment)' at line 1 My query var_dump is: string(136) "INSERT INTO news_comments (news_id,comment_by,comment_date,comment) VALUES (17263,Philip,2010-05-11 06:45:23,i want to leave a comment)" My question is how can i add an empty value to id as it is the primary key and not news_id my insert function looks like this: function insertQuery($tbl, &$data) { global $mysqli; $_SESSION['errors'] = array(); require_once '../config/mysqli.php'; $query = "INSERT INTO $tbl (".implode(',',array_keys($data)).") VALUES (".implode(',',array_values($data)).")"; var_dump($query); if($result = mysqli_query($mysqli, $query)) { //$id = mysqli_insert_id($mysqli); print 'Very well done sir!'; } else { array_push($_SESSION['errors'], 'Unable to add : ' . mysqli_error($mysqli)); } } Note: arrays are not my strong point so i may be using them in-correctly!

    Read the article

  • mysql php problem: no error message despite error_reporting(E_ALL) line

    - by herrturtur
    index.php <html> <head> <title>Josh's Online Playground</title> </head> <body> <form method="POST" action="action.php"> <table> <tr> <td>"data for stuff"</td> <td><input type="text" ?></td> </tr> <tr> <td><input type="submit"></td> </tr> </table> </form> </body> </html> action.php <?php error_reporting(E_ALL); ini_sit("display_errors", 1); $mysqli = new mysqli('localhost', 'root', 'password', 'website'); $result = $mysqli->query("insert into stuff (data) values (' .$_POST['data'] ."'); echo $mysqli->error(); if($result = $mysqli->query("select data from stuff")){ echo 'There are '.$result->num_rows.' results.'; } while ($row = $result->fetch_object()){ echo 'stuff' . $row->data; } ?> Despite the first two lines in action.php, I get no error or warning messages. Instead I get a blank page after clicking the submit button. Do I have to do something differently to insert data?

    Read the article

  • PHP and MySQL - correct way to use mysqli_real_escape_string

    - by TaG
    I was wondering if the code below is the correct way to use mysqli_real_escape_string() when storing users data in a database. Here is the PHP & MySQL code. if (mysqli_num_rows($dbc) == 0) { $mysqli = mysqli_connect("localhost", "root", "", "sitename"); $dbc = mysqli_query($mysqli,"INSERT INTO info (user_id, url) VALUES ('$user_id', 'mysqli_real_escape_string($url)')"); } if ($dbc == TRUE) { $dbc = mysqli_query($mysqli,"UPDATE info SET url = 'mysqli_real_escape_string($url)' WHERE user_id = '$user_id'");

    Read the article

  • PHP & MySQL - Array to string conversion error problem.

    - by comma
    I keep getting an the following error of Array to string conversion error on this line listed below. How can I fix this problem? $skill = explode('', $_POST['skill']); Here is the PHP & MySQL code. $skill = explode('', $_POST['skill']); $experience = explode('', $_POST['experience']); $years = explode('', $_POST['years']); for ($s = 0; $s < count($skill); $s++){ for ($x = 0; $x < count($experience); $x++){ for ($g = 0; $g < count($years); $g++){ if (mysqli_num_rows($dbc) == 0) { $mysqli = mysqli_connect("localhost", "root", "", "sitename"); $dbc = mysqli_query($mysqli,"INSERT INTO learned_skills (user_id, skill, experience, years, date_created) VALUES ('" . $user_id . "', '" . $skill[$s] . "', '" . $experience[$x] . "', '" . $years[$g] . "', NOW())"); } if ($dbc == TRUE) { $dbc = mysqli_query($mysqli,"UPDATE learned_skills SET skill = '$skill', experience = '$experience', years = '$years', date_created = NOW() WHERE user_id = '$user_id'"); echo '<p class="changes-saved">Your changes have been saved!</p>'; } if (!$dbc) { print mysqli_error($mysqli); return; } } } }

    Read the article

  • PHP & MySQL Image deletion problem?

    - by IMAGE
    I have this script that deletes a users avatar image that is stored in a folder name thumbs and another named images and the image name is stored in a mysql database. But for some reason the script deletes all the users info for example if the users id is 3 all of the users info like first name last name age and so are deleted as well, basically everything is deleted including the user how do I fix this so only the images and image name is deleted? Here is the code. $user_id = '3'; if (isset($_POST['delete_image'])) { $a = "SELECT * FROM users WHERE avatar = '". $avatar ."' AND user_id = '". $user_id ."'"; $r = mysqli_query ($mysqli, $a) or trigger_error("Query: $a\n<br />MySQL Error: " . mysqli_error($mysqli)); if ($r == TRUE) { unlink("../members/" . $user_id . "/images/" . $avatar); unlink("../members/" . $user_id . "/images/thumbs/" . $avatar); $a = "DELETE FROM users WHERE avatar = '". $avatar ."' AND user_id = '". $user_id ."'"; $r = mysqli_query ($mysqli, $a) or trigger_error("Query: $a\n<br />MySQL Error: " . mysqli_error($mysqli)); } }

    Read the article

  • How To Correctly Specify A Default Value For A String Field In A PHP/MySQL Prepared Statement

    - by Joshua
    I'm trying to debug some auto-generated code, but I am a mySQL noob. Everything goes fine ultil the "prepare" line below, and then for some reason $mysqli_stmt is false, yielding the stated error. Could it have something to do with the SQL_MODE = 'ANSI'? The failure seems to have something to do with the string 'xxx' below, but it still happens no matter what I change it to. This value is meant to be a default value for the TickerDigest field, but strangely if I change 'xxx' to 'c_u_TickerDigest', then it suddenly works, but the TickerDigest field is inserted as 'null' when I look in the database. $mysqli = mysqli_init(); $mysqli->options(MYSQLI_INIT_COMMAND, "SET SQL_MODE = 'ANSI'"); $mysqli->real_connect(SR_Host,SR_Username,SR_Password,SR_Database) or die('Unable to connect to Database'); $sql_stmt = 'INSERT INTO "t_sr_u_Product"("c_u_Name", "c_u_Code", "c_u_TickerDigest") VALUES (?, ?, "xxx")'; $mysqli_stmt = $mysqli->prepare($sql_stmt); Fatal error: Uncaught exception 'Exception' with message 'INSERT INTO "t_sr_u_Product"("c_u_Name", "c_u_Code", "c_u_TickerDigest") VALUES (?, ?, "xxx"): prepare statement failed: Unknown column 'xxx' in 'field list'' in P:\StarRise\SandBox\GateKeeper\Rise\srIProduct.php on line 18 I'm hopeful what's going wrong is fairly simple, since I'm almost completely ignorant about SQL.

    Read the article

  • Recompile PHP5.3 with mysqlnd on Debian Squeeze?

    - by TheRebel
    My current PHP5.3 installation was compiled with libmysql by default. To run certain mysqli functions, I need the mysqlnd library, but I can't seem to find a step by step guide giving proper description how to recompile PHP 5.3 on Debian 6 with custom settings. All I found was the configuration parameter on the PHP.net manual (http://php.net/manual/en/mysqlinfo.library.choosing.php) saying that this is a compile time decision: $ ./configure --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysql=mysqlnd Any ideas how to do it? Thanks!

    Read the article

  • PHP & MySQL username submit problem

    - by peakUC
    I want to allow users to either have there username field empty at any time but I get the username error message Your username is unavailable! how can I correct this problem? Here is the PHP code. if(isset($_POST['username'])) { $u = "SELECT * FROM users WHERE username = '$username' AND user_id <> '$user_id'"; $r = mysqli_query ($mysqli, $u) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($mysqli)); if (mysqli_num_rows($r) == TRUE) { // Unavailable. echo '<p class="error">Your username is unavailable!</p>'; $username = NULL; } else if(mysqli_num_rows($r) == 0) { // Available. $username = mysqli_real_escape_string($mysqli, $purifier->purify(htmlentities(strip_tags($_POST['username'])))); } }

    Read the article

  • PHP form validation question?

    - by GeNx
    Is it necessary to validate a name or street address? when I have it coded in the following format. And if so why? $address = mysqli_real_escape_string($mysqli, htmlentities($_POST['address'])); $name = mysqli_real_escape_string($mysqli, htmlentities($_POST['name']));

    Read the article

  • Random problem connecting to MySQL

    - by CharlesLeaf
    Environment: RHEL 5 servers, MySQL 5.1.43, PHP 5.1.6 (using MySQLi). Currently only available within our internal VPN network. Servers ServerA: Webserver ServerB/C/D: Database server (1 master 2 slaves) The error (on ServerA) [Tue May 25 11:12:17 2010] [error] [client CLIENTIP] PHP Warning: mysqli::real_connect() [function.mysqli-real-connect]: (HY000/2003): Can't connect to MySQL server on 'ServerB' (4) in /home/**/Database.php on line 67, referer: [website] Problem description It appears that at completely random times, our website is unable to connect to one of the MySQL servers - usually the Master. Except for the forementioned error message, there is nothing to be found in any of the logs as far as I can see, and most of the times the connection is succesful and everything works as it should. It's just at completely random times, this error pops up. There's no firewall blocking any internal traffic, timeout value is 3 but it doesn't take 3 seconds before it fails to connect. With the default mysql client I can connect from ServerA to ServerB,C and D and haven't encountered a problem yet. Does anyone have a clue what I might be overlooking / could be the problem? Because I've run out of ideas myself.

    Read the article

  • Storing data in a MySQL database using MySQL & PHP

    - by comma
    I'm new to PHP and MySQL and I'm trying to store a users entered data from the following fields $skill, $experience, $years which a user can also add additional fields of $skill, $experience, $years if needed so in instead of 1 of each field there might be multiples of each field. I was wondering how can I store the fields in my MySQL database using PHP and MySQL? I have the following script but I know its wrong. can some one help me fix the script listed below? Here is the PHP and MySQL code. $skill = serialize($_POST['skill']); $experience = serialize($_POST['experience']); $years = serialize($_POST['years']); for (($s = 0; $s < count($skill); $s++) && ($x = 0; $x < count($experience); $x++) && ($g = 0; $g < count($years); $g++)){ $mysqli = mysqli_connect("localhost", "root", "", "sitename"); $query1 = "INSERT INTO learned_skills (skill, experience, years) VALUES ('" . $skill[$s] . "', '" . $experience[$x] . "', '" . $years[$g] . "')"; if (!mysqli_query($mysqli, $query1)) { print mysqli_error($mysqli); return; } } Here is my MySQL table. CREATE TABLE learned_skills ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, skill TEXT NOT NULL, experience TEXT NOT NULL, years INT NOT NULL, PRIMARY KEY (id) ); CREATE TABLE u_skills ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, skill_id INT UNSIGNED NOT NULL, users_id INT UNSIGNED NOT NULL, PRIMARY KEY (id) );

    Read the article

  • PHP & MySQL username validation and storage problem.

    - by php
    For some reason when a user enters a brand new username the error message <p>Username unavailable</p> is displayed and the name is not stored. I was wondering if some can help find the flaw in my code so I can fix this error? Thanks Here is the PHP code. if($_POST['username'] && trim($_POST['username'])!=='') { $u = "SELECT * FROM users WHERE username = '$username' AND user_id <> '$user_id'"; $r = mysqli_query ($mysqli, $u) or trigger_error("Query: $u\n<br />MySQL Error: " . mysqli_error($mysqli)); if (mysqli_num_rows($r) == TRUE) { echo '<p>Username unavailable</p>'; $_POST['username'] = NULL; } else if(isset($_POST['username']) && mysqli_num_rows($r) == 0 && strlen($_POST['username']) <= 255) { $username = mysqli_real_escape_string($mysqli, $_POST['username']); } else if($_POST['username'] && strlen($_POST['username']) >= 256) { echo '<p>Username can not exceed 255 characters</p>'; } }

    Read the article

  • how connect to local mysql server (LAN)

    - by clarkk
    I got two Debian 6 servers - one for web and one for the database.. How can I connect through the local area network? On both servers I have permanently changed the hostnames /etc/hostname /etc/hosts web => web-server db => db-server In the privileges in mysql I have set the root user to accept requests from web-server (instead of localhost) and from the web-server I connect to db-server in my.cnf I have escaped the following line: # bind-address = 127.0.0.1 error Warning: mysqli::mysqli(): (HY000/2005): Unknown MySQL server host 'db-server' (1)

    Read the article

  • mysql connect error issue

    - by Alex
    I've php page which update Mysql Db. I don't understand why my following php code is saying that "Could not update marker. No database selected". Strange!! can you please tell me why it's showing error message. Thanks. Php code: <?php // database settings $db_username = 'root'; $db_password = ''; $db_name = 'parkool'; $db_host = 'localhost'; //mysqli $mysqli = new mysqli($db_host, $db_username, $db_password, $db_name); if (mysqli_connect_errno()) { header('HTTP/1.1 500 Error: Could not connect to db!'); exit(); } ################ Save & delete markers ################# if($_POST) //run only if there's a post data { //make sure request is comming from Ajax $xhr = $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'; if (!$xhr){ header('HTTP/1.1 500 Error: Request must come from Ajax!'); exit(); } // get marker position and split it for database $mLatLang = explode(',',$_POST["latlang"]); $mLat = filter_var($mLatLang[0], FILTER_VALIDATE_FLOAT); $mLng = filter_var($mLatLang[1], FILTER_VALIDATE_FLOAT); $mName = filter_var($_POST["name"], FILTER_SANITIZE_STRING); $mAddress = filter_var($_POST["address"], FILTER_SANITIZE_STRING); $mId = filter_var($_POST["id"], FILTER_SANITIZE_STRING); /*$result = mysql_query("SELECT id FROM test.markers WHERE test.markers.lat=$mLat AND test.markers.lng=$mLng"); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; } $row = mysql_fetch_row($result); $id=$row[0];*/ //$output = '<h1 class="marker-heading">'.$mId.'</h1><p>'.$mAddress.'</p>'; //exit($output); //Update Marker if(isset($_POST["update"]) && $_POST["update"]==true) { $results = mysql_query("UPDATE parkings SET latitude = '$mLat', longitude = '$mLng' WHERE locId = '94' "); if (!$results) { //header('HTTP/1.1 500 Error: Could not Update Markers! $mId'); echo "coudld not update marker." . mysql_error(); exit(); } exit("Done!"); } $output = '<h1 class="marker-heading">'.$mName.'</h1><p>'.$mAddress.'</p>'; exit($output); } ############### Continue generating Map XML ################# //Create a new DOMDocument object $dom = new DOMDocument("1.0"); $node = $dom->createElement("markers"); //Create new element node $parnode = $dom->appendChild($node); //make the node show up // Select all the rows in the markers table $results = $mysqli->query("SELECT * FROM parkings WHERE 1"); if (!$results) { header('HTTP/1.1 500 Error: Could not get markers!'); exit(); } //set document header to text/xml header("Content-type: text/xml"); // Iterate through the rows, adding XML nodes for each while($obj = $results->fetch_object()) { $node = $dom->createElement("marker"); $newnode = $parnode->appendChild($node); $newnode->setAttribute("name",$obj->name); $newnode->setAttribute("locId",$obj->locId); $newnode->setAttribute("address", $obj->address); $newnode->setAttribute("latitude", $obj->latitude); $newnode->setAttribute("longitude", $obj->longitude); //$newnode->setAttribute("type", $obj->type); } echo $dom->saveXML();

    Read the article

  • PHP 5.3.8 startup warning

    - by David
    How do I solve my PHP startup warning: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions /no-debug-non-zts-20090626/imap.so' - /usr/lib/php/extensions/no-debug-non-zts-20090626 /imap.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions /no-debug-non-zts-20090626/mcrypt.so' - /usr/lib/php/extensions/no-debug-non-zts- 20090626/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions /no-debug-non-zts-20090626/memcache.so' - /usr/lib/php/extensions/no-debug-non-zts- 20090626/memcache.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions /no-debug-non-zts-20090626/mysql.so' - /usr/lib/php/extensions/no-debug-non-zts- 20090626/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib /php/extensions/no-debug-non-zts-20090626/mysqli.so' - /usr/lib/php/extensions /no-debug-non-zts-20090626/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions /no-debug-non-zts-20090626/pdo.so' - /usr/lib/php/extensions/no-debug-non-zts-20090626 /pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions /no-debug-non-zts-20090626/pdo_mysql.so' - /usr/lib/php/extensions/no-debug-non-zts- 20090626/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions /no-debug-non-zts-20090626/suhosin.so' - /usr/lib/php/extensions/no-debug-non-zts- 20090626/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0 I've many configuration files in my config folder, I don't know where they come from: PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/conf.d/gd.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/conf.d/gd.ini on line 2 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/conf.d/imap.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/conf.d/mcrypt.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/conf.d /memcache.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/conf.d /mysql.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/conf.d /mysqli.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/conf.d/pdo.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/conf.d /pdo_mysql.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/conf.d/xcache.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/conf.d/xcache.ini on line 9 in Unknown on line 0 Because of the warning I think I don't need them?

    Read the article

  • How can arguments to variadic functions be passed by reference in PHP?

    - by outis
    Assuming it's possible, how would one pass arguments by reference to a variadic function without generating a warning in PHP? We can no longer use the '&' operator in a function call, otherwise I'd accept that (even though it would be error prone, should a coder forget it). What inspired this is are old MySQLi wrapper classes that I unearthed (these days, I'd just use PDO). The only difference between the wrappers and the MySQLi classes is the wrappers throw exceptions rather than returning FALSE. class DBException extends RuntimeException {} ... class MySQLi_throwing extends mysqli { ... function prepare($query) { $stmt = parent::prepare($query); if (!$stmt) { throw new DBException($this->error, $this->errno); } return new MySQLi_stmt_throwing($this, $query, $stmt); } } // I don't remember why I switched from extension to composition, but // it shouldn't matter for this question. class MySQLi_stmt_throwing /* extends MySQLi_stmt */ { protected $_link, $_query, $_delegate; public function __construct($link, $query, $prepared) { //parent::__construct($link, $query); $this->_link = $link; $this->_query = $query; $this->_delegate = $prepared; } function bind_param($name, &$var) { return $this->_delegate->bind_param($name, $var); } function __call($name, $args) { //$rslt = call_user_func_array(array($this, 'parent::' . $name), $args); $rslt = call_user_func_array(array($this->_delegate, $name), $args); if (False === $rslt) { throw new DBException($this->_link->error, $this->errno); } return $rslt; } } The difficulty lies in calling methods such as bind_result on the wrapper. Constant-arity functions (e.g. bind_param) can be explicitly defined, allowing for pass-by-reference. bind_result, however, needs all arguments to be pass-by-reference. If you call bind_result on an instance of MySQLi_stmt_throwing as-is, the arguments are passed by value and the binding won't take. try { $id = Null; $stmt = $db->prepare('SELECT id FROM tbl WHERE ...'); $stmt->execute() $stmt->bind_result($id); // $id is still null at this point ... } catch (DBException $exc) { ... } Since the above classes are no longer in use, this question is merely a matter of curiosity. Alternate approaches to the wrapper classes are not relevant. Defining a method with a bunch of arguments taking Null default values is not correct (what if you define 20 arguments, but the function is called with 21?). Answers don't even need to be written in terms of MySQL_stmt_throwing; it exists simply to provide a concrete example.

    Read the article

  • MySQL how to display data from two tables.

    - by gew
    I'm trying to display the username of the person who has submitted the most articles but I don't know how to do it using MySQL & PHP, can someone help me? Here is the MySQL code. CREATE TABLE users ( user_id INT UNSIGNED NOT NULL AUTO_INCREMENT, username VARCHAR(255) DEFAULT NULL, pass CHAR(40) NOT NULL, PRIMARY KEY (user_id) ); CREATE TABLE users_articles ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT UNSIGNED mNOT NULL, title TEXT NOT NULL, acontent LONGTEXT NOT NULL, PRIMARY KEY (id) ); Here is the code I have so far. $mysqli = mysqli_connect("localhost", "root", "", "sitename"); $dbc = mysqli_query($mysqli,"SELECT COUNT(*) as coun, user_id FROM users_articles GROUP BY user_id ORDER BY coun DESC LIMIT 1");

    Read the article

  • Wrong data retrieved from database

    - by holyredbeard
    So, I want to retrieve the order of the elements of a list. The order is set before by the user, and are stored in the table below. Because I also want to retrieve name and description of the list elements I need to combine two tables (see below). However, what is actually retrieved is an array containing 16 elements (should be four because it only exists four elements as for now). The array is too long to post here, but I put it in a phpFiddle to be found here if you're interested. Well, I have really tried to find what's wrong (probably something easy as always), but with no luck. Thanks a lot for your time and help! listModel.php: public function GetOrderedElements($userId, $listId) { // $userId = 46 // $listId = 1 $query = "SELECT le.listElemId, le.listElemName, le.listElemDesc, lo.listElemOrderPlace FROM listElement AS le INNER JOIN listElemOrder AS lo ON le.listId = lo.listId WHERE lo.userId = ? AND lo.listId = ? ORDER BY listElemId"; $stmt = $this->m_db->Prepare($query); $stmt->bind_param("ii", $userId, $listId); $listElements = $this->m_db->GetOrderedElements($stmt); return $listElements; } database.php: public function GetOrderedElements(\mysqli_stmt $stmt) { if ($stmt === FALSE) { throw new \Exception($this->mysqli->error); } if ($stmt->execute() == FALSE) { throw new \Exception($this->mysqli->error); } if ($stmt->bind_result($listElemId, $listElemName, $listElemDesc, $listElemOrderPlace) == FALSE) { throw new \Exception($this->mysqli->error); } $listElements = array(); while ($stmt->fetch()) { $listElements[] = array('listElemId' => $listElemId, 'listElemName' => $listElemName, 'listElemDesc' => $listElemDesc, 'listElemOrderPlace' => $listElemOrderPlace); } var_dump($listElements); $stmt->Close(); return $listElements; } from the database: listElemOrder: listElemOrderId | listId | listElemId | userId | listElemOrderPlace 1 1 1 46 1 2 1 2 46 4 3 1 3 46 2 4 1 4 46 3 listElement: listElemId | listElemName | listId | listElemDesc | listElemOrderPlace 1 Elem A 1 Derp NULL 2 Elem B 1 Herp NULL 3 Elem C 1 Lorum NULL 4 Elem D 1 Ipsum NULL Note: 'listElemOrderPlace' in the table listElement is the final order of the elements (all users average), not to be mixed with the one with the same name in the other table, that's only a specific user's order of the list elements (which is the interesting one in this case).

    Read the article

  • Cannot connect to MySQL 4.1+ using old authentication

    - by B T
    I'm trying to connect to a mySQL database at http://bluesql.net, but when I try to connect, it gives this error: Connect Error (2000) mysqlnd cannot connect to MySQL 4.1+ using old authentication I've looked into this, and it has to do with some old password scheme used before MySQL 4.1. Newer versions have the option to use old passwords, which I've read may cause this problem. I'm running php 5.3, and connecting with mySQLi (new mysqli(...)). I'm hoping I can do something in the code to connect to the DB at bluesql.net - clearly I don't control how their database is set up. Downgrading php versions isn't an option. Anyone have any ideas?

    Read the article

  • MySQL: How to consume/discard the result of a query?

    - by GetFree
    I have a stored procedure which executes an optimize table statement for every table in a DB. Those optimize table statements are prepared statements of course (they have to be built at runtime) and I need to call that procedure from PHP using ext/mysql API. Unfortunately, ext/mysql does't support doing such thing because optimize table returns a result set and in order to handle that, the new mysql protocol is required, which is supported by the "new" ext/mysqli API. Well... there are several things I dont have control over, so it's not in my posibilities to upgrade to ext/mysqli any time soon, nor can I implement the procedure as PHP code rather than sql code. So I thought if it would be possible somehow to consume/discard the result of optimize table inside the stored procedure so that ext/mysql doesn't complain about it. One thing to consider is that since the optimize table statements are prepared statements, you can't use a cursor over them.

    Read the article

  • PHP - MySQL how to delete an image when a user submits a new image problem.

    - by pc-wiki
    I'm trying to delete the current image that is already set on the server when a user submits a new image to the server, but I don't know how to do add this to my current code can some one please help me? Here is my PHP & MySQL code. if(isset($_FILES["thumb"]["name"])) { if (file_exists("/images/" . $_FILES["thumb"]["name"])) { $thumb != $_FILES["thumb"]["name"]; } else if($_FILES["thumb"]["name"] == TRUE) { move_uploaded_file($_FILES["thumb"]["tmp_name"], "/images/" . mysqli_real_escape_string($mysqli, htmlentities(strip_tags(basename($_FILES["thumb"]["name"]))))); $thumb = mysqli_real_escape_string($mysqli, htmlentities(strip_tags(basename($_FILES["thumb"]["name"])))); } if($thumb == TRUE) { //create thumb code here... } }

    Read the article

  • When I write a post on the board, with the posts and tried to put the image into

    - by bismute
    When I write a post on the board, with the posts and tried to put the image into. When I add an image, the text in the image are about to enter. <?php $reg_date = time(); $member_idx = $_POST['member_idx']; $q = "INSERT INTO ap_bbs (member_idx, subject,content,reg_date) VALUES('$member_idx', '$subject', '$content', '$reg_date')"; $result = $mysqli->query($q); if ($result==false) { $_SESSION['writing_status'] = 'NO'; } else { $_SESSION['writing_status'] = 'YES'; } $mysqli->close(); ?> Writing, I think the logic is as follows, where the images in the attachment content and I'm wondering if there is any way to put.

    Read the article

  • Why does Cacti keep waiting for dead poller processes?

    - by Oliver Salzburg
    sorry for the length I am currently setting up a new Debian (6.0.5) server. I put Cacti (0.8.7g) on it yesterday and have been battling with it ever since. Initial issue The initial issue I was observing, was that my graphs weren't updating. So I checked my cacti.log and found this concerning message: POLLER: Poller[0] Maximum runtime of 298 seconds exceeded. Exiting. That can't be good, right? So I went checking and started poller.php myself (via sudo -u www-data php poller.php --force). It will pump out a lot of message (which all look like what I would expect) and then hang for a minute. After that 1 minute, it will loop the following message: Waiting on 1 of 1 pollers. This goes on for 4 more minutes until the process is forcefully ended for running longer than 300s. So far so good I went on for a good hour trying to determine what poller might still be running, until I got to the conclusion that there simply is no running poller. Debugging I checked poller.php to see how that warning is issued and why. On line 368, Cacti will retrieve the number of finished processes from the database and use that value to calculate how many processes are still running. So, let's see that value! I added the following debug code into poller.php: print "Finished: " . $finished_processes . " - Started: " . $started_processes . "\n"; Result This will print the following within seconds of starting poller.php: Finished: 0 - Started: 1 Waiting on 1 of 1 pollers. Finished: 1 - Started: 1 So the values are being read and are valid. Until we get to the part where it keeps looping: Finished: - Started: 1 Waiting on 1 of 1 pollers. Suddenly, the value is gone. Why? Putting var_dump() in there confirms the issue: NULL Finished: - Started: 1 Waiting on 1 of 1 pollers. The return value is NULL. How can that be when querying SELECT COUNT()...? (SELECT COUNT() should always return one result row, shouldn't it?) More debugging So I went into lib\database.php and had a look at that db_fetch_cell(). A bit of testing confirmed, that the result set is actually empty. So I added my own database query code in there to see what that would do: $finished_processes = db_fetch_cell("SELECT count(*) FROM poller_time WHERE poller_id=0 AND end_time>'0000-00-00 00:00:00'"); print "Finished: " . $finished_processes . " - Started: " . $started_processes . "\n"; $mysqli = new mysqli("localhost","cacti","cacti","cacti"); $result = $mysqli->query("SELECT COUNT(*) FROM poller_time WHERE poller_id=0 AND end_time>'0000-00-00 00:00:00';"); $row = $result->fetch_assoc(); var_dump( $row ); This will output Finished: - Started: 1 array(1) { ["COUNT(*)"]=> string(1) "2" } Waiting on 1 of 1 pollers. So, the data is there and can be accessed without any problems, just not with the method Cacti is using? Double-check that! I enabled MySQL logging to make sure I'm not imagining things. Sure enough, when the error message is looped, the cacti.log reads as if it was querying like mad: 06/29/2012 08:44:00 PM - CMDPHP: Poller[0] DEVEL: SQL Cell: "SELECT count(*) FROM cacti.poller_time WHERE poller_id=0 AND end_time>'0000-00-00 00:00:00'" 06/29/2012 08:44:01 PM - CMDPHP: Poller[0] DEVEL: SQL Cell: "SELECT count(*) FROM cacti.poller_time WHERE poller_id=0 AND end_time>'0000-00-00 00:00:00'" 06/29/2012 08:44:02 PM - CMDPHP: Poller[0] DEVEL: SQL Cell: "SELECT count(*) FROM cacti.poller_time WHERE poller_id=0 AND end_time>'0000-00-00 00:00:00'" But none of these queries are logged my MySQL. Yet, when I add my own database query code, it shows up just fine. What the heck is going on here?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13  | Next Page >