Jump to content

Recommended Posts

I got the following code (will put at end) and im trying to grab some info from my database and stick it on the webpage however i get these errors:

 

Notice: Undefined variable: title in /home/content/p/p/f/ppffffpp/html/stayner.ca/TEST/showquestion.php on line 57

 

Notice: Undefined variable: message in /home/content/p/p/f/ppffffpp/html/stayner.ca/TEST/showquestion.php on line 60

 

Im not sure why  ??? anyway my code is below is somone could help - thanks.

 

 <?php
  $getthreads="SELECT * FROM forumtutorial_posts WHERE postid = '$page'";
$findamount = mysql_query($getthreads) or die (mysql_error());

//grab all the content
while($r=mysql_fetch_array($findamount))
{   
//the format is $variable = $r["nameofmysqlcolumn"]; - makes it easier to call later CAUSE IM LAZY!!
$answer=$r["answered"];
$title=$r['title'];
$post=$r['post'];
}
?>

Link to comment
https://forums.phpfreaks.com/topic/147856-solved-why-is-my-array-empty/
Share on other sites

ok..

 

try this:

 

<?php
if (isset($_GET['page'])) {
	$pid = (int) $_GET['page'];
	if ($pid) {
		mysql_connect("host.to.connect.to","user","password");
		mysql_select_db("dbToUse");
		$q = mysql_query("SELECT * FROM `forumtutorial_posts` WHERE `postid` = '$pid' LIMIT 1");
		if ($a = mysql_fetch_assoc($q)) {
			print_r($a);
		} else {
			// post $pid does not exist..
		}
	} else {
		// $pid is not a number or a positive number.
	}
} else {
	// page GET VAR not set
}
?>

 

change the values according to what you're doing

are this code

<?php
  $getthreads="SELECT * FROM forumtutorial_posts WHERE postid = '$page'";
$findamount = mysql_query($getthreads) or die (mysql_error());

//grab all the content
while($r=mysql_fetch_array($findamount))
{   
//the format is $variable = $r["nameofmysqlcolumn"]; - makes it easier to call later CAUSE IM LAZY!!
$answer=$r["answered"];
$title=$r['title'];
$post=$r['post'];
}
?>

before this one

<td><div align="center"><strong><?=$title?></strong></div></td>
    </tr>
    <tr bgcolor="#E6E6E6">
      <td height="138"><div align="center" class="style1"><?=$message?></div></td>

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.