Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 05-20-2022, 09:43 PM   #1
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
Old 05-20-2022, 09:46 PM   #2
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
Oh, i should add, when using only 1 query, the code works perfectly
__________________
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
Old 05-21-2022, 02:37 AM   #3
redwhiteandblue
Bollocks
 
redwhiteandblue's Avatar
 
Industry Role:
Join Date: Jun 2007
Location: Bollocks
Posts: 2,792
Is this all of the code? What are lines 62, 63 and 74?
redwhiteandblue is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-21-2022, 07:12 AM   #4
CurrentlySober
Too lazy to wipe my ass
 
CurrentlySober's Avatar
 
Industry Role:
Join Date: Aug 2002
Location: A Public Bathroom
Posts: 38,522
Quote:
Originally Posted by redwhiteandblue View Post
Is this all of the code? What are lines 62, 63 and 74?
Easy, they are the lines that come between lines 61 and 64, plus the line between 73 & 75 respectively... come on... keep up
__________________


👁️ 👍️ 💩
CurrentlySober is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-21-2022, 07:48 AM   #5
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,058
Not sure how any of that code is running.

You mention 2 queries but you only have one query in there. It has 2 conditions, but it is one query.

Quote:
$sql = "SELECT * FROM Recipe WHERE Title RLIKE 'fryer' AND RLIKE 'Air' ORDER BY Title ASC;";
Needs to be:
$sql = "SELECT * FROM Recipe WHERE Title RLIKE 'fryer' AND Title RLIKE 'Air' ORDER BY Title ASC";

You have to have the field being interrogated listed in each condition.

I am not sure if that is your only problem.

Quote:
PHP Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /blah/blah/domain.com/members/test/index.php on line 62
This would indicate that you did not have a good connection. The first parameter on mysqli_query is the connection. The error message says that is null which would mean a bad connection.

The second set of code that was posted should not even run because of the errors in there. It shows 2 different wile loops but only one is closed. That doesn't matter though because the 2 different while loops make no sense. You are looping through the resuult and inside the loop you are looping through the results again. I don't think you want ot do that.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-21-2022, 10:00 AM   #6
redwhiteandblue
Bollocks
 
redwhiteandblue's Avatar
 
Industry Role:
Join Date: Jun 2007
Location: Bollocks
Posts: 2,792
Try replacing the line

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

Quote:
$con=mysqli_connect("localhost","db","pass","user" ) or die("Error connecting to database");
and if you see the message "Error connecting to database"...
redwhiteandblue is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-21-2022, 10:03 AM   #7
redwhiteandblue
Bollocks
 
redwhiteandblue's Avatar
 
Industry Role:
Join Date: Jun 2007
Location: Bollocks
Posts: 2,792
BTW the parameters need to be in the order ("localhost", user, password, database_name)

But you said it works fine if you only have one query so it may be you had the correct code for connecting to the database. Try using the query Sarettah described, the ones you wrote don't make sense.
redwhiteandblue is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-21-2022, 11:23 AM   #8
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
i fixed it early this morning.

This issue was a missing Category as Sarettah mentioned above.

Quote:
SELECT * FROM Recipe WHERE Category RLIKE 'air' AND Category RLIKE 'fryer' ORDER BY Title ASC LIMIT 60
I appreciate all the responses

Must stop coding while drinking Jameson, that will solve most of the issues
__________________
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
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
php, warning, america/chicago], parameter, line, null, [20-may-2022, expects, code, mysqli_result, kicking, mysqli_fetch_array, error, sets, crap, original, errors, query, mysqli_query, sql, types, multiple, programmer, mysqli



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.