mbrown Posted February 4, 2009 Share Posted February 4, 2009 $softwareQuery = "SELECT * FROM `software` WHERE `SKU` = '$SKU'"; $softwareResult = mysql_fetch_assoc(mysql_query($softwareQuery)); [/coe] When I echo out $softwareResult[OtherInfo] it display but when i put it in something like this: [code] <textarea name='otherinfo' id='otherinfo' cols='45' rows='5' value='$softwareResult[OtherInfo]'></textarea> it does not display it in the form. any ideas why? like I said when i do the following it works echo $softwareResult[OtherInfo] Link to comment https://forums.phpfreaks.com/topic/143770-solved-echo-works-but-valuevariable/ Share on other sites More sharing options...
timmah1 Posted February 4, 2009 Share Posted February 4, 2009 <textarea name='otherinfo' id='otherinfo' cols='45' rows='5'><?php echo $softwareResult[OtherInfo]; ?></textarea> Link to comment https://forums.phpfreaks.com/topic/143770-solved-echo-works-but-valuevariable/#findComment-754298 Share on other sites More sharing options...
mbrown Posted February 4, 2009 Author Share Posted February 4, 2009 thanks. I did it the way I posted before for something else and I thought it worked. This is a php form. So the <?php, echo and ?> are not needed. Thanks again Link to comment https://forums.phpfreaks.com/topic/143770-solved-echo-works-but-valuevariable/#findComment-754306 Share on other sites More sharing options...
aschk Posted February 4, 2009 Share Posted February 4, 2009 $softwareResult[OtherInfo] will give you PHP warning error in your logs for "Invalid array index" or something simliar. You MUST use quotes for associative array indices. i.e. $softwareResult['OtherInfo'] You also haven't shown the full code for the following line: <textarea name='otherinfo' id='otherinfo' cols='45' rows='5' value='$softwareResult[OtherInfo]'></textarea> We don't know how the above is being output? By echo? By print? timmah1's solution is the correct one. So either post the full code or implement his solution. Link to comment https://forums.phpfreaks.com/topic/143770-solved-echo-works-but-valuevariable/#findComment-754310 Share on other sites More sharing options...
mbrown Posted February 4, 2009 Author Share Posted February 4, 2009 <?php session_start(); if ($_SESSION['loggedIn'] == TRUE) { $username = $_SESSION['username']; echo "User Logged In: $username"; echo "<br /><a href='../administration/index1.php'>Main Admin</a>"; echo "<br />"; echo "<div align='center'><img src='../images/wasdBanner.gif' alt='header' /></div>"; //including the database connection script include("../includes/connect.php"); echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <title>Modify Software</title> </head> <body>"; $userquery = "SELECT * FROM users WHERE username = '$username'"; $query = mysql_fetch_assoc(mysql_query($userquery)); if($query[usergroup] != "Super Administrator") { echo "<br />You need to have administration privleges"; //meta refresh }//end of if($query[usergroup] == "Super Administrator") else { $SKU = $_POST['sku#']; $softwareQuery = "SELECT * FROM `software` WHERE `SKU` = '$SKU'"; $softwareResultNumRows = mysql_query($softwareQuery) or die (mysql_error()); $softwareResult = mysql_fetch_assoc(mysql_query($softwareQuery)); $softwareNumRows = mysql_num_rows($softwareResultNumRows); //Debuggin: echo "$SKU"; if ($softwareNumRows == 0) { if ($SKU == "") { echo "Please enter a SKU Number"; }//end of if ($SKU == "") }//end of if ($numrows == 0) else { echo "<style type='text/css'> <!-- .style1 { color: #0000FF; font-weight: bold; } .style2 {color: #0000FF} .style3 {font-size: 12px} --> </style> "; echo "<form id='software' name='software' method='post' action='softwareModifyCheck.php'> <div align='center' > <p class='style1'>Software<br /> <hr width='50%' /> <p align='left'> <label>ID: <input type='text' name='ID' id='ID' value='$softwareResult[iD]' readonly='readonly' length='4'/> </label> </p> <p align='left'> <label>Software Title: <input type='text' name='softwareTitle' id='softwareTitle' value='$softwareResult[softwareTitle]'/> </label> </p> <p align='left'> <label>SKU #: <input type='text' name='sku#' id='sku#' value='$softwareResult[sKU]'/> </label> </p> <p align='left'>Building: <select name='building' id='building'> <option value='$softwareResult[Location]'>$softwareResult[Location]</option> <option value='Summitview'>Summitview</option> <option value='WAMS'>WAMS</option> <option value='WASHS'>WASHS</option> <option value='Hooverville'>Hooverville</option> <option value='Mowery'>Mowery</option> <option value='Fairview Ave'>Fairview Ave</option> <option value='Clayton Ave'>Clayton Ave</option> </select> </p> <p align='left'>Room: <label> <input name='room' type='text' id='room' size='3' maxlength='3' value='$softwareResult[Room]'> </label> </p> <p align='left'>Grant: <label> <input type='text' name='grant' id='grant' value='$softwareResult[Grant]'/> </label> </p> <p align='left'>Other Information: <label><br /> <textarea name='otherinfo' id='otherinfo' cols='45' rows='5'>$softwareResult[OtherInfo]</textarea> </label> </p> <p align='left'> </p> <div align='center'> <input type='submit' name='submit2' id='submit2' value='Submit' /> <input type='reset' name='button' id='button2' value='Reset' /> </div> </div> </form>"; }//end of else }//end of else }//end of if ($_SESSION['loggedIn'] == TRUE) else { header('Location: ../login.php'); } echo" </body> </html>"; ?> I implemented timmah1's solution <textarea name='otherinfo' id='otherinfo' cols='45' rows='5'>$softwareResult[OtherInfo]</textarea> Link to comment https://forums.phpfreaks.com/topic/143770-solved-echo-works-but-valuevariable/#findComment-754335 Share on other sites More sharing options...
gevans Posted February 4, 2009 Share Posted February 4, 2009 And is it working? Link to comment https://forums.phpfreaks.com/topic/143770-solved-echo-works-but-valuevariable/#findComment-754342 Share on other sites More sharing options...
mbrown Posted February 4, 2009 Author Share Posted February 4, 2009 Now it is working. That is why I said thank you. I just included the code because aschk was saying about he didnt know how it was being outputted. thanks again! Link to comment https://forums.phpfreaks.com/topic/143770-solved-echo-works-but-valuevariable/#findComment-754378 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.