Jump to content

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.

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.