Na reinstall sorteert PHP niet in MySQL

Pagina: 1
Acties:
  • 62 views sinds 30-01-2008

  • Dionysus007281
  • Registratie: Maart 2002
  • Laatst online: 06-05 14:01

Dionysus007281

Spank my monkey!

Topicstarter
Ik heb een probleempje gehad met m'n Linux server, en alles is opnieuw geinstalleerd.
Ik heb apache met MySQL, waarin een database staat van al m'n DVD's.
Met PHP heb ik een script gemaakt dat zoekt in die DB, op bv. titel of cast.

Dit werkte altijd prima, tot na de reinstall.

Als ik nu een zoekopdracht geef, krijg ik gewoon een overzicht van álles wat er in de DB staat, niet alleen de resultaten.

Ik heb een sql dump gemaakt en deze na de reinstall opnieuw geimporteerd, en de volledige inhoud van de website met PHP scripts gewoon gekopieerd. Er is dus bij mijn weten niks veranderd.

Ik weet niet of het nou een MySQL probleem of iets van PHP, maar de scripts lijken me goed. Ik heb tevens de MySQL gebruiker alle rechten gegeven op de betreffende DB, dus dat kan het ook niet zijn. Als ik dezelfde zoekopdracht geef vanaf de CLI op de server krijg ik wel het goede resultaat.

Dit zijn de scripts:

De eerste pagina, waarop idd een overzicht van de gehele inhoud, (dit is dus de bedoeling)

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
$db = mysql_select_db("verzamelingen");

function display_db_table($tablename)
{
    $query_string = "select * from dvd";
    $result_id = mysql_query($query_string);
    $column_count = mysql_num_fields($result_id);

    print ("<TABLE BORDER=1>\n");
    while ($row = mysql_fetch_row($result_id))
        {
            print("<TR ALIGN=LEFT VALIGN=TOP>");
            for ($column_num = 0;
                $column_num < $column_count;
                $column_num++)
            print("<TD>$row[$column_num]</TD>\n");
            print("</TR>\n");
        }
        print("</TABLE>\n");
}
?>

<HTML>
<HEAD>
<TITLE>Patrick's</TITLE>
<link href="../all.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {font-size: small}
-->
</style>
</HEAD>
<BODY>
<table width="950" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <th align="left" scope="col" width="450"><H3>U kunt hier zoeken op Titel, Cast en Genre</H3></th>
    <th align="right" scope="col"><a href="../index.php" target="_self" class="style1">Home</a></th>
  </tr>
</table>
<form action=search_results_dvd.php method=post>
<input type=text name=titel size=30>
<input type=submit name=zoeken value=Zoeken>
</form>

<TABLE width="950" border="1" cellspacing="2" cellpadding="2" bgcolor="#DDDDDD">
    <tr>
    <th scope="col">Titel</th>
    <th scope="col">Cast</th>
    <th scope="col">Episodes</th>
    <th scope="col">Genre</th>
    <th scope="col">Speelduur</th>
    <th scope="col">Regio</th>
    <th scope="col">Aantal DVD's</th>
    </tr>
<?php
$quotedtitel = mysql_escape_string($titel);
$query = "SELECT titel,cast,episodes,genre,speelduur,regio,aantal FROM dvd WHERE titel like '%$quotedtitel%' ORDER BY titel";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {

?>
    <tr>
    <td><div align="left"><?php echo $row["titel"]; ?></div></td>
    <td><div align="left"><?php echo $row["cast"]; ?></div></td>
    <td><div align="left"><?php echo $row["episodes"]; ?></div></td>
    <td><div align="left"><?php echo $row["genre"]; ?></div></td>
    <td><div align="right"><?php echo $row["speelduur"]; ?></div></td>
    <td><div align="right"><?php echo $row["regio"]; ?></div></td>
    <td><div align="right"><?php echo $row["aantal"]; ?></div></td>
    </tr>

<?php
}
?>
</TABLE>
</BODY>
</HTML>


De zoekresultaat pagina, waar ik ook een overzicht krijg van de hele inhoud, wat dus niet de bedoeling is:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$db = mysql_select_db("verzamelingen");
$quotedtitel = mysql_escape_string($titel);
$query = "SELECT titel,cast,episodes,genre,speelduur,regio,aantal FROM dvd WHERE titel like '%$quotedtitel%' OR cast like '%$quotedtitel%' OR genre like '%$quotedtitel%' ORDER BY titel";
$result = mysql_query($query);
$resultaten = mysql_num_rows($result);
    if($resultaten == "1")
        $show1 = "is";
    else
        $show1 = "zijn";

    if($resultaten == "1")
        $show2 = "DVD";
    else
        $show2 = "DVD's";

    echo "<B>Er $show1 $resultaten $show2 gevonden:<P>";
?>

<HTML>
<HEAD>
<TITLE>Zoekresultaten</TITLE>
<link href="../all.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>

<TABLE width="950" border="1" cellspacing="2" cellpadding="2" bgcolor="#DDDDDD">
    <tr>
    <th scope="col">Titel</th>
    <th scope="col">Cast</th>
    <th scope="col">Episodes</th>
    <th scope="col">Genre</th>
    <th scope="col">Speelduur</th>
    <th scope="col">Regio</th>
    <th scope="col">Aantal DVD's</th>
    </tr>

<?php

while ($row = mysql_fetch_array($result)) {

?>
    <tr>
    <td><div align="left"><?php echo $row["titel"]; ?></div></td>
    <td><div align="left"><?php echo $row["cast"]; ?></div></td>
    <td><div align="left"><?php echo $row["episodes"]; ?></div></td>
    <td><div align="left"><?php echo $row["genre"]; ?></div></td>
    <td><div align="right"><?php echo $row["speelduur"]; ?></div></td>
    <td><div align="right"><?php echo $row["regio"]; ?></div></td>
    <td><div align="right"><?php echo $row["aantal"]; ?></div></td>
    </tr>
<?php
}
?>

</BODY>
</HTML>


Als je het wilt testen, adres is http://p-lankhorst.nl

Het vreemde is trouwens dat als ik een onzin opdracht geef, zoals a;ljds;lahfd, dat ik geen foutmelding krijg, maar weer dat hele overzicht.

[ Voor 26% gewijzigd door Dionysus007281 op 11-02-2004 20:58 ]

Dual Opteron 248 Nu met Asus X800XT PE @ X850XT PE Server.


  • 4VAlien
  • Registratie: November 2000
  • Laatst online: 26-05 14:22

4VAlien

Intarweb!

Als je je php geupgrade hebt of weer de default config hebt dan moet je kijken of je argumenten zo mag gebruiken of dat je specifiek GET moet gebruiken.

edit , ff zoeken in php.ini :
; You should do your best to write your scripts so that they do not require
; register_globals to be on; Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of.
; ##### JMD: This is set to On in Mandrake because a lot of existing scripts
; needs it to be on, and we don't want to break configuration. Turning
; it on is a Bad Thing (tm), but for the sake of compatibility and less
; technical support, we'll close our eyes ;-)
register_globals = On

staat bij jou op off gok ik, zie ook:
http://nl.php.net/register_globals

edit 3 ;) En het gaat ook goed als je onzin in vult omdat op dit moment altijd de zoek query eruit ziet als bla like '%%' or bla like '%%' wat dus matcht op alle strings in je database

[ Voor 82% gewijzigd door 4VAlien op 11-02-2004 21:05 ]


  • Dionysus007281
  • Registratie: Maart 2002
  • Laatst online: 06-05 14:01

Dionysus007281

Spank my monkey!

Topicstarter
Dat was het idd. Dank U.

Dual Opteron 248 Nu met Asus X800XT PE @ X850XT PE Server.


  • curry684
  • Registratie: Juni 2000
  • Laatst online: 12-05 22:23

curry684

left part of the evil twins

FAQ-werk dus :Y)

Professionele website nodig?


Dit topic is gesloten.