Jump to content

[SOLVED] MySql php problem (again)


marklarah

Recommended Posts

Probably elementary, but compared to you guys, I suck ass at php (im only a begginer)

 

Im coding some forms, and on the page that displays the messages, I wan't the catagory, and the topic. I can echo the catagory fine, but the echoing the topic doesn't want to work:

 

<?php
if (isset($_GET['topic']))
{

$boardB = $_GET['topic'];

$loolo = 'SELECT * FROM topics WHERE ID = '.$boardB;
$lolo = mysql_query($loolo) or die(mysql_error());
$rowob = mysql_num_rows($lolo);
$titler = $rowob['Name'];

if (isset($titler)){
echo "yup";
}else{
echo "nope";
}

echo $boardB;
echo $titler;


} 
?>

 

It echoes nope and 1.

 

The one is what it should be, and its definetly one in the DB and the title is correct and such. Help please?

 

 

Link to comment
https://forums.phpfreaks.com/topic/86675-solved-mysql-php-problem-again/
Share on other sites

Thats because $rowob contains the number of rows returned by the query, not an array of the returned row. I assume you meant:

 

<?php
if (isset($_GET['topic']))
{

$boardB = $_GET['topic'];

$loolo = 'SELECT * FROM topics WHERE ID = '.$boardB;
$lolo = mysql_query($loolo) or die(mysql_error());
$rowob = mysql_fetch_assoc($lolo);
$titler = $rowob['Name'];

if (isset($titler)){
echo "yup";
}else{
echo "nope";
}

echo $boardB;
echo $titler;


} 
?>

 

p.s. You should learn to indent your code - it'll save you a hell of a lot of time and hassle in the future.

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.