Why not trying this:
$q = "SELECT * FROM news_items WHERE upper('headline') LIKE '%".$find."%'";
echo $q;
$data = mysql_query($q);
...
And try running the echoed query in phpmyadmin, etc.
Cheers,
Tamas
-----Original Message-----
From: David Green [mailto:[email protected]]
Sent: Tuesday, August 09, 2011 4:14 PM
To: [email protected]
Subject: [PHP] Struggling with MySQL query
Hi
I have a simple from which uses the post method to get to my page script
results.php
in results.php I have
$find=$_POST["find"]; //this works perfectly, echo $find gives me the search
term as entered
I then connect to mysql and select the db successfully.
After that, I have the following:
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim($find);
$data = mysql_query("SELECT * FROM news_items WHERE upper('headline') LIKE
'%$find%'");
while($result = mysql_fetch_array($data)) { //etc
I get no error messages, but no results to work with either. It returns a
"no results" message that I put in further on in the script. A casual look
at the db shows that I should be getting results. I'm pretty sure that the
problem is in the query, but for the life of me I can't see the problem.
Kind regards
David
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php