Mysql openen database (beginner)
Ik probeer met het volgende script informatie uit mijn database te halen:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?PHP
$hostname = "db.pcextreme.nl";
$user = "private";
$password = "private";
$database = "cms";
mysql_connect($hostname, $user, $password);
mysql_select_db($database);
$query = "select id, titel, bericht FROM cms WHERE id = 1";
$result = mysql_query($query);
while(list($id, $titel, $bericht))
print("$id, $titel, $bericht");
?>
$hostname = "db.pcextreme.nl";
$user = "private";
$password = "private";
$database = "cms";
mysql_connect($hostname, $user, $password);
mysql_select_db($database);
$query = "select id, titel, bericht FROM cms WHERE id = 1";
$result = mysql_query($query);
while(list($id, $titel, $bericht))
print("$id, $titel, $bericht");
?>
De database is aangemaakt en bevat ook content. Kan iemand mijn script verbouwen / mij helpen?
Code (php)
1
2
3
4
5
2
3
4
5
<?
$result = mysql_query($query);
while(list($id, $titel, $bericht))
print("$id, $titel, $bericht");
?>
$result = mysql_query($query);
while(list($id, $titel, $bericht))
print("$id, $titel, $bericht");
?>
Ben je hier niet iets vergeten?
$out = mysql_query($query);
$row = mysql_fetch_assoc($out);
print_r($row);
De rest verzinnen kan geen kwaad :)
Gewijzigd op 10/10/2004 17:15:00 door Eris -
Wat gaat er fout?
Script staat nu ge-upload op: cms.bakenonline.nl/boek.php
Dus
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?php
$result = mysql_query ('SELECT id, titel, bericht FROM cms WHERE id = 1') or trigger_error(mysql_error(), E_USER_ERROR);
while(list($id, $titel, $bericht) = mysql_fecht_assoc($result))
{
}
?>
$result = mysql_query ('SELECT id, titel, bericht FROM cms WHERE id = 1') or trigger_error(mysql_error(), E_USER_ERROR);
while(list($id, $titel, $bericht) = mysql_fecht_assoc($result))
{
}
?>
Zou je het gehele script incl. verbinden, en print / echo kunnen posten?
Bedankt
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
$hostname = "db.pcextreme.nl";
$user = "private";
$password = "private";
$database = "cms";
mysql_connect($hostname, $user, $password) or trigger_error(mysql_error(), E_USER_ERROR);
mysql_select_db($database) or trigger_error(mysql_error(), E_USER_ERROR);
$result = mysql_query ('SELECT id, titel, bericht FROM cms WHERE id = 1') or trigger_error(mysql_error(), E_USER_ERROR);
while(list($id, $titel, $bericht) = mysql_fecht_assoc($result))
{
print("{$id}, {$titel}, {$bericht}");
}
?>
$hostname = "db.pcextreme.nl";
$user = "private";
$password = "private";
$database = "cms";
mysql_connect($hostname, $user, $password) or trigger_error(mysql_error(), E_USER_ERROR);
mysql_select_db($database) or trigger_error(mysql_error(), E_USER_ERROR);
$result = mysql_query ('SELECT id, titel, bericht FROM cms WHERE id = 1') or trigger_error(mysql_error(), E_USER_ERROR);
while(list($id, $titel, $bericht) = mysql_fecht_assoc($result))
{
print("{$id}, {$titel}, {$bericht}");
}
?>
Zou moeten werken, als je de goede database, username en password invult.
Hier nog even het gehele script:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
$hostname = "db.pcextreme.nl";
$user = "-";
$password = "-";
$database = "-";
mysql_connect($hostname, $user, $password) or trigger_error(mysql_error(), E_USER_ERROR);
mysql_select_db($database) or trigger_error(mysql_error(), E_USER_ERROR);
$query = "Select id, titel, bericht FROM cms where id = 1";
$result = mysql_query($query);
while(list($id, $titel, $bericht) = mysql_fetch_row($result))
print("$id $titel $bericht)<BR>\n");
?>
$hostname = "db.pcextreme.nl";
$user = "-";
$password = "-";
$database = "-";
mysql_connect($hostname, $user, $password) or trigger_error(mysql_error(), E_USER_ERROR);
mysql_select_db($database) or trigger_error(mysql_error(), E_USER_ERROR);
$query = "Select id, titel, bericht FROM cms where id = 1";
$result = mysql_query($query);
while(list($id, $titel, $bericht) = mysql_fetch_row($result))
print("$id $titel $bericht)<BR>\n");
?>