View Single Post
Old 05-20-2022, 09:43 PM  
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
SQL (multiple) query error

Any of the programmer types on here able to tell me why this is kicking out the following error?

Quote:
[20-May-2022 23:33:21 America/Chicago] PHP Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /blah/blah/domain.com/members/test/index.php on line 62
[20-May-2022 23:33:21 America/Chicago] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /blah/blah/domain.com/members/test/index.php on line 63
[20-May-2022 23:33:21 America/Chicago] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /blah/blah/domain.com/members/test/index.php on line 74
I've tried 2 different sets of php code and its still kicking errors out on me

Here was the original code:

Quote:
<?php

$con=mysqli_connect("localhost","db","pass","user" );

$result = mysqli_query($con,"SELECT * FROM Title WHERE Category REGEXP 'air' AND REGEXP 'fryer' ORDER BY Title ASC;");

echo "<table border='0'>

<tr>

</tr>";

while($row = mysqli_fetch_array($result))

{

$link = "../../recipes/recipe.php?id=".$row['RecipeID'];

echo "<tr>";

echo "<a href = ". $link . ">" . $row['Title'] . "</a><br>";

echo "</tr>";

}

echo "</table>";

mysqli_close($con);

?>
This is what I'm currently using (ditched regexp):

Quote:
<?php

$con=mysqli_connect("localhost","db","pass","user" );

$sql = "SELECT * FROM Recipe WHERE Title RLIKE 'fryer' AND RLIKE 'Air' ORDER BY Title ASC;";
$result = mysqli_query($con,$sql);
while($r = mysqli_fetch_array($result))
if (!$check1_res) {
printf("Error: %s\n", mysqli_error($con));
exit();
}
echo "<table border='0'>

<tr>

</tr>";

while($row = mysqli_fetch_array($result))

{

$link = "../../recipes/recipe.php?id=".$row['RecipeID'];

echo "<tr>";

echo "<a href = ". $link . ">" . $row['Title'] . "</a><br>";

echo "</tr>";

}

echo "</table>";

mysqli_close($con);

?>
Basically, I'm trying to get a set of recipes displayed where they contain 2 categories, in this instance 'air' and 'fryer' which should display any Air Fryer recipes, but it doesnt, any help would be greatly appreciated, this is my first time screwing with multipe queries to display results
__________________
SOMETHING EXTREME IS COMING SOON!
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote