dmcdaniel Posted August 10, 2010 Share Posted August 10, 2010 I am having a bit of trouble here. I will explain what I am trying to do: I am trying to pull the Field Name: Account into my input form. My input form code looks like this: Account Number: <input type="text" value="<?php echo($Account); ?>" name="Account"/> My PHP code above this looks like this: <?php @ $db = mysql_connect("localhost", "usr", "pass"); mysql_select_db("EmployeeInfo"); $sQuery = sprintf("SELECT * FROM EmployeeInfo WHERE EmployeeInfo.Name LIKE '%s'", mysql_real_escape_string($_POST['NameSelect'])); $result = mysql_query($sQuery); $actualResult = mysql_fetch_array($result); echo $actualResult['aSQLRow']; ?> My select query works properly. Can anyone find my error because I sure can't Thanks in advance, dmcdaniel Quote Link to comment Share on other sites More sharing options...
TOA Posted August 10, 2010 Share Posted August 10, 2010 I bet the error is a resource ID error. You're trying to access info that is an array. Cycle through it with a while or for statement like this $sql = "SELECT * FROM ...."; $query = ($sql); while ($row = mysql_fetch_array($query)) { echo $row[your_db_field_name_here]; } Since you're only matching one it will only print one. And another tip, you shouldn't use *...explicitly define what fields to pull, its alot safer Hope that helps. Quote Link to comment Share on other sites More sharing options...
dmcdaniel Posted August 10, 2010 Author Share Posted August 10, 2010 You sir, Are absolutely amazing! Thank you very much for your help! Thank you thank you thank you thank you! Quote Link to comment Share on other sites More sharing options...
TOA Posted August 10, 2010 Share Posted August 10, 2010 np. Glad it was simple Please mark it solved if your issue is resolved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.