I have already seek help in my previous thread regarding this matter but there is no people replying I want to display information from the database & I got these codes from fellow member javaongsan <? $aQuery = "select articleid, title, description, left(description, 100) as remedy from articles where articleid =". $_GET['articleId']; $aResult = mysql_query($aQuery); while($aRow = mysql_fetch_array($aResult)) { echo '<b><u>'.$aRow["title"].'</u></b>'; echo '<br><b><u>Description :</u></b>'.$aRow["description"]; echo '<br><b><u>Remedy :</u></b>'.$aRow["remedy"]; } mysql_close(); ?> PHP: I tried it & it didn't return any result & javaongsan ask me to check the quotation which I still didn't get any result. Can someone please help me with this? This is my current code with connection to the database <? $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ailment", $con); $aQuery = "select articleid, title, description from articles where articleid =". $_GET['articleid']; $aResult = mysql_query($aQuery); while($aRow = mysql_fetch_array($aResult)) { echo '<b><u>'.$aRow["title"].'</u></b>'; echo '<br><b><u>'Description :'</u></b>'.$aRow["description"]; echo '<br><b><u>'Remedy :'</u></b>'.$aRow["remedy"]; } mysql_close(); ?> PHP: Your help is greatly appreciated.
have you tried to echo your statement to see if all variabled are correctly set? echo $aQuery; PHP: And take a look at your statement. Try running it in phpMyAdmin or something like that to check for syntax errors in you SQL statement
Hi, thank you for your reply, i built my database using phpmyadmin, i am actually using XAMPP to build the system, I have tried echo $aQuery; but it didn't display any result should i change my query statement?
<?php error_reporting(E_ALL); $con = mysql_connect("localhost","root","") or trigger_error('Could not connect: ' . mysql_error()); mysql_select_db("ailment", $con) or trigger_error(mysql_error()); if(isset($_GET['articleid'])){ $aQuery = "select articleid, title, description from articles where articleid =". mysql_real_escape_string($_GET['articleid']); $aResult = mysql_query($aQuery) or trigger_error(mysql_error()); while($aRow = mysql_fetch_array($aResult)) { echo '<b><u>'.$aRow["title"].'</u></b>'; echo '<br><b><u>'Description :'</u></b>'.$aRow["description"]; echo '<br><b><u>'Remedy :'</u></b>'.$aRow["remedy"]; } } else { echo "$_GET['articleid'] is not defined!"; } mysql_close(); ?> PHP: Try that, if any errors occur reply with them so we can assist you better.
$aQuery = "select articleid, title, description from articles where articleid =". $_GET['articleid'].""; Try this first echo $aQuery and run this query on phpmyadmin check what result comes.
Hi, thank you for your reply, a friend of mine already solved the problem, the problem is not from the quotation but it is indeed from the MySQL query where it cannot retrieve 'articleid', so my friend change 'articleid' to 'title' then the result displayed But nonetheless thank you all for your time to help me with the situation
Try this: while($aRow = mysql_fetch_array($aResult)) { echo "<b><u>$aRow[title] </u></b>"; echo "<br><b><u>Description :</u></b>$aRow[description] "; echo "<br><b><u>Remedy :</u></b>$aRow[remedy] "; } PHP: