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
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
Share on other sites

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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.