Jump to content

[SOLVED] data not being pulled from db


soycharliente

Recommended Posts

My data is not being pulled from the db. I have no idea why. Can someone take a look at this code?

 

This code populates a div in my page. The 'reason' field isn't coming through.

<?php
function getSpotlight() {
dbconnect();
$query = "SELECT * FROM spotlight ORDER BY id DESC LIMIT 1";
$result = mysql_query($query) OR DIE ("Error: getSpotlight().");
if (mysql_num_rows($result) > 0) {
	while ($r = mysql_fetch_array($result)) {
		$member = $r["profileid"];
		$reason = myEscape($r["reason"]);
		$pic = getProfileField("image", $member);
		$name = getName($member);
			$spot = "<img src=\"img/bros/$pic\" class=\"picB\" alt=\"Picture of $name\" />
			<p><strong>$name</strong> $reason</p>\n";
		return $spot;
	}
} else {
	return "<p>No 'Alumni Spotlight' at this time.</p>\n";
}
dbclose();
}
?>

 

Here is the escape function. I took it from frost who posted it in response to something else a long time ago. Am I using it wrong or something? I'm using it in another query that is exactly the same as the one above except for a different table and it comes out fine.

<?php
function myEscape($string) {
      $new = get_magic_quotes_gpc() ? stripslashes($string) : $string;
      return mysql_real_escape_string($new);
}
?>

 

Only the image and the person's name are showing up in the div. The getProfileField() function is working fine so that can't be it.

Link to comment
https://forums.phpfreaks.com/topic/57171-solved-data-not-being-pulled-from-db/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.