This question already has answers here:
Why shouldn't I use mysql_* functions in PHP?
(14 answers)
Closed 6 years ago.
I'm trying to connect my form to the database but it keeps giving me this error.
( ! ) Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\Excercise\Real\base.php on line 9
Call Stack
# Time Memory Function Location
1 0.4390 135464 {main}( ) ...\index.php:0
2 0.5110 137784 include( 'C:\wamp\www\Excercise\Real\base.php' ) ...\index.php:1
3 0.7050 138816 mysql_connect ( ) ...\base.php:9
It's telling you that your version of mysql is outdated and you need to use mysqli instead.
Related
This question already has answers here:
PHP - Using PDO with IN clause array
(9 answers)
Why does this PDO statement silently fail?
(2 answers)
Closed 3 years ago.
I have a little problem with my SQL query:
I have a variable ($arraySearch) with a string:
$arraySearch = "'Bob', 'Ross'";
My PHP query:
$stmt = $this->pdo->prepare("SELECT * FROM `kunden` WHERE `FAMNAME` IN (arraySearch =:arraySearch) AND `VORNAME` IN (arraySearch = :arraySearch)");
$stmt->execute(['arraySearch' => $arraySearch]);
$all = $stmt->fetchAll(PDO::FETCH_CLASS, $model);
Error Code:
Fatal error: Uncaught Error: Call to a member function execute() on boolean
I've been searching for the error for hours but I can't find it.
What am I missing?
Does somebody have any idea?
best regards
This question already has answers here:
PHP PDOException: "SQLSTATE[HY093]: Invalid parameter number"
(4 answers)
How to view query error in PDO PHP
(5 answers)
Use bound parameter multiple times
(5 answers)
Closed 4 years ago.
I have this very simple MCVE where even no table/database is affected:
<?php
$pdoConnection = new PDO( "mysql:host=<hostname>", "<user>", "<pwd>" );
$pdoConnection->setAttribute( PDO::ATTR_EMULATE_PREPARES, TRUE );
$command = $pdoConnection->prepare("SELECT IF('1', -:foo, :foo) AS FOO");
$command->bindValue( "foo", 1, PDO::PARAM_INT );
$command->execute();
echo "<pre>";
print_r($command->fetch(PDO::FETCH_ASSOC));
?>
The result is as expected:
Array
(
[FOO] => -1
)
Disabling the prepare emulation with
$pdoConnection->setAttribute( PDO::ATTR_EMULATE_PREPARES, TRUE );
breaks totally the code. No error and also no output as nothing has been executed even it is a regular and correct MySQL code.
My questions:
Is there a legal reason why there is no result, or
is it a bug, but what causes the bug? PHP or MySQL?
Versions:
OS: SLES 12.3
PHP: 7.2.9
MySQL 8.0.12
This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
Closed 6 years ago.
My code is as following:
$br_code=$_SESSION["br_code"];
echo $sqlstr="select DISTINCT branch_assets.s_id,s_name
from branch_assets,assets
where assets.s_id=branch_assets.s_id and
br_code='$br_code'";
echo $result=mysql_query($sqlstr);
while($row1=mysql_fetch_array($result))
{
}
But on the line of while loop it show me warning as
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\System_management\send_in_maintanance1.php
where is my mistake please help to find this.
$sqlstr="select DISTINCT branch_assets.s_id,s_name from branch_assets,assets where assets.s_id = branch_assets.s_id and br_code='".$br_code."'";
It's best to switch to either mysqli or PDO with a prepared statement instead of mysql_, since it is deprecated and deleted from PHP 7.0.
Reference:
https://en.wikipedia.org/wiki/Prepared_statement
This question already has an answer here:
The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead [duplicate]
(1 answer)
Closed 8 years ago.
i just update my server. it showing an error today
Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the >future: use mysqli or PDO instead in C:\wamp\www\work\db\dbfields - Copy.php on line 33
my dbfields - Copy.php page is
mysql_query("insert into user(name,address) values('$name','$address')");
i create 2 columns (name&address), need to insert the value of var($name& $address).
mysqli_query is now used instead of mysql_query. You can also use PDO::query or MySQLi::query. You can see the documentation here
Read : The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead
It basically means mysql_query() can no longer be used. You will have to switch to using PDO.
For PDO, read: http://php.net/manual/en/book.pdo.php
This question already has an answer here:
PHP connection error with the database [closed]
(1 answer)
Closed 8 years ago.
I keep getting this error each time I run my .php page
It is supposed to show images taken from the server.
This page does show all the images but also error which is:
"Warning: mysqli_select_db() expects parameter 1 to be mysqli, string
given in F:\users\1203158\httpdocs\Adventure_Sports\gallery.php on
line 79 "
I do not understand how to eliminate this error
You presumably have:
$link = mysqli_connect( ... );
And my guess is you're doing:
mysqli_select_db("database_name");
That's how it was done with mysql_select_db, but with mysqli_, you have to pass the connection handler.
mysqli_select_db($link, "database_name");
The error is telling you that it's expecting a mysqli object (the connection handler) but is getting a string (the database name).