SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    HI silver trophy Silverado4x4's Avatar
    Join Date
    Jan 2001
    Location
    USA
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wrong datatype in call to extract()

    How do I fix this?

    http://www.jokeuniversity.com/links/database.php

    PHP Code:
    <?
    $dbcnx 
    mysql_connect('localhost','db','pass');
    mysql_select_db('db');

    $sql mysql_query("SELECT url, sitename, description, email FROM links ORDER BY sitename ASC") or die(mysql_error());
    $result mysql_fetch_array($sql);
    extract($result);

    function 
    listlinks() {
        
    //make table
        
    echo "<table>\">";
                echo 
    "<tr>";
                echo 
    "<td><a href=\"$url\" alt=\"$description\"><font color=\"#000000\" face=\"Arial\" size=\"2\">$sitename</a></td>";
                echo 
    "</tr>";
        echo 
    "</table></center>";
    }

    ?>

         <?



         listlinks
    ();

         
    ?>

  2. #2
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this for mysql_select_db
    PHP Code:
    mysql_select_db("dbname"$dbcnx); 
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  3. #3
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mm, maybe mysql is returning an empty set (ie, not data). Have you checked this?

    You can check if $result is an array with,
    PHP Code:
     if (is_array($result))
        
    extract($result);     
     else 
         echo 
    'Empty set, no data found'

  4. #4
    HI silver trophy Silverado4x4's Avatar
    Join Date
    Jan 2001
    Location
    USA
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, that is the problem Paul.

    Come to find out, another section of my script wasn't inserting anything at all.

    Here is the code...
    PHP Code:
    <?
    if ($submit) {
    $connect mysql_connect ("localhost""jokeun""pass")
            or die (
    "Could not connect");
        print (
    "Connected successfully");
        
    mysql_db_query("jokeun","INSERT INTO links (url, sitename, description, email)
                                      values ('
    $url', '$sitename', '$description', '$email')" )
        or die(
    "Error! " mysql_error());
    }
    $result=mysql_db_query("jokeun""SELECT * FROM links ORDER BY sitename ASC") or die ("Couldn't open \"jokeun\" database. Please inform [email]webmaster@jokeuniversity.com[/email]: ".mysql_error());
    $row mysql_fetch_array($result); 
    $url $row["url"];
    $sitename $row["sitename"];
    $description $row["description"];
    $email $row["email"];
    echo 
    "$url<br>$sitename<br>$description<br>$email";
    ?>
    Yet, I get this result:
    Couldn't open "jokeun" database. Please inform webmaster@jokeuniversity.com: Access denied for user: '@localhost' to database 'jokeun'


  5. #5
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when $submit is false, the bracket part is skipped and mysql_conect() is not called.
    Try this,
    PHP Code:
     $connect mysql_connect('localhost''jokeun''pass')
            or die (
    'Could not connect');

     if (
    $submit) { .... 

  6. #6
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hmm nice site

    Nice site...!!!!!!!!!

    A bit to much on the popup screens to join the school but for the rest is a nice site
    the neigbours (free) WIFI makes it just a little more fun

  7. #7
    HI silver trophy Silverado4x4's Avatar
    Join Date
    Jan 2001
    Location
    USA
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well...thanks

    It'll be even nicer when I get my new site design tomorrow (see the trading post)!


Bookmarks

Posting Permissions

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