Hi I want to show the user his articles using this code: <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("articles") or die(mysql_error()); $result = mysql_query("SELECT * FROM articles WHERE username={$_SESSION['username']} ORDER BY id") or die(mysql_error());?> <p align=center> your articles</p> <? while($row = mysql_fetch_array( $result )) { echo $row['subject'] ."<br>".$row['title']."<br>".$row['text']."<br><br>"; } mysql_close(); ?> PHP: but the output is: I have checked the spelling and have not found a mistake. it's so strange :?
You need quotes around strings in queries. $result = mysql_query("SELECT * FROM articles WHERE username='{$_SESSION['username']}' ORDER BY id") or die(mysql_error());
thanks now I want the article subjects clickable by something like: <a href=readarticle.php?id=$id> $row['subject']<a> PHP: at: <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("articles") or die(mysql_error()); $result = mysql_query("SELECT * FROM articles WHERE username='{$_SESSION['username']}' ORDER BY id") or die(mysql_error());?> <p align=center> مقالات شما </p> <? while($row = mysql_fetch_array( $result )) { echo <a href=readarticle.php?id=$id> $row['subject']<a> ."<br>".$row['title']."<br>".$row['text']."<br><br>"; } mysql_close(); ?> PHP: How do I get that done? because you see somewhere I need something but where and what?
<?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("articles") or die(mysql_error()); $result = mysql_query("SELECT * FROM articles WHERE username='{$_SESSION['username']}' ORDER BY id") or die(mysql_error());?> <p align=center> مقالات شما </p> <? while($row = mysql_fetch_array( $result )) { echo "<a href=\"readarticle.php?id=".$id."\">".$row['subject']."</a> <br />".$row['title']."<br />".$row['text']."<br /><br />"; } mysql_close(); ?> PHP: and also, i would recommend reading this: http://parseerror.com/~pizza/select*isevil.html