Ezkiel Posted November 27, 2014 Share Posted November 27, 2014 Hi everyone, I can’t understand what happens… When I try my site in WAMP, I have the follow errors:Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO (…) Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in (…) The same happened with the connect to mysql, but I solved using mysqli extension. But in this case is totally diferente. When I use the mysqli_query or mysqli_num_rows that are the alternatives presented I receive again other error, in PHP Manual says: "function.mysqli-query doesn't exist. Closest matches:" Someone know solve this problem??? When I use MySQL <?php session_start(); if (isset($_SESSION["manager"])){ header("location:index.php"); exit(); } ?> <?php if(isset($_POST["username"])&&isset($_POST["password"])){ $manager=preg_replace('#[^A-Za-z0-9]#i','',$_POST["username"]); $password=preg_replace('#[^A-Za-z0-9]#i','',$_POST["password"]); $cnn= include "../lojascript/connect_mysql.php"; $sql=mysql_query($cnn, "SELECT id FROM admin WHERE username='$manager' AND password='$password' LIMIT 1"); $existCount=mysql_num_rows($sql); if ($existCount==1){ while ($row = mysqli_fetch_array($sql)){ $id=$row["id"]; } $_SESSION["id"]=$id; $_SESSION["manager"]=$manager; $_SESSION["password"]=$password; header("location:index.php"); exit(); }else { echo 'Informação incorrecta <a href="index.php"> Click here</a>'; exit(); } } ?> When I use MySQLi <?php session_start(); if (isset($_SESSION["manager"])){ header("location:index.php"); exit(); } ?> <?php if(isset($_POST["username"])&&isset($_POST["password"])){ $manager=preg_replace('#[^A-Za-z0-9]#i','',$_POST["username"]); $password=preg_replace('#[^A-Za-z0-9]#i','',$_POST["password"]); $cnn = include "../lojascript/connect_mysql.php"; $query= "SELECT id FROM admin WHERE username='$manager' AND password='$password' LIMIT 1"; $result= mysqli_query($cnn,$query) or die(mysqli_error()); $num_row = mysqli_num_rows($result); if ($num_row==1) { while ($row = mysqli_fetch_array($result)){ $_SESSION["id"]=$row["id"]; } $_SESSION["id"]=$id; $_SESSION["manager"]=$manager; $_SESSION["password"]=$password; header("location:index.php"); exit(); }else { echo 'Informação incorrecta <a href="index.php"> Click here</a>'; exit(); } } ?> Link to comment https://forums.phpfreaks.com/topic/292745-mysqli-problems/ Share on other sites More sharing options...
Ch0cu3r Posted November 27, 2014 Share Posted November 27, 2014 Make sure you have enable the MySQLi extension in PHP's configuration. I think with WAMP you can left click the tray icon > PHP > Extensions > php_mysqli to enable mysqli Link to comment https://forums.phpfreaks.com/topic/292745-mysqli-problems/#findComment-1497824 Share on other sites More sharing options...
Barand Posted November 27, 2014 Share Posted November 27, 2014 It is there in the php manual http://php.net/manual/en/mysqli.query.php Search for "mysqli" then click on the links for the individual methods. As to why a search for "mysqli_query" doesn't work is an issue you would have to take up with php.net Link to comment https://forums.phpfreaks.com/topic/292745-mysqli-problems/#findComment-1497825 Share on other sites More sharing options...
Ezkiel Posted November 27, 2014 Author Share Posted November 27, 2014 Make sure you have enable the MySQLi extension in PHP's configuration. I think with WAMP you can left click the tray icon > PHP > Extensions > php_mysqli to enable mysqli Yes, I have enabled Link to comment https://forums.phpfreaks.com/topic/292745-mysqli-problems/#findComment-1497830 Share on other sites More sharing options...
Ezkiel Posted November 27, 2014 Author Share Posted November 27, 2014 It is there in the php manual http://php.net/manual/en/mysqli.query.php Search for "mysqli" then click on the links for the individual methods. As to why a search for "mysqli_query" doesn't work is an issue you would have to take up with php.net I re-write the code in mysqli inspired by I saw in php.net... but appear a new type of error : "function.mysqli-query doesn't exist. Closest matches:" Link to comment https://forums.phpfreaks.com/topic/292745-mysqli-problems/#findComment-1497831 Share on other sites More sharing options...
ginerjm Posted November 27, 2014 Share Posted November 27, 2014 Underscore, not dash. mysqli_query Also - as I said in your other post - you can't mix MySQL and MySQLI functions. Change your connection logic Link to comment https://forums.phpfreaks.com/topic/292745-mysqli-problems/#findComment-1497834 Share on other sites More sharing options...
Ezkiel Posted November 27, 2014 Author Share Posted November 27, 2014 Underscore, not dash. mysqli_query Also - as I said in your other post - you can't mix MySQL and MySQLI functions. Change your connection logic appear this "function.mysqli-query doesn't exist. Closest matches:" but the code is "mysqli_query" Link to comment https://forums.phpfreaks.com/topic/292745-mysqli-problems/#findComment-1497836 Share on other sites More sharing options...
Barand Posted November 27, 2014 Share Posted November 27, 2014 Underscore, not dash. mysqli_query Makes no difference. If I search php.net manual for "mysqli_query" I get the page shown below. Same goes for a search for "mysqli::query" Link to comment https://forums.phpfreaks.com/topic/292745-mysqli-problems/#findComment-1497838 Share on other sites More sharing options...
ginerjm Posted November 27, 2014 Share Posted November 27, 2014 Completely off the wall guess here but if php is telling you a function does not exist, then I would say you do not have it enabled in your installation. You said it is enabled but what confirmation of it do you have? Try doing a function_exists call perhaps. Link to comment https://forums.phpfreaks.com/topic/292745-mysqli-problems/#findComment-1497873 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.