Forum Moderators: coopster
<html>
<body>
<?
mysql_connect ("localhost", "username", "codeword") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("db");
$result = mysql_query(SELECT 'replies' FROM xmb_threads WHERE tid=11);
echo "comments: ";
echo $result;
?>
</body>
</html>
Does anyone understand what I am trying to get at? Andif so could someone please help. Thank you.
You may also want to read Basics of extracting data from MySQL [webmasterworld.com] in the PHP Library [webmasterworld.com] here at WebmasterWorld.
<html>
<body>
<?
mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("payingi_xmb1");
$result = mysql_query(SELECT 'replies' FROM xmb_threads WHERE tid=11);
$resulta = mysql_fetch_array($result);
echo "comments: ";
echo $resulta[replies];
?>
</body>
</html>
And I get this error:
Parse error: parse error in /home/payingi/public_html/pages/test3.html on line 6
Also I'm not sure is I have to use an array function because "replies" is only one number.
NOw does this mean line 6 of the whole page or line 6 of where the actual php code starts.
Also what am I doing wrong. I know it's so simple I just can't figure it out.
$sql = "SELECT replies FROM xmb_threads WHERE tid=11";
$result = mysql_query($sql);
Also I'm not sure is I have to use an array function because "replies" is only one number.
array. The mysql_result [php.net] function would work for you, but you'll find yourself using the other functions recommended on that page of the manual more often (as mentioned, the other functions are MUCH quicker as well). Also, you should always use quotes around a string literal array index.
echo $resulta['replies'];
<?
$dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("payingi_xmb1");
$tid="1";
$result = mysql_query("SELECT * FROM xmb_threads WHERE tid=$tid ");
while($row = mysql_fetch_array($result)) {
$mem = explode("¦", $row[lastpost]);
$row[replies] = stripslashes($row[replies]);
echo "<a href=\"/forum/viewthread.php?tid=$row[tid]\" target=\"main\" ONMOUSEOVER=\"this.style.color='#666666'\" ONMOUSEOUT=\"this.style.color='#000000'\">comments $row[replies]</a></br>";
echo "last comment by: <a href=\"/forum/member.php?action=viewpro&member=$mem\" target=\"main\" ONMOUSEOVER=\"this.style.color='#666666'\" ONMOUSEOUT=\"this.style.color='#000000'\">$mem[1]</a>"; } What it inables users of my website to do is comment on any section of the website where I put this code. The code links to a topic on my bullitan board. Check out the final results at <snip> If you click on any of the sections you will see the code at work and you will be able to comment on that section. Thanks for the help. I will have more questions as I delve further into mySQL. I am planning to eventually re-build my entire site and base it around a database so I have a lot of learning to do. [1][edited by: jatar_k at 4:07 am (utc) on Dec. 22, 2003]
?>
[edit reason] no personal urls thanks [/edit]