Jump to content

Variable from a database keeps equaling nothing.


Alex1646

Recommended Posts

I am trying to take a variable from a database. But it keeps equaling nothing. Ive tried using mysql_error() and sI get nothing. I also keep tryed mysql_num_rows() and I get 3(just what Id exspect).

Here is the code.

<?php
if($userb)
{ 


$q1 = "
SELECT sub FROM login_info
WHERE user='$user_log'
LIMIT 1
";
$s1 = mysql_query($q1);
$scribe  = mysql_fetch_assoc($s1);
$sub = explode('![sep]!' ,$scribe['sub']);
foreach($sub as $key => $name)
{
$q2 = "
SELECT * FROM subscribe
WHERE user = '$name'
";
echo 'Llama';
$s2 = mysql_query($q2);
$num1 = mysql_num_rows($s2);

echo '<h3>' .$name .' Posted ' .$num1 .' Storie(s)! </h3>';
while($stor  = mysql_fetch_assoc($s2));
{
	$story = $stor['stor'];
	$sid = $stor['sid'];
	$q3 = "
	SELECT * FROM story_info
	WHERE id = $sid 
	";

	echo $q3 .'<br />';
	$s3 = mysql_query($q3) or die(mysql_error());
	$rows = mysql_fetch_assoc($s3);

	$viewsdb = $rows['views'];
$titledb = $rows['title'];
$userdb = $rows['user'];
$catdb = $rows['cat'];
$ratdb = $rows['rating'];
$id_db = $rows['story_id'];
$sumdb = shorten($rows['sum']);
echo "<h3><a href='?p=page&id=$id_db'> $titledb </a>   </h3>";
echo "<div id='fun_info'>";
echo "$sumdb <br />";
echo "By <a href='?p=profile&user=$userdb'> $userdb </a> <br /> ";
echo "$viewsdb Views | Rated: $ratdb | Catagory: <a href='?p=cat_view&gen=$catdb'> $catdb </a>  </div>";

}

}

}
else
{
login('?p=sub');	
}


Alex you didn't tell us what number your looking for. But the only query that has the mysql_error() with it is the $s3 query. If you don't get an error then the query is running ok. And from the looks of it, it is ok. but I see this in the code that follows: $sumdb = shorten($rows['sum']);

 

shorten() is not a php function and If $sumdb is the number in question I would suspect that. echo $rows['sum'] to see what you have.

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.