SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would you pull the title out of a table in PHP, i tried

    <?php echo('$title'); ?>

    which down below i have said what title is, how ever it display the file name instead.??

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2000
    Location
    Warwickshire, England
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is probably because $title is undefined. You must put a value in this variable before you try to print it's contents.

    Just use a simple select statement and mysql fetch.

    Remember, later in the script, if you already have a mysql connection, there is no need to establish another one.

  3. #3
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have title defined later in the script...

    Question: If you have opened a connection, and open another, does this slow the connection?

    by opening a connection do you mean:

    when you give ur username and password or something else?

  4. #4
    SitePoint Evangelist
    Join Date
    Jul 2000
    Location
    Warwickshire, England
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, mysql_connect or pconnect. You should never need to use the pconnect twice in a script.

    Having more than one connection wont be noticable unless your site gets busy.. but remember when you have more than one, there is always going to be more memory needed than is necessary.

    btw; if you need the $title defined before you use it..
    e.g.
    <?php

    echo ($title);

    $title = "hello world!";

    ?>

    would return nothing..
    whereas

    <?php
    $title = "hello world";
    echo ($title);
    ?>

    would return hello world.
    Hope I understood / explained that correctly

  5. #5
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got it.

    ONe more question, should u use something at the end of a script to free memory or something?

  6. #6
    SitePoint Evangelist
    Join Date
    Jul 2000
    Location
    Warwickshire, England
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use mysql_free_result, but PHP automatically does it when the script ends, so I dont bother
    mysql_free_result (int result)


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
  •