/    Sign up×
Community /Pin to ProfileBookmark

non-stop looping

the while loop is this creates so many of them it crashes my browser what is wrong with the code?

[code=php]
<?php

$template = “<a name=”topic-{ID}”></a><h2><a href=”#”>{TITLE}</a></h2><p class=”post-by”>{CONTENT}</p><p class=”post-footer align-left”><a href=”index.php” class=”readmore”>Posted {DATE_POSTED}</a><br /></p>”;

$sql = “SELECT * FROM `news` LIMIT 3”;
$result = @mysqli_query($cxn, $sql) or print(“No Posts Found.”);
while($row = mysqli_num_rows($result)){
$temp = str_replace(“{TITLE}”, $row[‘title’], $template);
$temp = str_replace(“{DATE_POSTED}”, $row[‘datePosted’], $temp);
$temp = str_replace(“{ID}”, $row[‘id’], $temp);
$temp = str_replace(“{CONTENT}”, $row[‘content’], $temp);
echo $temp;
}

?>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@MrCoderMay 15.2008 — [B]mysql_num_rows[/B] should be [B]mysql_fetch_assoc[/B]

Didn't see the mysqli, should you be using mysql not mysqli, since you have no binds?

mysql_query

mysql_fetch_assoc
Copy linkTweet thisAlerts:
@bradmasterxauthorMay 15.2008 — thanks m8
×

Success!

Help @bradmasterx spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...