e107help.org Q&A
0 like 0 dislike

Hi,

for some reason unknown to me... it doesnt work

print_r($sql); shows that it has all the sql info.. but no result

 $sql = e107::getDB();

if($result = mysqli_query($sql, "SELECT * FROM #games_reviews WHERE ID =".$reviewID)) //doesnt work

{

bla

}

$sql->gen("SELECT * FROM #games_reviews WHERE ID =".$reviewID); //doesnt work

Thanks!

e107 version 2.2.1
closed
in Plugins by (27 points) 1 4 8
closed by
I answer with what i know and can see : If the posted code above is identical than : parse error : syntax error, unexpected token "}" in file on line 10 (the one before $sql)

Some info at what also may help https://www.e107.org/developer-manual/classes-and-methods/database
nothing seems to help

also

if($sql->gen("SELECT * FROM #games_reviews WHERE ID =".$reviewID))

//print_a($sql);

{

 

         if(mysqli_num_rows($sql) > 0)

{

 

            while($row = $sql->fetch())

{

         ?>

         <?php echo $row["Title"];  //removed most of the code because of character limitations in this post

     

    }

}

}

?>

mysqli_num_rows breaks to code for some reason

$sql->gen works in here... $result = $sql->gen doesnt work. Am I missing something?

the code by itself works.. trying to integrate it into the e107 environment everything kindof.. brakes

I can not help you further as i am not familiar with retrieving data, so you could a) wait untill someone else answers or be bold and b) ask on gitter chat  e107inc/e107 - Gitter (link to this post?) .
 

1 Answer

0 like 0 dislike
Best answer
As mentioned by Tgtje, take a look at the developer manual here: https://www.e107.org/developer-manual/classes-and-methods/database

In your case, you can use the following code: https://gist.github.com/Moc/4f4842ff0ad96bd6bac91cf71a39f853
(EDIT: see link)
by (2.8k points) 7 10 10
edited by
thanks for answering! are num_rows and while row irrelevant using this approach?
Yes. Actually, within the if loop I posted above above, you'd probably need to use something like foreach() to loop through the results array. See this code: https://gist.github.com/Moc/4f4842ff0ad96bd6bac91cf71a39f853
Welcome to e107 Q&A, where you can ask questions and receive answers from other members of the e107 community.
962 questions
1,362 answers
2,448 comments
2,404 users