Jump to content


Photo

It has always worked, now it doesn't anymore


  • Please log in to reply
2 replies to this topic

#1 RainbowRising

RainbowRising
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 16 August 2003 - 01:20 PM

On our site we have a product database that always worked correctly. Now when we activate a query it gives the wrong information, that is, it will display all the products instead of the only one were looking for.

Here\'s the code:

<?php
if (!($mylink = mysql_connect(\"localhost\",\"deleted\",\"deleted\")))
{
print \"<h3>could not connect to database</h3>n\";
exit;
}
mysql_select_db(\"vinifrance\");

$result = mysql_query(\"select * from Artikel where Artikel like
\'%$Artikel%\'
And Inhoud like \'%$Inhoud%\' And Groep like \'%$Groep%\' AND Info like \'%$Info%\' AND Land_Herkomst like \'%$Land_Herkomst%\' AND Regio_Herkomst like \'%$Regio_Herkomst%\'\");
if ($result)
$num = mysql_numrows($result);
if ($num == 0)
{
include_once(\"sorry.php\");

}
else

{
while ($row = mysql_fetch_array($result))
{
print \"<b><font color=#000000></b>\";
print \"<b>Vinifrance Artikelnummer: </b>\";
print $row[\"Code\"];
echo \"<img src=\'$row[foto]\'>\";
print \"<br>n\";
print \"<br>n\";
print \"<b>Artikel: </b>\";
print $row[\"Artikel\"];
print \"<br>n\";
print \"<br>n\";
print \"<b>Groep: </b>\";
print $row[\"Groep\"];
print \"<br>n\";
print \"<br>n\";
print \"<b>Inhoud: </b>\";
print $row[\"Inhoud\"];
print \"<br>n\";
print \"<br>n\";
print \"<b>Alcohol: </b>\";
print $row[\"Alcohol_percentage\"];
print \"<br>n\";
print \"<br>n\";
print \"<b>Land Herkomst: </b>\";
print $row[\"Land_Herkomst\"];
print \"<br>n\";
print \"<br>n\";
print \"<b>Regio Herkomst: </b>\";
print $row[\"Regio_Herkomst\"];
print \"<br>n\";
print \"<br>n\";
print \"<b>Informatie: </b>\";
print \"<font color=#FF0000>\";
print nl2br($row[\"Info\"]);
print \"<br>n\";
print \"<br>n\";
print \"<font color=#000000>\";
print \"<b>Prijs: </b>\";
print $row[\"Prijs\"];
print \"<br>n\";
print \"<br>n\";
print \"<font color=#0000FF>Alle prijzen onder voorbehoud. Prijzen in de winkels zijn de juiste prijzen.</font>\";
print \"<br>n\";
print \"<br>n\";
print \"<b><font color=#000000></b>\";
print \"<b>Website: </b>\";
echo \"<font color=#0000FF><A HREF=http://\";
echo $row[\"Url\"];
echo \"><b><font color=#0000FF>\";
echo stripslashes($row[\"Url\"]);
echo \"</b></a></font>\";
print \"</font><br>n\";
echo \"<img src=/assets/images/autogen/a_CHEERBAR.gif>\";
print \"<br>n\";
print \"<br>n\";
}
mysql_free_result($result);
}
?>

You can test it here:
http://www.vinifranc...l/produkten.php

The site has been moved by the host to another server with a higher version of PHP (4.2.2). Should I change anything?

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 17 August 2003 - 03:59 PM

You will probably find that your variables are empty, which would give ... LIKE \'%%\' ... which would give every record.

It likely that your new host has \'register_globals\' OFF so the variables from the POST are not created automatically anymore

use

[php:1:90d0624772]<?php
$Artikel = $_POST[\'Artikel\'] ;
?>[/php:1:90d0624772]
etc. before doing the query.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 RainbowRising

RainbowRising
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 17 August 2003 - 06:34 PM

Thank you Barand,

That did the trick. Very impressed. Thanks again.

Martin




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users