someone help me fix that it's driving me crazy [duplicate] - php

This question already has answers here:
INSERT query produces "Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given"
(2 answers)
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(1 answer)
Closed 20 days ago.
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\AppServ\www\test.php on line 22
enter image description here
HOW TO FIX IT? plss
The code
<?php
$user = $_POST['user'];
$document = $_POST['document'];
$sql = "INSERT INTO mananger(user,document)VALUES('$user','$document');";
$result = mysqli_query($conn,$sql);
$result_check = mysqli_num_rows($result);
if($result_check > 0)
{
while($row = mysqli_fetch_assoc($result))
{
echo "USERNAME: " . $row['user'] . "</br>";
echo "POST: " . $row['document'] . "</br>";
}
}
?>

Related

Why can't I execute this query? [duplicate]

This question already has an answer here:
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(1 answer)
Closed 1 year ago.
I'm running such a simple SQL connection and select but I am getting very odd errors whilst running queries.
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\Webmaster\run\forum_mc.php on line 23
Warning: mysqli_query(): Empty query in C:\xampp\htdocs\Webmaster\run\forum_mc.php on line 24
()
<?php
$sqli_host = 'localhost';
$sqli_dbname = 'forum_handling';
$sqli_username = 'root';
$sqli_password = ''; //null as defualt
$fhconnect = mysqli_connect($sqli_host, $sqli_username, $sqli_password, $sqli_dbname);
if (!$fhconnect) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
$query = "SELECT Forum Title FROM forum_categories ORDER";
$result = mysqli_query($fhconnect, $query);
$row = mysqli_fetch_array($result, MYSQLI_NUM);
$data = mysqli_query($fhconnect,$row);
printf ("%s (%s)\n", $row[0], $row[1]);
mysqli_close($fhconnect);
your query should be like as follows:
$query = "SELECT Forum,Title FROM forum_categories ORDER BY Title";
chenge order by as you want.
check your field name Forum Title You can't put a blank space between Forum and Title , and also write order by fieldname

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in E:\wamp\www\Demo 22\gallery.php on line 404? [duplicate]

This question already has an answer here:
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(1 answer)
Closed 6 years ago.
I give a image display PHP code in a page while i am not insert images in a database i had occur this error called
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in E:\wamp\www\Demo 22\gallery.php on line 404?
And this is code:
<?php
include("includes/connect.php");
$select_posts = "select * from album1 where post_id=1";
$run_posts = mysqli_query($con,$select_posts);
while($row=mysqli_fetch_array($run_posts)){
$post_title = $row['post_title'];
$post_name = $row['post_name'];
$post_image = $row['post_image'];`enter code here`
?>
<p><?php echo $post_title; ?></p>
<img class="gallery1" src="image/album1/<?php echo $post_image; ?>"width="160" height="120" >
<p><?php echo $post_name; ?></p>
<?php } ?>
This means your previous call to mysqli_query returned false instead of reference to result set. This happens when there is syntax error in the SQL. Try running the SQL manually or report the error by calling echo mysqli_error($con).

Warning: mysql_fetch_array() expects parameter 1 to be resource, object given [duplicate]

This question already has answers here:
Can I mix MySQL APIs in PHP?
(4 answers)
Closed 7 years ago.
how do i solve error message
Warning: mysql_fetch_array() expects parameter 1 to be resource,
object given
my code :
if(isset($_POST['login']))
{
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$res = $MySQLiconn->query(" SELECT * FROM users WHERE username = '$username' ");
$row = mysql_fetch_array($res);
if($row['password'] == md5($password))
{
$_SESSION['login'] = $row['user_id'];
echo $_SESSION['login'];
}
else
{
echo "<script>alert('wrong details')</script>";
}
}
Can anyone help ?
The actual problem is you are mixing mysqli methods and mysql methods together.
$res = $MySQLiconn->query(" SELECT * FROM users WHERE username = '$username' ");
is in mysqli and
$row = mysql_fetch_array($res);
is in mysql. so here you are passing $res which is an object mysqli::query returns an object and mysql_fetch_array() expects a resource that is why it shows such an error. . So either use mysql or use mysqli to resolve the problem.
You are mixing mysql and mysqli calls in your code. Use mysqli_fetch_array instead of mysql_fetch_array.

gettingerror as Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource [duplicate]

This question already has answers here:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result [duplicate]
(6 answers)
Closed 9 years ago.
<?php
{
session_start();
include "dbconnect.php";
$target1=$_SESSION['target1'];
echo $target1;
$query = "SELECT * FROM userpictures where pictures = $target1";
$result = mysql_query($query);
var_dump($result);
while($row=mysql_fetch_object($result))
echo $row;
{
$_SESSION['picid1']=$row['picid'];
//$_SESSION['picid1']=$row->picid;
echo $_SESSION['picid1'];
}
}
?>
it is returning me the output as
images/2101.jpgbool(false)
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource
it is giving the target1 but not the picid
please help.
Try this, Added ' - pictures = '$target1'
$query = "SELECT * FROM userpictures where pictures = '$target1' ";
$result = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_object($result))
{
$_SESSION['picid1']=$row->picid;
echo $_SESSION['picid1'];
}
Use,
$row->picid;
instead of
$row['picid']
Note: Use mysqli_* fucntions or PDO instead of mysql_* functions(deprecated)

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in? [duplicate]

This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 9 years ago.
here is my code , I could not find where's the problem!
<?php
include("dbc.php");
$result = mysqli_query($dbc,"SELECT * FROM employee");
while($row = mysqli_fetch_array($result))
{
echo $row['name'] . " " . $row['age']." ".$row['id'];
echo "<br>";
}
?>
mysqli_query "Returns FALSE on failure."
Please double check whether $dbc is really created and of expected type.
See: http://www.php.net/mysqli_query

Categories