You are here: Re: Problem with my SELECT « PHP Programming Language « IT news, forums, messages
Re: Problem with my SELECT

Posted by Rik on 10/26/06 18:13

bokke wrote:
> hi Jay,
>
> $query = "SELECT * FROM news WHERE writer=" . $_GET["SubCat"] . "";
> $result = mysql_query($query)
> or die ("no can do.");
>
> gets me a good old "no can do". besides I have these Select scripts
> working on other sites without the GET??

How would $_GET not work on other sites? Or do you mean the variable will
be fed otherwise?

In this case, one should offcourse always quote strings. When running into
trouble, don't blindly post this to a newsgroup/forum, there's othe things
you can check:

- Offcourse, there's always spelling errors.
- Echo the query-string, to check wether the query is built correctly
(which it wasn't in this case).
- Use backticks around field- and tablenames
- Echo mysql_error(), and check what it sais.

Seriously consider putting in the fieldnames instead of SELECT *, check the
manual why.

$cat = mysql_real_escape_string(trim($_GET['subcat']));//or any other means
of getting the value
$query = "
SELECT
*
FROM
`news`
WHERE
`writer` LIKE '$cat'";

--
Rik Wasmus

 

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

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