You are here: Re: [PHP] IBM's Learning PHP Part 1 tutorial. « PHP « IT news, forums, messages
Re: [PHP] IBM's Learning PHP Part 1 tutorial.

Posted by John Nichel on 07/06/05 16:20

Bill McEachran wrote:
> Newbie question.
>
> I'm working my way through IBM's PHP tutorial. Generally good ... but
> I'm stuck at an error point and have no idea what's going wrong.
> Before adding a new row to the mysql database (already opened) we do a
> query to see if a particular record already exists.
> (see $resultT).
>
> We then test, using if, to see if $resultT is true or false. If it's
> false we are then supposed to enter a new record.
> Problem: it's never false. It always evaluates true. What am I doing
> wrong? TIA
>
> /* build query to see if the record is entered already */
> $sqlT = "select * from users where username='".$_POST["name"]."'";
> $resultT = mysql_query($sqlT);

http://us2.php.net/mysql_query

mysql_query() will only return an error IF the query CANNOT be executed.
Basically, your query is executing fine, it's just returning zero
results. Check to see if any rows were returned...

http://us2.php.net/mysql_num_rows

if ( ! mysql_num_rows ( $resulT ) ) {
// No results returned
}

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john@kegworks.com

 

Navigation:

[Reply to this 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

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