If you want to have the Link in a new window yust remove the onclick-attribute. You can specify the target window with the attribute target. In your case it is set to _blank which means "open the link in a new Window" So change: echo '<td><a traget="_blank" onclick="pop_up(this)" href=VIEWSAMPLE.PHP?user_id='.$row["user_id"].'>'.$row["username"].'</a></td>'; To:...
php,mysql,search,pdo,pagination
Your field_oem_value and field_oem_pn_value params are getting lost after clicking on any of the pagination links. You need to specify them explicitly in link's href (or save in session). Do something like this: $params = [ 'field_oem_value' => $oemSearch, 'field_oem_pn_value' => $oempnSearch ]; // The "back" link $prevlink = ($page...
One: Yes, you are right. If you pass an array as a parameter to the execute method, then it will handle it as a bound parameter, and will consider it as a string (PDO::PARAM_STR). Two: Yes, but you have to use it together with either bindParam(), bindValue(), or a parameterized...
php,pdo,utf-8,character-encoding
Finally I did it. I have used ODBC Driver for connecting to SQL Server and then do the SELECT. $pdo = new PDO ("odbc:Driver={SQL Server};Server=$hostname;Database=$dbname; Uid=$username;Pwd=$pw;"); Note: I did this connection in my test environment (Windows 7) and not on FreeBSD. ...
Your example is a way to do it, but I will give my example of how I would handle this, especially when you can potentially have a significant number of inputs, without constantly needing to update SQL queries or the database when you were to add, remove, or reorder the...
The thing is your db class 'select' method always makes use of PDO fetchAll, if your action is based on a single row only then why not pass just the one result to the template? $results = $db->select("Contacts", "ContactID = :id", $bind); if (empty($results)) { throw new Exception("No contact found");...
php,mysql,encryption,pdo,mcrypt
additionally encode base64 encode after encryption base64_encode($encrypted) and decode before decryption base64_decode($encrypted) ...
$db->dbc(); this has no effect since you do not store the return value in a variable and then use this variable to make the call to prepare(). Also you're not storing the PDO object in a member variable but in a local variable in the constructor method -> falls out...
are you sure it fails? what is the result of this code? $pdo = new PDO( "mysql:dbname=" . SQL_DB . ";host=" . SQL_HOST, SQL_USER, SQL_PWD, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ) ); try { $stm = $pdo->prepare("show index from `TABLENAME` where `Key_name` = 'PRIMARY'"); $res = $stm->execute(); print_r($stm->fetch(PDO::FETCH_ASSOC)); } catch (Exception...
I can't see it in the code code you posted but you have a typo in the original: "$stmt = $db->query" has an extra question mark "$stmt = $db-?>query". Or maybe you have commented out an area with html tags and php comments which are incorrectly nested? Either way, it...
"yeh, the problem was with the missing $ signs when declaring x in the loop. Write it up as an anwser and I'll accept it. Thanks" As per OP's request, comment to answer: this for($x=0; x<count($result); x++) { you're missing $ signs for the x's The x is treated...
This is the best method that i could find. $results = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach($results as $result){ $result['object'] = description($result['object']); $myresult[] = $result; } echo json_encode($myresult); ...
You have a typo: 2 x :seachword and 2 x :searchword
php,mysql,security,laravel,pdo
The question is somewhat unanswerable (atleast not in a way that will not give you a false sense of security) with the amount of resource provided. Since you are using PDO I'll go right ahead and say that you ought to be using prepared statements. Injection on a whole primarily...
php,mysql,laravel,pdo,virtualbox
You need to uncomment the bind-address argument to allow for connections outside of the VM. bind-address = 0.0.0.0 ...
What you'll need to do is find the username in the database and retrieve the hash, then pass it to password_verify $sql = $db->prepare("SELECT Nick,Password FROM registrace WHERE Nick=:nick"); // PDO binds and execute here if($row = $sql->fetch()) { if(!password_verify($_POST['password'], $row['Password']) { //login fail ...
Instead of building a class to create the booking objects, it would be advisable to either create a standalone function, or a function within a parent class to achieve this. The issue I run in to with using fetchAll() with the FETCH_CLASS parameter, is that the objects do not automatically...
I knew there were fields that were empty that should have caught the check, but they were empty rather than NULL. So, when I was checking for NULL fields, it didn't find any. What I had to do was set all the empty columns to NULL: UPDATE `table` SET `column`...
Are you ok with associative arrays? Then create a new array (say $def_presentation or something ) and go for something like foreach($presentation as $row) { if(!isset($def_presentation[$row['presentation_uid']])) { $def_presentation[$row['presentation_uid']] = $row; unset($def_presentation[$row['presentation_uid']]['customfield_name'],$def_presentation[$row['presentation_uid']]['customfield_data_value']); $def_presentation[$row['presentation_uid']]['customfields'] = array(); }...
Actually, transactions (which, in MySQL, requires use of "InnoDB" tables ...) are quite efficient. The database engine will (probably ...) lock all of the storage pages that are covered by the query, and might delay actually writing the pages back to the store until after the transaction COMMITs. My suggestion...
Reference: 11.4.3 The BLOB and TEXT Types https://dev.mysql.com/doc/refman/5.6/en/blob.html Excerpt: The maximum size of a BLOB or TEXT object is determined by its type, but the largest value you actually can transmit between the client and server is determined by the amount of available memory and the size of the communications...
Use fetchColumn() instead of fetch() $query5 = $conn->prepare("SELECT MAX(spot_nb) from camping where capacity=2 and availability='Y'"); $query5->execute(); $result = $query5->fetchColumn(); $id = (int) $result; ...
Proof of concept with comments inside <?php if (isset($_POST["submit"]) /* add validation such as title and text are not empty*/ ) { $user='root'; $password=''; // close all db code to try/catch try { $dbh = new PDO("mysql:host=localhost;dbname=localy", $user, $password); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line // prepare your query...
There are a few things wrong here. Firstly, you missed the parameter for the SET for UPDATE produit set pr_id_vin, Then you're mixing ? and : placeholder types. Since I cannot be sure of what your column names are, I will let you fill those in by following this example:...
You are binding the exact string '$steamId' to the id so that it will search for an user with the id of '$steamId'. $stmt->bindParam(":id", $steamId, PDO::PARAM_STR); Also you can remove the quotes from the select statement. $stmt = $conn->prepare("SELECT Steam_id from Account_info WHERE Steam_id = :id"); ...
Since you are using PDO, you need to set the encoding like so... $db = new PDO("mysql:host=$hostname;dbname=topdecka_PTC;charset=utf8",$username, $password); When you obtain data from MySQL any text will be encoded in "client encoding", which is likely windows-1252 if you don't configure it otherwise. The character that is causing your problem is...
It depends on what you're trying to achieve. If you want to see all the inserts as an 'atomic operation' you are doing right, as if one call to the SP fails, the rollback will undo all the changes made from the previous calls If, otherwise, you want to "isolate"...
You can't chain comparisons like that. Each where statement must include the identifier you are doing a comparison on. You also need to use parenthesis to enforce operator precedence (that was going to be your next error). SELECT id, autorid, date, longitude, latitude, title, text FROM post WHERE ( longitude...
You forget to close the prepare function. That's all. $msg_table_query = $db->prepare("INSERT INTO msg_messaes (sender_id,recipient_id,msg ) VALUES (:sender_id, :recipient_id, :msg")"); $msg_table_query->execute([':sender_id' => 3, ':recipient_id' => 4, ':msg' => 'test']); var_dump($db->errorInfo());...
Few things to change: dont forget $ if your going to catch the error, catch the whole pdo code You can use rowCount() to count the rows echo something if the record count is 0 include 'config.php'; $id = "264540733647332"; try { $conn = new PDO("mysql:host=$hostname;dbname=mydata", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);...
As you are on a host now and not wamp, the following may not be possible in a hosted environment but give it a shot. (note the .cnf modification may not be possible) show variables like '%wait_timeout%'; show global variables like '%wait_timeout%'; You would run at a mysql prompt: set...
You never return $db in your funtion getConnection(); change the funtion to: function getConnection(){ try { $hostname = "busctrlctr-pc"; $dbname = "DispenserSystem"; $username = "sa"; $password = "123456"; $db = new PDO ("sqlsrv:Server=$hostname;Database=$dbname", $username, $password); echo 'We are succesful to connect the database !!'.'<br>'; // successful word return $db; }...
This answer as per the original post. (I also performed a rollback to the original post). I'll explain graphically. This line: (name= :nam, last_name1= :last_n1,family_id= :id_family, user_id= :id_user) that isn't the proper syntax for an INSERT using PDO. Remove all of the word/equals (:nam, :last_n1, :id_family, :id_user) References: http://php.net/pdo.prepared-statements http://php.net/manual/en/class.pdoexception.php...
you just need to extend your code slightly. at the moment your query is only bringing out 1 field, the password. SELECT * FROM members WHERE email = :email AND active="Yes" this will then return the whole row, not just one field. you can then extract the username and put...
php,mysql,pdo,database-administration
I have managed to achieve what I wanted with the following line: $categorynumber = $dbh->lastInsertId(); full example: function create_category($userid) { // connect to database with PDO $dsn = 'mysql:host='.DB_HOST.';dbname='.DB_DATABASE; $dbh = new PDO($dsn, DB_USER, DB_PASSWORD); // insert category and get the category_id $categorynumber = 0; $stmt = $dbh->prepare("INSERT INTO categories...
There is a missing, ), to close the column assignment, before the implode. $sql = "INSERT INTO stackoverflowplaceholder (".implode("','",$stacks)." VALUES ("; will be $sql = "INSERT INTO stackoverflowplaceholder (".implode("','",$stacks)." ) VALUES ("; ...
You cant have same name for multiple inputs if it is not an array, else they will be overwritten by the last one. Try with - <form action="send.php"> <input type="checkbox" name="txt_group[]" value="CID">CID <input type="checkbox" name="txt_group[]" value="OSDS">OSDS <input type="checkbox" name="txt_group[]" value="SGO">SGO <input type="submit"> </form> With php an example query will be...
It is not, I'd recommend something like this: $diagSel = $_POST['diagSel']; $search_crit = $_POST['criteria']; $list = explode(',', $search_crit); array_map(array($dbh, 'quote'), $list); $sql1 = sprintf(' SELECT * FROM `myTable` WHERE `Diagnosis` = :diagnosis AND `zip_code` IN (%s) GROUP BY `Provider Number`', implode(',', $list)); $stmt = $dbh->prepare($sql1); $stmt->bindParam(':diagnosis', $diagSel, PDO::PARAM_STR); $stmt->execute(); $result1...
You would have to set a transaction on database B also. Since you are not posting ChildUser code, here is an example : app/models/ChildUser.php : class ChildUser extends Eloquent { protected $connection = 'some_connection'; // as defined in app/config/database.php } Then your code public function devUserCreateTest() { DB::beginTransaction(); DB::connection('some_connection')->beginTransaction(); //...
Assuming you have a page variable in the GET global, you could use Limit in your SQL statement. $results_per_page = 10; $skip = ($_GET['page'] - 1) * $results_per_page; $sql = "SELECT * FROM _products LIMIT :skip, :show"; $handler = dbConnect()->prepare($sql); $handler->bindValue(":skip", $skip); $handler->bindValue(":show", $results_per_page); $handler->execute(); $result = $handler->fetchAll(); ...
Your $stmt->fetchALL(PDO::FETCH_CLASS); is returning a array of objects. To access properties of objects you should use ->, so try this: print $row->BUS_ID; Inside your foreach....
Try this (works on my computer : Ubuntu, Apache2, MySQL) <?php try { $db = new PDO("mysql:hostname=localhost",'root','pw'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { echo $e->getMessage(); die(); } //to create database $db->query("CREATE DATABASE IF NOT EXISTS theShop;"); $db->query("USE theShop;"); $createTableShops = "CREATE TABLE `advertisor` ( `ShopID` INT UNSIGNED NOT NULL AUTO_INCREMENT...
Be careful when ever you are creating columns with not null attribute. You need to pass value always when you want to save the data to that table. Change in table. Change the default value of telephone field to null. so that if no value is assigned then automatically null...
This ...snip... ) LIKE '%' LOWER(:wildcard) '%' OR ...snip is incorrect. You've got a string ('%') followed by a function call (LOWER()) followed by another string, and they're just sitting there - no connecting logic, no concatenation, blah blah blah . It should be ... LIKE CONCAT('%', LOWER(:wildcard), '%') OR...
php,arrays,multidimensional-array,pdo
You have to loop over $data array and add function as per your requirement. Fetch values from `... VALUES (:foo, :bar); Then explode as you did in your code , then loop over $col array and add values to $data as required foreach($col as $val){ $method = "get".ucfirst( $val); $data[...
I don't think mysqli and PDO are compatible as shown in the error you provided. So what I do for my database connection is: function dbConnect() { global $dbh; $dsn = DB_HOST; $user = DB_USER; $password = DB_PASS; try { $dbh = new PDO($dsn, $user, $password); } catch(PDOException $e) {...
The SELECT part of the statement chooses what data to return for each row - so ABS( Poscode - :distance ) AS distance will return a field called distance that is the difference between the field Poscode and the value :distance for each row. The WHERE part of the statement...
I think you forger query statement $dbh->query().Also username is written in quotes $sql = "SELECT code FROM user2 WHERE username = '".$username."' "; if ($res = $dbh->query($sql)) {// need to add this line in your code // then after fetchColumn $result = $res->fetchColumn(); } ...
Functions and methods don't behave differently within a specific context. If $bd->query() runs the query the behavior won't change if it's in a if statement. So, yes it does run the query you could try something like this to test your query $result = $db->query(); if (is_null($result)) { var_dump($result); }...
Firstly, you forgot the $ sign for %:seachword% as per your assignment: Sidenote: There's a typo that I just noticed in seachword which should read as searchword as per ':searchword' => $searchword $searchword = $_POST["searchword"]; However, I'd do something like this instead: LIKE :seachword then $query->execute(array(":searchword" => "%" . $searchword...
You can generate a parameterised query with a dynamic number of parameters like this: $searchString = "WHERE Aktivno = 1"; $params = array(); $paramNum = 1; foreach($pretragaArray as $key => $item) { $paramName = ':param' . $paramNum++; $searchString = $searchString." AND"; $searchString = $searchString." ". $key ." = " ....
You need to echo JSON encoded data: Change this line: return $result; To: echo json_encode($result); ...
php,mysql,security,pdo,prepared-statement
To clear any confusion, what i'm doing is this: $pdo = new PDO('..'); $sql = 'SELECT id FROM users WHERE username = :username'; $statement = $pdo->prepare($sql); $statement->bindParam(':username', $_POST['username']); Question is, what if $_POST['username'] contains 'SELECT * FROM users' (or any other query) ? This query would return the ids...
Try this... SELECT * FROM questions LEFT JOIN options ON questions.questionID=options.questionID WHERE options.questionID=questions.questionID ORDER BY RAND() LIMIT 8 //You will need 8 rows as each question has 2 option rows Hard to know without seeing your db schema but this should work. In your PHP script this change may help...
Thanks to @James Taylor for the suggestion of .htaccess file. The problem was hiding in RewriteRule and parameter QSA.
It could make a big difference if you do not have an index. Consider the following with no index: select * from clients where client_id = x The engine will need to scan the entire table to determine that there is only one row. With limit 1 it could stop...
By adding a line and moving $id before $statement it is all fix thanks to Dante Javier Input code xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //Under this add the following lines: var id = document.getElementById('myid').value; xmlhttp.send("id="+id); Data Code $id = $_POST['id']; //Move this above the $statement = $connection->prepare. ...
Keys is a reserved word in MySQL. Either change your column name (better solution) or update your query wrapping keys in backticks. INSERT INTO asce (idn, `keys`... ...
Your variable assignments are all wrong. They should be: $range = $_COOKIE["range"]; $longitude = $_COOKIE["longitude"]; $latitude = $_COOKIE["latitude"]; When you try to use a non-numeric string as a number in an arithmetic expression, it's treated as 0. So the result of your code was effectively: $le = 0 * $onemile;...
I don't know the source of the array $arr = array();, but it is assigned to null before the insert query. So it means, literally you are inserting nothing into the database. So check your array well, maybe it was to be like $arr = array('name'=>'My Name', 'url'=>'url', 'email'=>'my email',...
php,mysql,database,pdo,zend-framework2
Your code looks good. The only issue I can see is that you are using the ClassMethods hydrator and you have no setters on your entity. The hydrator will use the entity API to hydrate the entity, if the setId, setName or setText are not callable then the values will...
You should FETCH i.e., $sql->fetch(PDO::FETCH_ASSOC); So, You shall have something like $sql = "SELECT MAX(id) FROM employees"; $sql = $db->prepare($sql); $sql->execute(); $result = $sql->fetch(PDO::FETCH_ASSOC); print_r($result); Note : Simply $lid = $sql->execute(); means it will assign whether the query is executing or not. As your query is executing it is returning...
From PHP documentation: Returns a single column from the next row of a result set or FALSE if there are no more rows. For fetching use: Single row fetch: $stmt->fetch(); Multiple rows fetch: while($stmt->fetch()) { //do something } ...
It looks alright for a basic implementation, beside that you shouldn't echo something inside a class. If you want see a well implemented solution, have a look into eloquent created by taylor otwell. That should give you heaps of ideas how to improve your code. https://github.com/laravel/framework/blob/4.2/src/Illuminate/Database/Connection.php...
According to your script, you seem like you want 2 columns. One with row_1 and one with count(user_id). If so, UNION is not the correct operator. Your code as it stands returns 2 rows with one column each. But in your PHP you called $query->fetch(). That only returns the first...
Assuming you're using the same script to display the form and process the submission, you need to check whether the form was submitted before updating the DB. if (isset($_POST['header1'], $_POST['summary1'])) { $header1 = $_POST['header1']; $summary1 = $_POST['summary1']; $handler = new PDO('mysql:host=localhost;dbname=myDB', 'username', 'password'); $handler->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "UPDATE myTable SET...
You are receiving the invalid parameter number error because you are using bindParam() and passing an array into execute(). Passing any array to execute() will erase and replace any previous bindings. You need to bind your data through bindParam() or execute(), but not through both. To solve this problem, change...
php,sql,pdo,prepared-statement
You can't use same named bind parameters within prepare statement your parameters name must be unique as $stmt = $connection->prepare("UPDATE users SET name = :newName WHERE name = :oldName"); $stmt->bindParam(':oldName', $oldName); $stmt->bindParam(':newName', $newName); ...
Most likely your statement fails to insert, Your code is full of problems: You used prepare statement but yet you put values in the query string hashed_password is undefined in the first query You try to bind multiple queries at once wrong order prepare the first query, execute , then...
Hmmmm... There are some flaws I can see: database.php $host = "us-cdbrbababababableardb.net"; $user = "b9bababababefc"; $pass = "9c4ababab"; $dbname = "heroku_aabababab49"; $DBH = null; try { # MySQL with PDO_MYSQL $DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass); $DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); } catch(PDOException $e) { echo $e->getMessage(); } ?> file that...
Your problem is the typos in your code. In delete.php, your code has two big ones. First, btn-del should be btn_del. Second, your closing </script> tag has a typo. You also have ;" at the end of the script where you should have ";. Your code should be: <?php include_once...
Create a variable to store your prepared statement then execute that. $connection = MYSQLDatabase::getInstance()->getConnection(); $statement = $connection->prepare("INSERT INTO users etc etc......."); $insertArray = $statement->execute(array( ":username" => $_POST["username"] )); ...
There are some issues with how you build your sql query esp. around the $crumbs part - it's not marked as a string literal for MySQL. Your script is also prone to sql injections. You could use prepared statements to get rid of those problems. <?php if ( isset($_POST['username'], $_POST['email'],...
you could add another column to each UNION SELECT where you define the table $lister_query = " SELECT * FROM (SELECT lister1_password lister_password, lister1_status lister_status, lister1_email lister_email, 'lister1' lister_table // define lister_table FROM lister1 UNION SELECT lister2_password lister_password, lister2_status lister_status, lister2_email lister_email, 'lister2' lister_table // define lister_table FROM lister2 UNION...
The warning is occuring on line 29 (so at foreach($row['posted'] as $time)). The reason is that $row['posted'] is not an array. Change the loop to this for($i = 0; $i < count($result); ++$i) { $result[$i]['posted'] = strtotime($result[$i]['posted']) * 1000; } ...
MySQL Command Line If you are using the MySQL command line tool the output given will let you differentiate the two scenarios. If the entry doesn't exist: +---------------+---------+ | user_id | faculty | +---------------+---------+ | 80 | abc | +---------------+---------+ mysql> UPDATE `undergraduate` set `faculty` = 'Efac' WHERE `user_id` =...
Use a group by and join: select e.* from entries e join (select title, max(time_added) as maxta from entries e where dataset_id = xxx group by title ) emax on emax.title = e.title and e.time_added = emax.maxta where dataset_id = xxx order by e.timestamp; Your method uses a MySQL extension...
PDO::exec() returns the number of rows that were modified or deleted by the SQL statement you issued. If no rows were affected, PDO::exec() returns 0. try this: $nrows = $this-con->query("delete from aTable WHERE id = "'".$id."'")->fetchColumn(); ...
There are two problems with what you have now: You are calling nextRowset() on the array that contains your data and you are not getting the data from the second row set. You need something like: $result = $query->fetchAll(); // now $result contains your row with data // get the...
As long as the string passed to prepare() is static (i.e. does not contain any variables), you should be safe from SQL injections. The important part is separating user input from your SQL statements, and you do that by having the SQL passed to prepare() and the user input to...
I assume after the first INSERT the field orderID is NULL. You could therefore run a query that updates ALL records WHERE orderID IS NULL. No need to pull any values into PHP, MySQL's lpad(), date_format() and concat functions should do the trick. sscce: <?php $pdo = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'localonly',...
fetchAll returns all of the rows. So you shouldn't call it inside a loop. You can solve that in different ways. Here is one: // Get the entire dataset $rows = $result->fetchAll(PDO::FETCH_ASSOC)); // Loop through the array foreach ($rows as $row) { echo $row['id']; } Another way (the one you...
php,mysql,pdo,foreign-keys,sql-insert
You are setting the foreign key on the wrong table. you have to set the foreign key on the field id of the table user_data referencing the filed id on the table users Now you are trying to insert the data in the table users, but, as the id should...
Here's a rough answer which should resolve the injection issue, the non-executing query issue, and the incorrect insert syntax. I don't have your DB so I can't confirm this is fully functional but it should be closer.. <?php // include to get database connection include_once 'config/db.php'; try{ $a_id = "SELECT...
all you need to do is concatenate the string like this: foreach($rslt as $val){ foreach($val as &$grade){ $grade = "Grade ".$grade; } $sd[] = $val; } However, you should clean your array. You currently have this structure: array( array( "0" => 97, "1" => 38, "2" => 73, "physics" =>...
Use something like this after your execute statement: $results = $stmt->fetchAll() Then to loop through the results: foreach($results as $row){ echo $row['Agent']. ": ". $row['Tickets']; } ...
Change $http.get('/scripts/php/articles.php') to $http.get('http://YOURDOMAIN.COM/scripts/php/articles.php') Off course you need to replace YOURDOMAIN.COM with localhost or any other domain you are using....
php,sql-server,pdo,odbc,sqlsrv
Change it to: $this->link = new PDO( "sqlsrv:Server={$this->serverName},{$this->port};Database={$this->db};", $this->uid, $this->pwd ); The default SQL Server port is 1433. Note the curly brackets, they allow for class variables....
You forget table name in your query $this->db->select('password'); $this->db->where('email', $this->input->post('email')); $this->db->get('mytable');// add table name in your query ...
Seems like I figured it out and can answer my own question. It looks like XAMPP is delivering a non-suitable ddl with their distribution. The right and most recent oci8 dll's are downloadable here in all possible flavors: http://windows.php.net/downloads/pecl/releases/oci8/2.0.8/. Once I got the right one, it worked like a charm.
$stmt->execute() returns a boolean indicating success/failure. Instead, use this: $stmt->execute(); $result = $stmt->fetchAll(); ...
Key 0 doesn't exist. As you see in dump, you have one record. There are no keys 0 and 1 in your one-item array. echo $stations['Leicester']; // returns LESTER ...
No difference but only advantage it is more readable. mysqli only has ? which is not as nice to read when you got too many parameters Imagine something like this: $stmt = $db->prepare( "Call store_procedure ?,?,?,?,?,?,?,?,?,?"); it could be so much more error prone and hard to debug...
Just few modifications in your code if( isset($_GET['edit']) ) { $id = $_GET['edit']; $res= "SELECT * FROM staff_db WHERE staff_id='$id'"; $r = $conn->query($res); $r->setFetchMode(PDO::FETCH_ASSOC); $result = $r->fetch(); } and few modification in your form to put value <input type="text" name="staf_name" value=<?php echo $result["staff_name"]; ?>/> ...
PDO and MySqli are mutually exclusive. They do similar things and cannot be used together. To use PDO (my strong recommendation), change references from MySqli to MySQL $GLOBALS['config'] = array( 'mysql' => array( 'host' => 'localhost', 'username' => 'root', 'password' => '', 'db' => 'sfd' ), Here is an in...