GetDotted Domains

Viewing Thread:
"MySQL search query"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Wed 30/06/04 at 13:42
"Bothered!"
Posts: 207
Right i have a slight problem with this code. On this page:

[URL]http://81.178.213.251/key/?page=2&from=0&limit=10[/URL]

Type in a product shown in the search box and hit enter and look at the error message that comes up...Can someone tell me what that error message means. The code for the search field is:


Search for a product:



And the code for the "searchquery.php" page is:


include "connect.php";

$sql = "select * from prods where prod_id=" . $_POST['idinput'];
echo $sql;

$result = mysql_query($sql) or die(mysql_error());

while ($row = mysql_fetch_array($query)) { echo "

",$row['prod_desc'],": ",$row['idinput']; }

....and it continues but this is the part that is obviously not working. Can someone please point me in the right direction for this...thanks.

SS

Thu 01/07/04 at 12:21
"Bothered!"
Posts: 207
Turbonutter wrote:
> Oh.. you've made a very stupid error:
>
> $result = mysql_query($sql) or die(mysql_error());
>
> while ($row = mysql_fetch_array($query))
>
> Spot the difference.

LOL thanks, sometimes it just takes another person to look at it...wen u proof read ur own code, you see what you want to see...cheerS!
Thu 01/07/04 at 09:26
Regular
"Pouch Ape"
Posts: 14,499
I should really start getting into SQL, especially as I have some pretty big web jobs coming up soon. Turbo, know any good resources for it out there? I'm a competent programmer, and it looks fairly straight-forward from the little snippets I've seen.
Thu 01/07/04 at 01:45
Regular
"Eff, you see, kay?"
Posts: 14,156
Oh.. you've made a very stupid error:

$result = mysql_query($sql) or die(mysql_error());

while ($row = mysql_fetch_array($query))

Spot the difference.
Thu 01/07/04 at 01:43
Regular
"Eff, you see, kay?"
Posts: 14,156
echo mysql_error();
Thu 01/07/04 at 00:22
"Bothered!"
Posts: 207
Right now i have another problem...

Here is the error message:

select * from prods where prod_id='AA101'

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\key\searchquery.php on line 13


Here is the page if you want to play around with it...you can download it in this zip file:

[URL]http://www.ukhacking.com/phpzip.zip[/URL]

Thanks if you can help!
Wed 30/06/04 at 14:57
"Bothered!"
Posts: 207
Thanks a lot, I will try that as soon as I get back on it...CHEERS!
Wed 30/06/04 at 14:43
Regular
Posts: 88
secret_squirrel™ wrote:

> $sql = "select * from prods where prod_id=" .
> $_POST['idinput'];

You need to put quotes around the variable you're searching on.

Change the above line to:
$sql = "select * from prods where prod_id='".$_POST['idinput']."'";

To make your code a little more safe use:

$sql = "select * from prods where prod_id='" .mysql_escape_string($_POST['idinput']) . "'";

This will help prevent your script failing if someone types a ' for their search.

EDIT: You may want to COPY&PASTE what I've written cos it's difficult to make out the single / double quotes properly.
Wed 30/06/04 at 13:42
"Bothered!"
Posts: 207
Right i have a slight problem with this code. On this page:

[URL]http://81.178.213.251/key/?page=2&from=0&limit=10[/URL]

Type in a product shown in the search box and hit enter and look at the error message that comes up...Can someone tell me what that error message means. The code for the search field is:


Search for a product:



And the code for the "searchquery.php" page is:


include "connect.php";

$sql = "select * from prods where prod_id=" . $_POST['idinput'];
echo $sql;

$result = mysql_query($sql) or die(mysql_error());

while ($row = mysql_fetch_array($query)) { echo "

",$row['prod_desc'],": ",$row['idinput']; }

....and it continues but this is the part that is obviously not working. Can someone please point me in the right direction for this...thanks.

SS

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Very pleased
Very pleased with the help given by your staff. They explained technical details in an easy way and were patient when providing information to a non expert like me.
Impressive control panel
I have to say that I'm impressed with the features available having logged on... Loads of info - excellent.
Phil

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.