variabele vergelijken met tabel entry
ik probeer dus momenteel een soort film bibliotheek te maken wat aardig lukt maar nu probeer ik een eerder gedefinieerde variabele te vergelijken met een database invulling maar krijg dus de foutmelding:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in ... on line 461
No Files Found.
mocht iemand me kunnen helpen, bedankt op voorhand!
Code (php)
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
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
<? php
stdhead("Movie Catalog");
$query = mysql_query("SELECT * FROM `movies` ORDER BY `id` DESC LIMIT 10");
if (mysql_num_rows($query) > 0){
while ($row = mysql_fetch_array($query)){
///layout
begin_frame("$row[name] ($row[year])");
print("<table align=center width=800 border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n");
Print("<tr><td width=150>$poster</td><td width=700>");
Print("<table align=center height=100% width=100% border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n");
Print("<tr><td width=150>year:</td><td width=100>$row[year]</td><td width=300></td></tr>");
Print("<tr><td width=150>budget:</td><td width=100>" . number_format($row[budget]) . "$</td><td width=300></td></tr>");
Print("<tr><td width=150>rating</td><td width=100>$row[rating]</td><td width=300></td></tr>");
Print("<tr><td width=150>revenue</td><td width=100>" . number_format($row[revenue]) . "$</td><td width=300></td></tr>");
Print("<tr><td width=150>runtime</td><td width=100>$row[runtime] min</td><td width=300></td></tr>");
Print("<tr><td width=150></td><td width=100></td><td width=150>$cat5 $cat4 $cat3 $cat2 $cat1</td></tr>");
Print("</table></td></tr></table>");
///torrents
$result = mysql_query("SELECT * FROM `files` WHERE `url`=`$row[imdb]`");
if (mysql_num_rows($result) > 0)
{
echo("<table border='0' cellpadding='5' cellspacing='0' class='ttable_headinner' align='center'>");
echo("<tr>");
echo("<td class='ttable_head'><strong>Name</strong></td>");
echo("<td class='ttable_head'><strong>test</strong></td>");
echo("<td class='ttable_head'><strong>test</strong></td>");
echo("</tr>");
while ($trow = mysql_fetch_array($result))
{
echo("<tr>");
echo("<td class='ttable_col1'>" . htmlspecialchars($trow["name"]) . "</td>");
echo("<td class='ttable_col2'>" . number_format($trow["test1"]) . "</td>");
echo("<td class='ttable_col1'>" . number_format($trow["test2"]) . "</td>");
echo("</tr>");
}
echo("</table>");
}
else
{
echo("<strong>No Files Found.</strong>");
}
////end///
end_frame();
}
}
?>
stdhead("Movie Catalog");
$query = mysql_query("SELECT * FROM `movies` ORDER BY `id` DESC LIMIT 10");
if (mysql_num_rows($query) > 0){
while ($row = mysql_fetch_array($query)){
///layout
begin_frame("$row[name] ($row[year])");
print("<table align=center width=800 border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n");
Print("<tr><td width=150>$poster</td><td width=700>");
Print("<table align=center height=100% width=100% border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n");
Print("<tr><td width=150>year:</td><td width=100>$row[year]</td><td width=300></td></tr>");
Print("<tr><td width=150>budget:</td><td width=100>" . number_format($row[budget]) . "$</td><td width=300></td></tr>");
Print("<tr><td width=150>rating</td><td width=100>$row[rating]</td><td width=300></td></tr>");
Print("<tr><td width=150>revenue</td><td width=100>" . number_format($row[revenue]) . "$</td><td width=300></td></tr>");
Print("<tr><td width=150>runtime</td><td width=100>$row[runtime] min</td><td width=300></td></tr>");
Print("<tr><td width=150></td><td width=100></td><td width=150>$cat5 $cat4 $cat3 $cat2 $cat1</td></tr>");
Print("</table></td></tr></table>");
///torrents
$result = mysql_query("SELECT * FROM `files` WHERE `url`=`$row[imdb]`");
if (mysql_num_rows($result) > 0)
{
echo("<table border='0' cellpadding='5' cellspacing='0' class='ttable_headinner' align='center'>");
echo("<tr>");
echo("<td class='ttable_head'><strong>Name</strong></td>");
echo("<td class='ttable_head'><strong>test</strong></td>");
echo("<td class='ttable_head'><strong>test</strong></td>");
echo("</tr>");
while ($trow = mysql_fetch_array($result))
{
echo("<tr>");
echo("<td class='ttable_col1'>" . htmlspecialchars($trow["name"]) . "</td>");
echo("<td class='ttable_col2'>" . number_format($trow["test1"]) . "</td>");
echo("<td class='ttable_col1'>" . number_format($trow["test2"]) . "</td>");
echo("</tr>");
}
echo("</table>");
}
else
{
echo("<strong>No Files Found.</strong>");
}
////end///
end_frame();
}
}
?>
Gewijzigd op 10/01/2011 21:31:09 door Kevin vdm
- verwijder de backticks
- haal de variabele buiten de quotes
- gebruik quotes voor tekstuele array-sleutels
dan wordt het
- gebruik idpv
zie mijn voorbeeld voor foutafhandeling:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$sql = "SELECT *
FROM files
WHERE url='".$row[imdb]."'
";
if(($result = mysql_query($sql)) === false)
{
echo 'Error: Er is een fout'; # Laat hier de mysql_error zien in testfase
}
else
{
# Gelukt
}
?>
$sql = "SELECT *
FROM files
WHERE url='".$row[imdb]."'
";
if(($result = mysql_query($sql)) === false)
{
echo 'Error: Er is een fout'; # Laat hier de mysql_error zien in testfase
}
else
{
# Gelukt
}
?>
- gebruik geen * maar selecteer wat je wil hebben: bijvoorbeeld: id, gebruikersnaam, email
Gewijzigd op 10/01/2011 21:21:30 door Jasper DS
wel, backticks zijn verwijder lijntje 27 van hier is aangepast maar de fout is er nog steeds.
heb je de foutafhandeling erin gezet?
heb ik gedaan, ik gebruikt normaal uum nooit foutenbehandeling, is ook een jaar geleden dat ik nog php heb gedaan dus ik zou niet weten waar men fout zou kunnen zitten dus mocht iemand me kunnen verder helpen...
voeg dan ook even mysql_error(); toe, de weet je de exacte fout
is opgelost Thanks voor alle hulp!
Nu nog even de netiquette afhandelen: wat heb je nu gevonden?