Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-14-2012, 03:23 PM   PM User | #1
gjcluttrell
New Coder

 
Join Date: Mar 2011
Posts: 34
Thanks: 2
Thanked 0 Times in 0 Posts
gjcluttrell is an unknown quantity at this point
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>
gjcluttrell is offline   Reply With Quote
Old 12-14-2012, 04:58 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,752
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
<?= 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.
Fou-Lu is offline   Reply With Quote
Old 12-14-2012, 06:09 PM   PM User | #3
EarthToHeaven
New to the CF scene

 
Join Date: Dec 2012
Location: Toronto, ON
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
EarthToHeaven is an unknown quantity at this point
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
EarthToHeaven is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:56 AM.


Advertisement
Log in to turn off these ads.