why do i get this fatal error? function name must be a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luke noob
    New Member
    • Aug 2009
    • 69

    why do i get this fatal error? function name must be a string

    page 1

    [code=php]



    function getNewestTutori als() {
    require 'database.php';
    $q = "SELECT id, imagePath, titleOfTutorial , descriptionOfTu torial, tutorialBy FROM dogs ORDER BY id desc LIMIT 6";
    $result = $mysqli->query($q) or die($mysqli_err or($mysqli));

    if($result) {
    while($row = $result->fetch_object() ) {

    $id = $row->id;
    $imagePath = $row->imagePath;
    $titleOfTutoria l = $row->titleOfTutoria l;
    $descriptionOfT utorial = $row->descriptionOfT utorial;
    $tutorialBy = $row->tutorialBy;

    print '<div id="pictureOfTo picAndTitle"> <!-- start pictureOfTopicA ndTitle -->

    <div id="pictureOfTo pic">
    <a href="view_tuto rial.php?id=' . $id . '">
    <img src="' . $imagePath . '" width="200" height="200">
    </a>
    </div>



    <div id="titleAndCon tent">
    <h2>' . $titleOfTutoria l . '</h2>

    <p>' . $descriptionOfT utorial . '</p>

    <div id="nameComment s">

    <p>Tutorial by ' . $tutorialBy . ', Comments 56</p>

    </div>
    </div>



    </div> <!-- end pictureOfTopicA ndTitle Div -->';


    }

    }
    }
    [/code]
    page 2
    [code=php]
    <?php getNewestTutori als(); ?>
    [/code]
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    Nothing jumps out at me. What is the line and exact error that comes up? Check out this if you haven't already.

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      Code:
      $result = $mysqli->query($q) or die($mysqli_error($mysqli));
      You have changed a function name to a variable by placing $ in front

      Comment

      • luke noob
        New Member
        • Aug 2009
        • 69

        #4
        Fatal error: Function name must be a string in /home/luke7859/public_html/blarblar/functions.php on line 234, line 234 is the line that you have above, i have checked and can't see a problem with this, some of my fields in my database are empty at the moment, could that be the problem, i should try

        Comment

        • code green
          Recognized Expert Top Contributor
          • Mar 2007
          • 1726

          #5
          Not sure wether mysqli_error is a function or class method
          but in principle you can have $mysqli->error() or mysqli_error() but not $mysqli_error()

          Comment

          • luke noob
            New Member
            • Aug 2009
            • 69

            #6
            sorry i got rid of the $ symbol and it works now thanks for your replys, i now have another error saying..., Unknown column 'imagePath' in 'field list' but it is in my feild list, if i cant sort this error out my self then i will post a new question.
            Last edited by luke noob; Aug 11 '10, 01:57 PM. Reason: old post wasn't worth looking at, sorry

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              Not sure wether mysqli_error is a function or class method
              MySQLi supports procedural and OO style for most of its functions.
              Code:
              $mysqli->error();
              // or
              mysqli_error($mysqli);

              Comment

              Working...