rugzo Posted September 25, 2008 Share Posted September 25, 2008 Hi all, I am new in the forum and also a beginner in php section. I am trying to do a simply listing in a php page. There is a simply table in mysql and the values in there should be listed in the page. The code --> <html> <head> <meta http-equiv="content-language" content="tr"> <meta http-equiv="content-type" type="text/html; charset=windows-1254"> </head> <body> <table border="1" bordercolor="#90022e"> <tr> <td width="16%"><font face="Arial Black" size="2">Adı</font></td> <td width="16%"><font face="Arial Black" size="2">Soyadı</font></td> <td width="17%"><font face="Arial Black" size="2">Kullanıcı Adı</font></td> <td width="13%"><font face="Arial Black" size="2">Şifre</font></td> <td width="21%"><font face="Arial Black" size="2">email</font></td> <td width="17%"><font face="Arial Black" size="2">Görüş</font></td> </tr> <?php @mysql_connect ("localhost","root","123") or die ("nix sql") ; @mysql_select_db ("uye") or die ("nix db") ; $sql = mysql_query ("SELECT * FROM uyeler") ; while ($liste = mysql_fetch_array($sql)) { ?> <tr> <td width="%16"><font face="verdana" size="2"><? echo "$liste(0)"; ?></font></td> <td width="%16"><font face="verdana" size="2"><? echo "$liste(1)"; ?></font></td> <td width="%17"><font face="verdana" size="2"><? echo "$liste(2)"; ?></font></td> <td width="%13"><font face="verdana" size="2"><? echo "$liste(3)"; ?></font></td> <td width="%21"><font face="verdana" size="2"><? echo "$liste(4)"; ?></font></td> <td width="%17"><font face="verdana" size="2"><? echo "$liste(5)"; ?></font></td> </tr> <? } ?> </table> </body> </html> But when i call the page i can see the table and the row numbers are also right but it look like -> Adı Soyadı Kullanıcı Adı Şifre email Görüş Array(0) Array(1) Array(2) Array(3) Array(4) Array(5) Array(0) Array(1) Array(2) Array(3) Array(4) Array(5) Array(0) Array(1) Array(2) Array(3) Array(4) Array(5) Array(0) Array(1) Array(2) Array(3) Array(4) Array(5) Array(0) Array(1) Array(2) Array(3) Array(4) Array(5) the first line is ok. but the values are not listed instead of the names you just see "array(0)... Can anyone help me. Where is my mistake. I am following the exact instructions of my php book. Thanks very much... Quote Link to comment https://forums.phpfreaks.com/topic/125819-solved-listing-mysql/ Share on other sites More sharing options...
jonsjava Posted September 25, 2008 Share Posted September 25, 2008 try this: <html> <head> <meta http-equiv="content-language" content="tr"> <meta http-equiv="content-type" type="text/html; charset=windows-1254"> </head> <body> <table border="1" bordercolor="#90022e"> <tr> <td width="16%"><font face="Arial Black" size="2">Adı</font></td> <td width="16%"><font face="Arial Black" size="2">Soyadı</font></td> <td width="17%"><font face="Arial Black" size="2">Kullanıcı Adı</font></td> <td width="13%"><font face="Arial Black" size="2">Şifre</font></td> <td width="21%"><font face="Arial Black" size="2">email</font></td> <td width="17%"><font face="Arial Black" size="2">Görüş</font></td> </tr> <?php @mysql_connect ("localhost","root","123") or die ("nix sql") ; @mysql_select_db ("uye") or die ("nix db") ; $sql = mysql_query ("SELECT * FROM uyeler") ; while ($liste = mysql_fetch_assoc($sql)) { $liste0 = $liste[0]; $liste1 = $liste[1]; $liste2 = $liste[2]; $liste3 = $liste[3]; $liste4 = $liste[4]; $liste5 = $liste[5]; echo <<<END <tr> <td width="%16"><font face="verdana" size="2">$liste0</font></td> <td width="%16"><font face="verdana" size="2">$liste1</font></td> <td width="%17"><font face="verdana" size="2">$liste2</font></td> <td width="%13"><font face="verdana" size="2">$liste3</font></td> <td width="%21"><font face="verdana" size="2">$liste4</font></td> <td width="%17"><font face="verdana" size="2">$liste5</font></td> </tr> END; } ?> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/125819-solved-listing-mysql/#findComment-650582 Share on other sites More sharing options...
Push Eject Posted September 25, 2008 Share Posted September 25, 2008 Does this help? <tr> <td width="%16"><font face="verdana" size="2"><?php echo $liste[0]; ?></font></td> <td width="%16"><font face="verdana" size="2"><?php echo $liste[1]; ?></font></td> <td width="%17"><font face="verdana" size="2"><?php echo $liste[2]; ?></font></td> <td width="%13"><font face="verdana" size="2"><?php echo $liste[3]; ?></font></td> <td width="%21"><font face="verdana" size="2"><?php echo $liste[4]; ?></font></td> <td width="%17"><font face="verdana" size="2"><?php echo $liste[5]; ?></font></td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/125819-solved-listing-mysql/#findComment-650585 Share on other sites More sharing options...
rugzo Posted September 25, 2008 Author Share Posted September 25, 2008 I tried that, but the result is that this time i just got the first line--> Adı Soyadı Kullanıcı Adı Şifre email Görüş --->the headers of the table. Thanks for the reply... Quote Link to comment https://forums.phpfreaks.com/topic/125819-solved-listing-mysql/#findComment-650649 Share on other sites More sharing options...
JsusSalv Posted September 25, 2008 Share Posted September 25, 2008 Hell rugzo: Give this a try: <?php // Create database connection. @ mysql_connect ("localhost","root","123") or die ("nix sql") ; @ mysql_select_db ("uye") or die ("nix db") ; $sql = "SELECT * FROM uyeler"; $result = mysql_query($sql) or die(mysql_error()); ?> <table> <tr> <th>Adı</th> <th>Soyadı</th> <th>Kullanıcı Adı</th> <th>Şifre</th> <th>email</th> <th>Görüş</th> </tr> <?php while ($liste = mysql_fetch_array($result)) { ?> <tr> <td><?php echo $liste[Adı]; ?></td> <td><?php echo $liste[soyadı]; ?></td> <td><?php echo $liste[KullanıcıAdı]; ?></td> <td><?php echo $liste[Şifre]; ?></td> <td><?php echo $liste[email]; ?></td> <td><?php echo $liste[Görüş]; ?></td> </tr> <?php } mysql_free_result($result); ?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/125819-solved-listing-mysql/#findComment-650663 Share on other sites More sharing options...
rugzo Posted September 26, 2008 Author Share Posted September 26, 2008 Thanks for the reply but the result is -> Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\t.php on line 23 I am also trying to understand why the example from my php book isn't working. It creates the table but list all values as array()... Can the reason be the version of php i am using 5.2.5 or maybe the version of mysql... Or can it be that i have to make a configuration in php.ini... I am really lost ??? Quote Link to comment https://forums.phpfreaks.com/topic/125819-solved-listing-mysql/#findComment-651347 Share on other sites More sharing options...
CroNiX Posted September 26, 2008 Share Posted September 26, 2008 Its because you were using parenthesis on your array elements when they should be square brackets. Wrong: <? echo "$liste(0)"; ?> Right: <?php echo $liste[0]; ?> You shouldnt need quotes around your array element. Also, its bad practice to use php short tags (<?), use the full tag (<?php) Quote Link to comment https://forums.phpfreaks.com/topic/125819-solved-listing-mysql/#findComment-651391 Share on other sites More sharing options...
rugzo Posted September 26, 2008 Author Share Posted September 26, 2008 Yesss, thats it... Thanks very much Cronix Quote Link to comment https://forums.phpfreaks.com/topic/125819-solved-listing-mysql/#findComment-651422 Share on other sites More sharing options...
Push Eject Posted September 29, 2008 Share Posted September 29, 2008 LOL - isn't that what I posted in my first reply? Quote Link to comment https://forums.phpfreaks.com/topic/125819-solved-listing-mysql/#findComment-653149 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.