0

I got a little problem here. I just exported my EasyPHPV13 databases into EasyPHPV14 on another computer.

When I try to run my php code I get this error :

mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in 

The odd thing, it's that on the old computer it works, and on the new computer with EasyPHP V14, with imported databases and localweb data I get the error. I marked the code with /*error for the lines I get error at

My php code:

<?php
$con=mysqli_connect("localhost","root","root","site_db"); /*error*/

if (mysqli_connect_errno())
{
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM produse where categorie='1'"); /*error*/

echo "

<table border='1'>
<tr>
<th ALIGN=center>Denumire</th>
<th>Specificatii</th>
<th>Pret</th>

</tr>";

while($row = mysqli_fetch_array($result)) /*error*/
  {
   echo "<tr>";
   echo "<td ALIGN=center>" . $row['denumire'] . "</td>";
   echo "<td ALIGN=center>" . $row['specificatii'] . "</td>";
   echo "<td ALIGN=center>" . $row['pret'] . "</td>";
   echo "</tr>";
  }
echo "</table>";

mysqli_close($con); /*error*/
?>
user3225647
  • 1
  • 1
  • 1
  • Since I see it's failing right at the connect (based on your error comment), is the credential the same on the new database? Still root / root? – Charlie74 Jan 22 '14 at 23:35
  • Additionally, I noticed you exported your databases... did you move everything between servers? As in... is your web server and DB server on the same box? – Charlie74 Jan 22 '14 at 23:37

1 Answers1

-2

Switch around the $con and the query.

http://www.php.net/manual/en/function.mysql-query.php

David Corbin
  • 524
  • 2
  • 11
  • 25
  • 1
    Sidenote: I did NOT downvote this. The most likely reason why you got a downvote is because the OP is using `mysqli_*` functions and not `mysql_*` --- Consider deleting your answer to regain your rep points. ;-) – Funk Forty Niner Jan 22 '14 at 23:47