Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Location
    Lebanon
    Posts
    223
    Thanks
    6
    Thanked 0 Times in 0 Posts

    php error please help

    This is the code to fetch data from the database, but it's giving me an error.

    PHP Code:
    <?php
      $mysql 
    mysql_connect("localhost""revoluti_darkquo""bymyside""revoluti_darkquote");
      if (
    mysqli_connect_errno()) {
          
    printf("Connect failed: %s\n"mysqli_connect_error());
          exit();
      } else  {
          
    $sql "SELECT * FROM data ORDER BY id desc LIMIT 5";
         
    // $result = "SELECT * FROM data";
        //  $num_rows = mysql_num_rows($result);
          
    $res mysqli_query($mysqli$sql);
          if (
    $res) {
              while (
    $newArray mysqli_fetch_array($resMYSQLI_ASSOC)) {
                  
    $id  $newArray['id'];
                  
    $quote $newArray['quote'];
                  
    $email $newArray['email'];
         
    $name $newArray['name']; ?>
         <fieldset class="fieldset">
         <legend>Quote #<?php echo "".$id."" ?></legend>
         <table border="0" cellpadding="0" cellspacing="3" width="100%">
                    <tbody><tr>
                        <td>
                        <div align="center"><?php echo"".$quote."" ?></div><br />
                        <div align="right"<b><i>By <a href="mailto:<?php echo "".$email."" ?>"><?php echo "".$name."" ?></a></i></b><br /></div>
                        </td>
                    </tr>
                    </tbody></table>
                </fieldset>
              <br />
              <?php
                
    //  echo"".$quote." - <i>By ".$name."</i><br />Thought #".$id."<br/><br />";
                 
    }
          } else {
              
    printf("Could not retrieve records: %s\n"mysqli_error($mysqli));
          }
          
    mysqli_free_result($res);
          
    mysqli_close($mysqli);
      }
    ?>
    And this is the error I'm getting!

    Fatal error: Call to undefined function: mysqli_connect() in /home/revoluti/public_html/darkquote/index.php on line 81
    can you please help?

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't know if it was your intention or not, but do you see you are using mysql_connect and assigning it to $mysql?

    if seems like it should be

    PHP Code:
    <?php 
      $mysqli 
    mysqli_connect("localhost""...""...""..."); 
      if (
    mysqli_connect_errno()) { 
    .
    .
    .
    http://livedocs.phpdoc.info/index.ph...mysqli-connect

    I don't understand why it would cause that error though, but it's something to look at.

    david_kw


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •