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 Link to comment https://forums.phpfreaks.com/topic/210336-php-mysql-help/ 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. Link to comment https://forums.phpfreaks.com/topic/210336-php-mysql-help/#findComment-1097618 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! Link to comment https://forums.phpfreaks.com/topic/210336-php-mysql-help/#findComment-1097623 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 Link to comment https://forums.phpfreaks.com/topic/210336-php-mysql-help/#findComment-1097634 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.