mysql_query() vs mysqli_query()

+1 Rehman . · January 26, 2015
i am making login in php i wrote a code for mysql query it says :
Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\dist\core\functions\users.php on line 5
Call Stack

and when i change to  mysqli_query() it says :

Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\wamp\www\dist\core\functions\users.php on line 5
Call Stack

can anybody know what i'm doing wrong ?

Post a Reply

Replies

Oldest  Newest  Rating
+1 Rehman . · January 26, 2015
yes it worked after giving two parameters every thing is disturbed after the new version of PHP i'm hating it now, now i'have running problem with mysql_result() which doesn't even want two parameter it wants 1 resource. again a mess i think i should quite this new crap,
but thanks for your reply
+1 Logan R Logan · January 26, 2015
I think there is a better, easy  OOP way to get your results, and you wont see any error message again:

$db = new mysqli($host, $user, $passw, $database);
$query = $db->query("SELECT * FROM yourtable");
$result = $query->fetch_object();

etc. etc. etc.

Bucky made a great tutorial for this:

https://www.thenewboston.com/videos.php?cat=87
+1 Rehman . · January 26, 2015
@Martijin yes i have updating a code previous simple mysql functions doesn't work properly now and they may get excluded from version 5 of php
  • 1

PHP

107,187 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators