Re: Weird things happening with mysql

From: Date: Fri, 09 May 2003 18:18:27 +0000
Subject: Re: Weird things happening with mysql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147052@lists.php.net to get a copy of this message
Daniel, This might sound stupid, but echo or print $_POST['foo'] before executing the query just to make sure that $_POST['foo'] is really what you think it is. If $_POST['foo'] is empty or contains a value not in the database, you will get an empty $result. Joseph "Daniel R. Anderson" <dan@mathjunkies.com> wrote in message news:1052490768.22819.24.camel@ny-chicagost2d-72.buf.adelphia.net... > I have a $query for mysql that looks something like: > > $query = "SELECT * FROM table WHERE value = 'foo'"; > > If I mysql_query with foo typed in it works like a charm. If however I > try to: > > $query = "SELECT * FROM table WHERE value = '" . $_POST['foo'] . > "'"; > $result = mysql_query($query); > > The query succeeds but returns an empty $result. (I know there is an > entry in the table with foo (Primary Key). > > Anybody have any ideas why this might be? > > Thanks, > > -Dan >

« previous php.general (#147052) next »