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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.