You should not just give him the code but rather tell him why.

1. trim() is a php function. MySQL does not know what to do with it. You need to place it 'outside' of the sql. You can also do something like this:

$userid = trim($row['USERID']);

Then use $userid in your sql.

2. Items in arrays must be in quotes.

jzf

Jay Blanchard wrote:

[snip]
$sql = INSERT INTO tblname (USERID,FULLNAME,SSN,STARTDATE) VALUES
(trim($row[USERID]),trim($row[FULLNAME]),trim($row[SSNO]),trim($row[STAR
TDAT
E]));
[/snip]

Time to quote and concatenate and make pretty...

$sql = "INSERT INTO tblname (USERID,FULLNAME,SSN,STARTDATE) ";
$sql .= "VALUES ( ";
$sql .= "'" . trim($row['USERID']) . "', ";
$sql .= "'" . trim($row['FULLNAME']) . "', ";
$sql .= "'" . trim($row['SSNO']) . "', ";
$sql .= "'" . trim($row['STARTDATE']) . "' ";
$sql .= ") ";

This will make things easier to maintain as well.




-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to