sql SELECT probleempje

Praat mee over van alles en nog wat!
Forumregels
Dit forum is voor alle zinnige gesprekken buiten phpBB om. Discussies en gesprekken over interessante onderwerpen.

Een nieuw onderwerp moet..:
  • uiteraard voldoen aan de algemene voorwaarden
  • niet passen in de gewone supportfora
  • interessante zijn voor het overgrote deel van onze gebruikers
  • een neutrale of positieve ondertoon hebben
  • anders zijn dan bestaande onderwerpen
Plaats reactie
Gebruikersavatar
CG bandicoot
Berichten: 391
Lid geworden op: 18 mar 2004, 17:47
Locatie: Amersfoort
Contacteer:

sql SELECT probleempje

Bericht door CG bandicoot » 19 sep 2004, 19:32

Het gaat om deze site 'http://skateit.netrulon.com' en deze pagina 'http://skateit.netrulon.com/spotlist.php'.

Dit is de hele php file :

Code: Selecteer alles

<?php 
define('IN_PHPBB', true); 

$phpbb_root_path = './'; // <-- 
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.'.$phpEx); 

$userdata = session_pagestart($user_ip, PAGE_INDEX); 
init_userprefs($userdata); 

include($phpbb_root_path . 'includes/page_header.'.$phpEx); 
?>

<html>

<head>
<meta name="generator" content="Namo WebEditor v5.0">
</head>

<body bgcolor="#CC9966" text="black" link="blue" vlink="purple" alink="red">
<table cellpadding="0" cellspacing="0" width="991">
    <tr>
        <td width="138" height="30" bgcolor="#990000">
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color="#CC6600">Navigatie</font></b></p>
        </td>
        <td width="37" height="420" rowspan="6">
            <p>&nbsp;</p>
        </td>
        <td width="816" height="30" bgcolor="#990000">
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color="#CC6600">Nieuws</font></b></p>
        </td>
    </tr>
    <tr>
        <td width="138" height="113" valign="top" bgcolor="#996600">
            <p><?	    include('navigation.php')	    ?></p>
        </td>
        <td width="816" height="390" valign="top" rowspan="5" bgcolor="#996600">
            <p><?
$sql= "SELECT id,spot,location FROM phpbb_spots ORDER BY id desc limit 50"
   ";
   $res   = mysql_query($query);
   while($data = @mysql_fetch_array($res))
   { 
    echo "&nbsp;<a href="spot.php?id=$data["id"]."">".$data['spot']."</a><br>";
   }   
?>
</p>
        </td>
    </tr>
    <tr>
        <td width="138" height="25" valign="top" bgcolor="#990000">
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color="#CC6600">Links</font></b></p>
        </td>
    </tr>
    <tr>
        <td width="138" height="87" valign="top" bgcolor="#996600">
            <p><?  include('links.php')   ?></p>
        </td>
    </tr>
    <tr>
        <td width="138" height="23" valign="top" bgcolor="#990000" align="center">
            <p><b><font color="#CC9900">Latest event</font></b></p>
        </td>
    </tr>
    <tr>
        <td width="138" height="142" valign="top" bgcolor="#996600">
            <p>&nbsp;&nbsp;Nog geen evenementen bekend.  
</p>
        </td>
    </tr>
</table>
<p>&nbsp;</p>
</body>

</html>
 

<?
include($phpbb_root_path . 'includes/page_tail.'.$phpEx); 
?>
Dit is van regel 38 tot en met 47 :

Code: Selecteer alles

            <p><?
$sql= "SELECT id,spot,location FROM phpbb_spots ORDER BY id desc limit 50"
   ";
   $res   = mysql_query($query);
   while($data = @mysql_fetch_array($res))
   { 
    echo "&nbsp;<a href="spot.php?id=$data["id"]."">".$data['spot']."</a><br>";
   }   
?>
</p>
Wat is er fout?

Code: Selecteer alles

<?
$sql = mysql_query("SELECT * FROM bestevanbeste WHERE name = 'CG Bandicoot'");
while ($obj = mysql_fetch_assoc($sql)) {
if (mysql_num_rows($sql) == 0) {
echo 'Huh?';
} else {
echo 'Als je het maar weet.';
}} ?>

Gebruikersavatar
Podium4
Berichten: 3009
Lid geworden op: 07 aug 2003, 15:32
Locatie: Groningen / Zwolle

Bericht door Podium4 » 19 sep 2004, 19:41

Code: Selecteer alles

$sql= "SELECT id,spot,location FROM phpbb_spots ORDER BY id desc limit 50" 
   ";
Moet zijn:

Code: Selecteer alles

$sql= "SELECT id,spot,location FROM phpbb_spots ORDER BY id desc limit 50";
Alleen support via het forum, dus geen support via email, msn of pb.

Gebruikersavatar
CG bandicoot
Berichten: 391
Lid geworden op: 18 mar 2004, 17:47
Locatie: Amersfoort
Contacteer:

Bericht door CG bandicoot » 19 sep 2004, 19:47

Oke. Hij krijgt op spotlist.php nog steeds dezelfde fout melding. Het gaat over één of andere backslash.
Dit is nu de hele file :

Code: Selecteer alles

<?php 
define('IN_PHPBB', true); 

$phpbb_root_path = './'; // <-- 
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.'.$phpEx); 

$userdata = session_pagestart($user_ip, PAGE_INDEX); 
init_userprefs($userdata); 

include($phpbb_root_path . 'includes/page_header.'.$phpEx); 
?>

<html>

<head>
<meta name="generator" content="Namo WebEditor v5.0">
</head>

<body bgcolor="#CC9966" text="black" link="blue" vlink="purple" alink="red">
<table cellpadding="0" cellspacing="0" width="991">
    <tr>
        <td width="138" height="30" bgcolor="#990000">
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color="#CC6600">Navigatie</font></b></p>
        </td>
        <td width="37" height="420" rowspan="6">
            <p>&nbsp;</p>
        </td>
        <td width="816" height="30" bgcolor="#990000">
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color="#CC6600">Nieuws</font></b></p>
        </td>
    </tr>
    <tr>
        <td width="138" height="113" valign="top" bgcolor="#996600">
            <p><?	    include('navigation.php')	    ?></p>
        </td>
        <td width="816" height="390" valign="top" rowspan="5" bgcolor="#996600">
            <p><?
$sql= "SELECT id,spot,location FROM phpbb_spots ORDER BY id desc limit 50"; 
   $res   = mysql_query($query);
   while($data = @mysql_fetch_array($res))
   { 
    echo "&nbsp;<a href="spot.php?id=$data["id"]."">".$data['spot']."</a><br>";
   }   
?>
</p>
        </td>
    </tr>
    <tr>
        <td width="138" height="25" valign="top" bgcolor="#990000">
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color="#CC6600">Links</font></b></p>
        </td>
    </tr>
    <tr>
        <td width="138" height="87" valign="top" bgcolor="#996600">
            <p><?  include('links.php')   ?></p>
        </td>
    </tr>
    <tr>
        <td width="138" height="23" valign="top" bgcolor="#990000" align="center">
            <p><b><font color="#CC9900">Latest event</font></b></p>
        </td>
    </tr>
    <tr>
        <td width="138" height="142" valign="top" bgcolor="#996600">
            <p>&nbsp;&nbsp;Nog geen evenementen bekend.  
</p>
        </td>
    </tr>
</table>
<p>&nbsp;</p>
</body>

</html>
 

<?
include($phpbb_root_path . 'includes/page_tail.'.$phpEx); 
?>

Code: Selecteer alles

<?
$sql = mysql_query("SELECT * FROM bestevanbeste WHERE name = 'CG Bandicoot'");
while ($obj = mysql_fetch_assoc($sql)) {
if (mysql_num_rows($sql) == 0) {
echo 'Huh?';
} else {
echo 'Als je het maar weet.';
}} ?>

Gebruikersavatar
Podium4
Berichten: 3009
Lid geworden op: 07 aug 2003, 15:32
Locatie: Groningen / Zwolle

Bericht door Podium4 » 19 sep 2004, 20:25

Het gaat fout op deze regel:

Code: Selecteer alles

    echo "&nbsp;<a href="spot.php?id=$data["id"]."">".$data['spot']."</a><br>"; 
Vekeerd gebruik van de ". Als ik het niet mis heb moet ie zo worden:

Code: Selecteer alles

    echo "&nbsp;<a href=\"spot.php?id=$data[\"id\"].\"\">\".$data['spot'].\"</a><br>"; 
Alleen support via het forum, dus geen support via email, msn of pb.

Gebruikersavatar
CG bandicoot
Berichten: 391
Lid geworden op: 18 mar 2004, 17:47
Locatie: Amersfoort
Contacteer:

Bericht door CG bandicoot » 19 sep 2004, 20:37

Oke. Nu krijg ik weer dit :

Code: Selecteer alles

Parse error: parse error, unexpected T_CHARACTER, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/bandicoo/public_html/spotlist.php on line 43
Zo ziet de file er nu uit :

Code: Selecteer alles

<?php 
define('IN_PHPBB', true); 

$phpbb_root_path = './'; // <-- 
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.'.$phpEx); 

$userdata = session_pagestart($user_ip, PAGE_INDEX); 
init_userprefs($userdata); 

include($phpbb_root_path . 'includes/page_header.'.$phpEx); 
?>

<html>

<head>
<meta name="generator" content="Namo WebEditor v5.0">
</head>

<body bgcolor="#CC9966" text="black" link="blue" vlink="purple" alink="red">
<table cellpadding="0" cellspacing="0" width="991">
    <tr>
        <td width="138" height="30" bgcolor="#990000">
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color="#CC6600">Navigatie</font></b></p>
        </td>
        <td width="37" height="420" rowspan="6">
            <p>&nbsp;</p>
        </td>
        <td width="816" height="30" bgcolor="#990000">
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color="#CC6600">Nieuws</font></b></p>
        </td>
    </tr>
    <tr>
        <td width="138" height="113" valign="top" bgcolor="#996600">
            <p><?	    include('navigation.php')	    ?></p>
        </td>
        <td width="816" height="390" valign="top" rowspan="5" bgcolor="#996600">
            <p><?
$sql= "SELECT id,spot,location FROM phpbb_spots ORDER BY id desc limit 50"; 
   $res   = mysql_query($query);
   while($data = @mysql_fetch_array($res))
   { 
    echo "&nbsp;<a href=\"spot.php?id=$data[\"id\"].\"\">\".$data['spot'].\"</a><br>"; 
   }   
?>
</p>
        </td>
    </tr>
    <tr>
        <td width="138" height="25" valign="top" bgcolor="#990000">
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color="#CC6600">Links</font></b></p>
        </td>
    </tr>
    <tr>
        <td width="138" height="87" valign="top" bgcolor="#996600">
            <p><?  include('links.php')   ?></p>
        </td>
    </tr>
    <tr>
        <td width="138" height="23" valign="top" bgcolor="#990000" align="center">
            <p><b><font color="#CC9900">Latest event</font></b></p>
        </td>
    </tr>
    <tr>
        <td width="138" height="142" valign="top" bgcolor="#996600">
            <p>&nbsp;&nbsp;Nog geen evenementen bekend.  
</p>
        </td>
    </tr>
</table>
<p>&nbsp;</p>
</body>

</html>
 

<?
include($phpbb_root_path . 'includes/page_tail.'.$phpEx); 
?>

Code: Selecteer alles

<?
$sql = mysql_query("SELECT * FROM bestevanbeste WHERE name = 'CG Bandicoot'");
while ($obj = mysql_fetch_assoc($sql)) {
if (mysql_num_rows($sql) == 0) {
echo 'Huh?';
} else {
echo 'Als je het maar weet.';
}} ?>

Gebruikersavatar
mosymuis
Berichten: 6940
Lid geworden op: 05 feb 2003, 14:00
Locatie: Amsterdam
Contacteer:

Bericht door mosymuis » 20 sep 2004, 14:38

podium4 schreef:Het gaat fout op deze regel:

Code: Selecteer alles

    echo "&nbsp;<a href="spot.php?id=$data["id"]."">".$data['spot']."</a><br>"; 
Vekeerd gebruik van de ". Als ik het niet mis heb moet ie zo worden:

Code: Selecteer alles

    echo "&nbsp;<a href=\"spot.php?id=$data[\"id\"].\"\">\".$data['spot'].\"</a><br>"; 
Je hebt het mis. ;)

Code: Selecteer alles

    echo "&nbsp;<a href=\"spot.php?id=" . $data['id'] . "\">" . $data['spot'] . "</a><br>";

Gebruikersavatar
CG bandicoot
Berichten: 391
Lid geworden op: 18 mar 2004, 17:47
Locatie: Amersfoort
Contacteer:

Bericht door CG bandicoot » 20 sep 2004, 19:10

Oke. Mosymuis zijn oplossing heeft gewerkt.
Maar nu zit ik weer met een nieuw probleem.
Ik krijg een lege lijst te zien.
Hoe moet ik dat nou oplossen?

Code: Selecteer alles

<?
$sql = mysql_query("SELECT * FROM bestevanbeste WHERE name = 'CG Bandicoot'");
while ($obj = mysql_fetch_assoc($sql)) {
if (mysql_num_rows($sql) == 0) {
echo 'Huh?';
} else {
echo 'Als je het maar weet.';
}} ?>

Plaats reactie