mycro Posted September 11, 2006 Share Posted September 11, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/20338-echo-is-not-working/ Share on other sites More sharing options...
bob_the _builder Posted September 11, 2006 Share Posted September 11, 2006 Hi,maybe its topic_id?Must be working fine if it displays the other variables. Quote Link to comment https://forums.phpfreaks.com/topic/20338-echo-is-not-working/#findComment-89592 Share on other sites More sharing options...
mycro Posted September 11, 2006 Author Share Posted September 11, 2006 no.. it's "topicid" ... I can't figure this out. Quote Link to comment https://forums.phpfreaks.com/topic/20338-echo-is-not-working/#findComment-89594 Share on other sites More sharing options...
rallokkcaz Posted September 11, 2006 Share Posted September 11, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/20338-echo-is-not-working/#findComment-89595 Share on other sites More sharing options...
mycro Posted September 11, 2006 Author Share Posted September 11, 2006 Hmm still nothing. This makes no sense!! Quote Link to comment https://forums.phpfreaks.com/topic/20338-echo-is-not-working/#findComment-89600 Share on other sites More sharing options...
rallokkcaz Posted September 11, 2006 Share Posted September 11, 2006 whats not working about it???is there a connect to database script somewhere in the codeyou might wanna try to just use something like $_GET['topicid'] Quote Link to comment https://forums.phpfreaks.com/topic/20338-echo-is-not-working/#findComment-89601 Share on other sites More sharing options...
bob_the _builder Posted September 11, 2006 Share Posted September 11, 2006 Yer, if other variables from the query work there is no reason why topicid shouldnt echo, doent matter that its set for auto incriments. Quote Link to comment https://forums.phpfreaks.com/topic/20338-echo-is-not-working/#findComment-89602 Share on other sites More sharing options...
perezf Posted September 11, 2006 Share Posted September 11, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/20338-echo-is-not-working/#findComment-89605 Share on other sites More sharing options...
pocobueno1388 Posted September 11, 2006 Share Posted September 11, 2006 [code]$query2 = "SELECT * FROM topics WHERE timestamp='$timestamp'";$result1 = mysql_query($query2, $conn);while($row=mysql_fetch_array($result1)) {echo "$row[topicid]";}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20338-echo-is-not-working/#findComment-89614 Share on other sites More sharing options...
kenrbnsn Posted September 11, 2006 Share Posted September 11, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/20338-echo-is-not-working/#findComment-89623 Share on other sites More sharing options...
panyero2003 Posted September 11, 2006 Share Posted September 11, 2006 Try this one..$query2 = "SELECT * FROM topics WHERE timestamp='$timestamp'";$result1 = mysql_query($query2, $conn);while($row=mysql_fetch_array($result1)) {echo "$row[topicid]";} Quote Link to comment https://forums.phpfreaks.com/topic/20338-echo-is-not-working/#findComment-89629 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.