Reply to Re: [PHP] Don't ejecute a sentence if a field is empty

Your name:

Reply:


Posted by Jochem Maas on 07/25/05 15:56

Jesús Alain Rodríguez Santos wrote:
> Hello I'm new:
> I need to know how can I stop a php sentence if my db is empty, for example
> I have writed a php sentence, if every fields from mmy db are full, there

what do you mean by 'php sentence'?

> is no problem, but I delete every values from the all fields in my db when
> I ejecute my script mysql give me an error, Ej:
>
> $fecha = mysql_query("SELECT event_day, event_month, event_year FROM
> $db_table WHERE event_title = $dia_maximo");
> $fecha_max = mysql_fetch_array($fecha);
> $fecha_maxima = $fecha_max['event_day'];
> $diames_maximo = $fecha_max['event_month'];
>
> wehen I ejecute the script the error message is it:

you get this message because $fecha is not what you think it is - I am willing
to bet that it actually contains FALSE), the reason it would contain false is
that your SQL statement is invalid. at the very least it should read something like:

"SELECT event_day, event_month, event_year
FROM $db_table
WHERE event_title = '$dia_maximo'"

if the value of $dia_maximo is coing from the user then you should be sanitizing the
value before using it in a query (see, as a start,
http://nl3.php.net/manual/en/function.mysql-real-escape-string.php)

>
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
> result resource in /home/www/cfg/prueba/calendar_este2/index.php on line
> 277
>
> sorry for my english, I'm cuban

dont be! (your english is better than my spanish! this probably goes for most people
onm the list!)

besides for some reason I had to really laugh when I read then the word 'ejecute'
.... laughing is always good! :-)

btw I think you meant 'execute'

>
>
>

[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

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