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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.