Jump to content

php mysql help


dmcdaniel

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.