Reply to Re: [PHP] Help with SQL Query String

Your name:

Reply:


Posted by Joseph Connolly on 03/31/05 18:16

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация