Jump to content

[SOLVED] $row['heading'] not displaying


camdenite

Recommended Posts

Hi all, I have been adapting scripts to build my own blog. All working okish so far. I have created a blog delete page - only problem is that I can't get it to display anything. I can get it to delete the blog but not show $row['heading'] or any other. There is definatly some text in there and the info shows up on my blog edit page - and indeed blog display page - as well as the actual page where you choose which you want to delete. But not here.

 

Thank you for any advice,

Colin

 

 

// Retrieve the page information.

$query = "SELECT blog_id, heading, first_para from blogb WHERE blog_id=$id";

$result = @mysql_query ($query); // Run the query.

if (mysql_num_rows($result) == 1) { // Valid page ID, show the form.

 

// Get the page information.

$row = mysql_fetch_array ($result, MYSQL_NUM);

 

// Create the form.

echo '<h2>Delete a blog.</h2>

<form action="delete_blog.php" method="post">

<h3>Blog Name: ' . $row['heading'] . '</h3>

<p>Are you sure you want to delete this blog?<br />

<input type="radio" name="sure" value="Yes" /> Yes

<input type="radio" name="sure" value="No" checked="checked" /> No</p>

<p><input type="submit" name="submit" value="Submit" /></p>

<input type="hidden" name="submitted" value="TRUE" />

<input type="hidden" name="id" value="' . $id . '" />

</form>';

 

} else { // Not a valid user ID.

echo '<h1 id="mainhead">Page Error</h1>

<p>This page has been accessed in error.</p><p><br /><br /></p>';

}

 

In fact echo $row['heading']; is not working either. Nothing in the error log :s

Link to comment
https://forums.phpfreaks.com/topic/143837-solved-rowheading-not-displaying/
Share on other sites

change

 

$query = "SELECT blog_id, heading, first_para from blogb WHERE blog_id=$id";
$result = @mysql_query ($query); // Run the query.

 

to

 

 
$query = "SELECT blog_id, heading, first_para from blogb WHERE blog_id=$id";
$result = @mysql_query ($query) or die(mysql_error()); // Run the query.

 

and see if that returns any errors

Hi justinh,

 

Thank you for this.

 

$query = "SELECT heading, first_para, entry FROM blogb WHERE blog_id=$id";

$result = @mysql_query ($query) or die(mysql_error());  // Run the query.

 

I did this but it returned no errors - not displayed or in the error log.

 

Cheers

You'll also want to change this....

 

$row = mysql_fetch_array ($result, MYSQL_NUM);

 

to...

 

$row = mysql_fetch_array ($result, MYSQL_ASSOC);

 

Hi thorpe,

          That did it  ;D I was wondering about the NUM as I wasn't trying to display a list. I will read up on it.

 

Thank you all  ;)

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.