You are here: Re: [PHP] Don't ejecute a sentence if a field is empty « PHP « IT news, forums, messages
Re: [PHP] Don't ejecute a sentence if a field is empty

Posted by "Richard Lynch" on 07/25/05 04:20

On Sat, July 23, 2005 2:18 pm, Jesús Alain Rodríguez Santos said:
> 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
> 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:
>
> 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

After adding the error checking with mysql_error() others have suggested,
the error message you get will, most likely, comlpain that there is no
field named 'XYZ' where XYZ is your $dia_maximo

That's because you need to put apostrophes around text data in SQL.

".. WHERE event.title = '$dia_maximo' ";

--
Like Music?
http://l-i-e.com/artists.htm

 

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

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