Jump to content

MySqli ? Problems


Ezkiel

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.