Reply to How to create sql statement with php to insert null in database with update

Your name:

Reply:


Posted by JM on 01/21/07 18:55

When you pass an array to a function that will update a record in a
database.

for example:
function doIt($file) {
//connect to database

$sql = 'UPDATE Files ' .
"SET FileName = '" . $file['FileName']. "', " .
// what if $file['Author'] or $file['Description']
// equals null or ''? Should I test for this and construct
// my sql statement as a result of several if statements ?
// or is there another possibility ?
// FileID and FileName cannot be null so this is easy,
// but what for the other fields
"WHERE FileID = '" . $file['FileID'] . "'"
// execute sql
// return result
}

JM

[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

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