Jump to content


Photo

Echo is not working


  • Please log in to reply
10 replies to this topic

#1 mycro

mycro
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 11 September 2006 - 02:23 AM

For some reason, the following code will not retreive the row data

$query2 = "SELECT * FROM topics WHERE timestamp='$timestamp'";
$result1 = mysql_query($query2, $conn);
while($row=mysql_fetch_array($result1)) {

echo $row[topicid];
}

This same thing works if I simply change $row[topicid] to a different field, such as row[username]. There IS data in all of the topicid rows, btw. If it helps, "topicid" is the primary index in my database, and auto incriments. Thank you!

#2 bob_the _builder

bob_the _builder
  • Members
  • PipPipPip
  • Advanced Member
  • 207 posts

Posted 11 September 2006 - 02:33 AM

Hi,

maybe its topic_id?

Must be working fine if it displays the other variables.

#3 mycro

mycro
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 11 September 2006 - 02:37 AM

no.. it's "topicid" ... I can't figure this out.

#4 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 11 September 2006 - 02:43 AM

try this

$query2 = "SELECT * FROM topics WHERE timestamp='$timestamp'";
$result1 = mysql_query($query2, $conn);
while($row=mysql_fetch_array($result1)) {

echo $row['topicid'];
}


#5 mycro

mycro
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 11 September 2006 - 02:58 AM

Hmm still nothing. This makes no sense!!

#6 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 11 September 2006 - 03:01 AM

whats not working about it???

is there a connect to database script somewhere in the code
you might wanna try to just use something like
$_GET['topicid']

#7 bob_the _builder

bob_the _builder
  • Members
  • PipPipPip
  • Advanced Member
  • 207 posts

Posted 11 September 2006 - 03:10 AM

Yer, if other variables from the query work there is no reason why topicid shouldnt echo, doent matter that its set for auto incriments.

#8 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 11 September 2006 - 03:27 AM

try this

$query2 = "SELECT * FROM topics WHERE timestamp='$timestamp'";
$result1 = mysql_query($query2, $conn);
while($row=mysql_fetch_array($result1)) {
$topic = $row[topicid];
echo $topic;
}


#9 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 11 September 2006 - 03:46 AM

$query2 = "SELECT * FROM topics WHERE timestamp='$timestamp'";
$result1 = mysql_query($query2, $conn);
while($row=mysql_fetch_array($result1)) {

echo "$row[topicid]";
}


#10 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 11 September 2006 - 04:32 AM

Put some debugging statements in your code to see what is going wrong:
<?php
$query2 = "SELECT * FROM topics WHERE timestamp='$timestamp'";
echo "The query we are using is: $query2<br>";
$result1 = mysql_query($query2, $conn) or die("There was a problem with the query: $query2<br>" . mysql_error());
echo 'Number of rows retrieved: ' . mysql_num_rows($result1) . '<br>';
while($row=mysql_fetch_assoc($result1)) {
       echo '<pre>' . print_r($row,true) . '</pre>';  // this is the crucial debugging line. It will show you exactly what has been retrieved.
//       echo $row['topicid'];  remove this line for now (put it back after you figure out what is wrong)
}?>

Ken

#11 panyero2003

panyero2003
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 11 September 2006 - 04:47 AM

Try this one..

$query2 = "SELECT * FROM topics WHERE timestamp='$timestamp'";
$result1 = mysql_query($query2, $conn);
while($row=mysql_fetch_array($result1)) {

echo "$row[topicid]";
}




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users