#1
  1. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    25
    Rep Power
    0

    extract variable from database, then output that variable.


    I have this strange problem (and probably also a strange question).

    Let's say you set a variable $blah. The variable has 'test' as content. When I write the variable ($blah) to a database (and not the content of the variable 'test') and I want to output the variable again, I get $blah as output. And not 'test'.

    PHP Code:
    $blah'test';

    //Extract $blah from database
    //$blah is in field 'text'

    $output $input['text'];
    print 
    "$output"//result = $blah, and should be 'test' 
    Is there a work-around ? Or am I doing something wrong?
  2. #2
  3. Moderator Emeritus
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2002
    Location
    Austin, TX
    Posts
    7,196
    Rep Power
    2268
    What code are you using to insert the value of $blah into your DB?

    What code are you using to extract that value from your DB?

    There is an issue in the method you're using for one of these; you'll need to post your code for us to determine where you're making the mistake.
    DrGroove, Devshed Moderator | New to Devshed? Read the User Guide | Connect with me on LinkedIn
    The Most Important Article You Can Read as a Developer
  4. #3
  5. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    25
    Rep Power
    0
    insert is manually done through phpmyadmin (the insert-interface is not quite finished)

    output:
    PHP Code:

    $links_result 
    mysql_query("SELECT * FROM $links WHERE hidden = 0 ")or die("SELECT Error: " mysql_error());

    while (
    $link_array mysql_fetch_array($links_result)) {
        
    $location $link_array['tekst']
        print 
    "$location";

  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    St. Paul, MN
    Posts
    5
    Rep Power
    0
    Looks to me like you're going to want to insert the value of the variable into the table instead of the name.

    Sorry if that's stupidly obvious.
  8. #5
  9. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    25
    Rep Power
    0
    That's the whole point.
    I don't need the value stored in a database, I really need to store the variable itself. And when outputted (from the database), THEN I need the value.
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    St. Paul, MN
    Posts
    5
    Rep Power
    0
    Oh, I see. Well, MySQL can't hold variables; it's not a programming language, just a database. You could try having a 'name' column and a 'value' column in the database, but I don't know a way that you could rename a variable after another variable.

    That doesn't mean there isn't a way, I just don't know of one.

IMN logo majestic logo threadwatch logo seochat tools logo