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 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    34
    Thanks
    2
    Thanked 0 Times in 0 Posts

    PHP Code Help Needed

    I'm trying to pull data from the mysql database & display the result in a form. In the mysql databse the databse name is flow. The table the names are listed in is named clerk_names & the only fields in thei table is names & clerk_id. When I put the below code in a form & display it in a browser, in the Assign To: field the value shows <?=$randomName?> instead of the result from the query...have I mistyped something? Thanks again for any help or assistance provided.


    PHP Code:
    <?php 
    $mysqli 
    = new mysqli('localhost''myusername''mypassword''flow'); 
    $sql "SELECT names FROM clerk_names ORDER BY RAND() LIMIT 1"
    $res $mysqli->query($sql); 
    $row $res->fetch_row(); 
    $randomName $row[0]; 
    $res->free(); 
    ?> 
     
    <td><b>Assign To:</b> <br><input type="text" name="clerk_names" size="15" maxlength="30" value="<?=$randomName?>" /><br /> </td>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    <?= prior to 5.4 is reliant on the use of short_open_tag directive. If it literally shows the text <?=$randomName?>, then you do not have 5.4 and the ini directive is disabled. Replace it as its full PHP block: <?php echo $randomName;?> or use an evaluation of the string with an echo or printf instead of breaking directly to the HTML.

  • #3
    New to the CF scene
    Join Date
    Dec 2012
    Location
    Toronto, ON
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by gjcluttrell View Post
    I'm trying to pull data from the mysql database & display the result in a form. In the mysql databse the databse name is flow. The table the names are listed in is named clerk_names & the only fields in thei table is names & clerk_id. When I put the below code in a form & display it in a browser, in the Assign To: field the value shows <?=$randomName?> instead of the result from the query...have I mistyped something? Thanks again for any help or assistance provided.


    PHP Code:
    <?php 
    $mysqli 
    = new mysqli('localhost''myusername''mypassword''flow'); 
    $sql "SELECT names FROM clerk_names ORDER BY RAND() LIMIT 1"
    $res $mysqli->query($sql); 
    $row $res->fetch_row(); 
    $randomName $row[0]; 
    $res->free(); 
    ?> 
     
    <td><b>Assign To:</b> <br><input type="text" name="clerk_names" size="15" maxlength="30" value="<?=$randomName?>" /><br /> </td>
    You might want to try that directly in your PHPMYADMIN . if this statement works.

    Use die('error here') on statements. This will pin point error accurately.

    Let me know what happens.

    Cheers,
    Nehal


  •  

    Posting Permissions

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