select werkt nie
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
include("config.php") ;
$sql = "SELECT * FROM clients" ;
$result = mysql_query($sql);
if (!$result) {
echo "Kon de query ($sql) niet uitvoeren: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "Geen rijen gevonden, niets te printen, dus stoppen.";
exit;
}
mysql_free_result($result);
?>
include("config.php") ;
$sql = "SELECT * FROM clients" ;
$result = mysql_query($sql);
if (!$result) {
echo "Kon de query ($sql) niet uitvoeren: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "Geen rijen gevonden, niets te printen, dus stoppen.";
exit;
}
mysql_free_result($result);
?>
Elwin
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
<?
include("config.php");
$sql = "SELECT * FROM clients";
$res = mysql_query($sql);
while($var = mysql_fetch_object)
{
echo "<tr><td>".$var->kolom1."</td><td>".$var->kolom2."</td></tr>";
}
?>
include("config.php");
$sql = "SELECT * FROM clients";
$res = mysql_query($sql);
while($var = mysql_fetch_object)
{
echo "<tr><td>".$var->kolom1."</td><td>".$var->kolom2."</td></tr>";
}
?>
</table>
Zoiets bedoel je?
Elwin
mysql_fetch_object() mist de haken en variabelen...
Als dat niet is post een je hele script of iig het hele deel wat met het verbinden, selecteren en verwerken ervan te maken heeft.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
<?
include("config.php");
$sql = "SELECT * FROM clients";
$res = mysql_query($sql);
while($var = mysql_fetch_object)
{
echo "<tr><td>"$var->lname"</td><td>"$var->fname"</td><td>"$var->nationality"</td><td>"$var->street"</td><td>"$var->no"</td><td>"$var->city"</td><td>"$var->zip"</td></td>"$var->country"</td><td>"$var->fax"</td><td>"$var->email"</td><td>"$var->alt_email"</td><td>"$var->mobile"</td><td>"$var->phone"</td><td>"$var->work"</td>;
}
?>
include("config.php");
$sql = "SELECT * FROM clients";
$res = mysql_query($sql);
while($var = mysql_fetch_object)
{
echo "<tr><td>"$var->lname"</td><td>"$var->fname"</td><td>"$var->nationality"</td><td>"$var->street"</td><td>"$var->no"</td><td>"$var->city"</td><td>"$var->zip"</td></td>"$var->country"</td><td>"$var->fax"</td><td>"$var->email"</td><td>"$var->alt_email"</td><td>"$var->mobile"</td><td>"$var->phone"</td><td>"$var->work"</td>;
}
?>
</table>
</body>
</html>
dit is het hele script, config.php is mijn mysqlconnect pagina, en nu laat die niks zien op de site alles is wit, terwijl de tabel clients gegevens bevat, kijk maar op: http://www.owndatabase.com/sel.php
line 17 = echo "<tr><td>"$var->lname"</td><td>"$var->fname"</td><td>"$var->nationality"</td><td>"$var->street"</td><td>"$var->no"</td><td>"$var->city"</td><td>"$var->zip"</td></td>"$var->country"</td><td>"$var->fax"</td><td>"$var->email"</td><td>"$var->alt_email"</td><td>"$var->mobile"</td><td>"$var->phone"</td><td>"$var->work"</td>;
}
?>
Gewijzigd op 22/09/2004 19:17:00 door phpdude
echo "<tr><td>"$var->lname"</td> (etcetera)
In die regel moet je alles zo doen:
echo "<tr><td>".$var->lname."</td>
Let op de punten rondom de variabele. Die moet overal komen te staan. Denk verder aan de volgende opmerking:
dutchcamel:
mysql_fetch_object() mist de haken en variabelen...
mysql_fetch_object() mist de haken en variabelen...
Elwin
ja dat had ik al verandert maar het is nog steeds precies hetzelfde
toon nog eens je compleet script meschien ?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
<?
include("config.php");
$sql = "SELECT * FROM clients";
$res = mysql_query($sql)
or die ("Cannot execute query");
while($var = mysql_fetch_object($res)) {
{
echo "<tr><td>"$var->lname"</td><td>"$var->fname"</td><td>"$var->nationality"</td><td>"$var->street"</td><td>"$var->no"</td><td>"$var->city"</td><td>"$var->zip"</td></td>"$var->country"</td><td>"$var->fax"</td><td>"$var->email"</td><td>"$var->alt_email"</td><td>"$var->mobile"</td><td>"$var->phone"</td><td>"$var->work"</td>;
}
?>
include("config.php");
$sql = "SELECT * FROM clients";
$res = mysql_query($sql)
or die ("Cannot execute query");
while($var = mysql_fetch_object($res)) {
{
echo "<tr><td>"$var->lname"</td><td>"$var->fname"</td><td>"$var->nationality"</td><td>"$var->street"</td><td>"$var->no"</td><td>"$var->city"</td><td>"$var->zip"</td></td>"$var->country"</td><td>"$var->fax"</td><td>"$var->email"</td><td>"$var->alt_email"</td><td>"$var->mobile"</td><td>"$var->phone"</td><td>"$var->work"</td>;
}
?>
</table>
</body>
</html>
Gewijzigd op 22/09/2004 20:21:00 door phpdude
Code (php)
1
2
3
2
3
<?php
echo "<tr><td>".$var->lname."</td><td>".$var->fname."</td><td>".$var->nationality."</td><td>".$var->street."</td><td>".$var->no."</td><td>".$var->city."</td><td>".$var->zip."</td></td>".$var->country."</td><td>".$var->fax."</td><td>".$var->emai.l"</td><td>".$var->alt_emai.l"</td><td>".$var->mobile."</td><td>".$var->phone."</td><td>".$var->work."</td>";
?>
echo "<tr><td>".$var->lname."</td><td>".$var->fname."</td><td>".$var->nationality."</td><td>".$var->street."</td><td>".$var->no."</td><td>".$var->city."</td><td>".$var->zip."</td></td>".$var->country."</td><td>".$var->fax."</td><td>".$var->emai.l"</td><td>".$var->alt_emai.l"</td><td>".$var->mobile."</td><td>".$var->phone."</td><td>".$var->work."</td>";
?>
kan je ff precies het hele script, posten want krijg nu weer een fout
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
<?
include("config.php");
$sql = "SELECT * FROM clients";
$res = mysql_query($sql)
or die ("Cannot execute query");
while($var = mysql_fetch_object($res)) {
{
echo "<tr><td>".$var->lname."</td><td>".$var->fname."</td><td>".$var->nationality."</td><td>".$var->street."</td><td>".$var->no."</td><td>".$var->city."</td><td>".$var->zip."</td><td>".$var->country."</td><td>".$var->fax."</td><td>".$var->email."</td><td>".$var->alt_email."</td><td>".$var->mobile."</td><td>".$var->phone."</td><td>".$var->work."</td></tr>";
}
?>
include("config.php");
$sql = "SELECT * FROM clients";
$res = mysql_query($sql)
or die ("Cannot execute query");
while($var = mysql_fetch_object($res)) {
{
echo "<tr><td>".$var->lname."</td><td>".$var->fname."</td><td>".$var->nationality."</td><td>".$var->street."</td><td>".$var->no."</td><td>".$var->city."</td><td>".$var->zip."</td><td>".$var->country."</td><td>".$var->fax."</td><td>".$var->email."</td><td>".$var->alt_email."</td><td>".$var->mobile."</td><td>".$var->phone."</td><td>".$var->work."</td></tr>";
}
?>
Voor de duidelijkheid zou ik voor dit gaan:
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?
include("config.php");
$sql = "SELECT * FROM clients";
$res = mysql_query($sql)
or die ("Cannot execute query");
while($var = mysql_fetch_object($res)) {
{
echo "<tr><td>".$var->lname."</td>\n";
echo "<td>".$var->fname."</td>\n";
echo "<td>".$var->nationality."</td>\n";
echo "<td>".$var->street."</td>\n";
echo "<td>".$var->no."</td>\n";
echo "<td>".$var->city."</td>\n";
echo "<td>".$var->zip."</td>\n";
echo "<td>".$var->country."</td>\n";
echo "<td>".$var->fax."</td>\n";
echo "<td>".$var->email."</td>\n";
echo "<td>".$var->alt_email."</td>\n";
echo "<td>".$var->mobile."</td>\n";
echo "<td>".$var->phone."</td>\n";
echo "<td>".$var->work."</td></tr>";
}
?>
include("config.php");
$sql = "SELECT * FROM clients";
$res = mysql_query($sql)
or die ("Cannot execute query");
while($var = mysql_fetch_object($res)) {
{
echo "<tr><td>".$var->lname."</td>\n";
echo "<td>".$var->fname."</td>\n";
echo "<td>".$var->nationality."</td>\n";
echo "<td>".$var->street."</td>\n";
echo "<td>".$var->no."</td>\n";
echo "<td>".$var->city."</td>\n";
echo "<td>".$var->zip."</td>\n";
echo "<td>".$var->country."</td>\n";
echo "<td>".$var->fax."</td>\n";
echo "<td>".$var->email."</td>\n";
echo "<td>".$var->alt_email."</td>\n";
echo "<td>".$var->mobile."</td>\n";
echo "<td>".$var->phone."</td>\n";
echo "<td>".$var->work."</td></tr>";
}
?>
Je fouten:
- Variabelen wel buiten de quote's, maar geen punten gebruikt...
- Bij $var->country had je de kolom gesloten ipv geopend
- Op het einde had je de rij niet gesloten
- De echo niet met een " afgesloten
Elwin
[Edit: Typo]
Gewijzigd op 22/09/2004 20:53:00 door Elwin - Fratsloos
nou is er een fout op line 37 en daar is de script net afgelopen zeg maar
Elwin
Parse error: parse error, unexpected $ in /home/owndata/public_html/sel.php on line 37
Twee keer een { voor de while loop. Doe het zo:
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?
include("config.php");
$sql = "SELECT * FROM clients";
$res = mysql_query($sql)
or die ("Cannot execute query");
while($var = mysql_fetch_object($res)) {
echo "<tr><td>".$var->lname."</td>\n";
echo "<td>".$var->fname."</td>\n";
echo "<td>".$var->nationality."</td>\n";
echo "<td>".$var->street."</td>\n";
echo "<td>".$var->no."</td>\n";
echo "<td>".$var->city."</td>\n";
echo "<td>".$var->zip."</td>\n";
echo "<td>".$var->country."</td>\n";
echo "<td>".$var->fax."</td>\n";
echo "<td>".$var->email."</td>\n";
echo "<td>".$var->alt_email."</td>\n";
echo "<td>".$var->mobile."</td>\n";
echo "<td>".$var->phone."</td>\n";
echo "<td>".$var->work."</td></tr>";
}
?>
include("config.php");
$sql = "SELECT * FROM clients";
$res = mysql_query($sql)
or die ("Cannot execute query");
while($var = mysql_fetch_object($res)) {
echo "<tr><td>".$var->lname."</td>\n";
echo "<td>".$var->fname."</td>\n";
echo "<td>".$var->nationality."</td>\n";
echo "<td>".$var->street."</td>\n";
echo "<td>".$var->no."</td>\n";
echo "<td>".$var->city."</td>\n";
echo "<td>".$var->zip."</td>\n";
echo "<td>".$var->country."</td>\n";
echo "<td>".$var->fax."</td>\n";
echo "<td>".$var->email."</td>\n";
echo "<td>".$var->alt_email."</td>\n";
echo "<td>".$var->mobile."</td>\n";
echo "<td>".$var->phone."</td>\n";
echo "<td>".$var->work."</td></tr>";
}
?>
Uit ervaring weet ik dat een foutmelding als jij nu krijgt te maken heeft met een van de volgende punten:
- Een accolade (zo een: { of }) wel openen, maar niet sluiten (andersom is volgens mij niet zo'n probleem)
- Een punt-komma vergeten
- Of zomaar een $ op regel x zetten .. ;)
Elwin
[Edit: Typo]
Gewijzigd op 23/09/2004 18:42:00 door Elwin - Fratsloos
ow oke harstikke bedankt, ik zal het onthouden
als ik een tabel wil maken met kolom lname, kolom fname, kolom nationality, en dat de gegevens dan precies in de juiste kolomen van de tabel komen, waar zo ik die dan in de script plaatsen?