Jump to content

Archived

This topic is now archived and is closed to further replies.

mycro

Echo is not working

Recommended Posts

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

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

echo $row[topicid];
}[/code]

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!

Share this post


Link to post
Share on other sites
try this

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

echo $row['topicid'];
}[/code]

Share this post


Link to post
Share on other sites
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']

Share this post


Link to post
Share on other sites
try this

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

Share this post


Link to post
Share on other sites
[code]$query2 = "SELECT * FROM topics WHERE timestamp='$timestamp'";
$result1 = mysql_query($query2, $conn);
while($row=mysql_fetch_array($result1)) {

echo "$row[topicid]";
}[/code]

Share this post


Link to post
Share on other sites
Put some debugging statements in your code to see what is going wrong:
[code]<?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)
}?>[/code]

Ken

Share this post


Link to post
Share on other sites
Try this one..

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

echo "$row[topicid]";
}

Share this post


Link to post
Share on other sites

×

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.