phpretard
-
Posts
821 -
Joined
-
Last visited
Never
Posts posted by phpretard
-
-
what is the url value?
somethin.com?id=WHAT
-
What are expecting forumid to be (value)?
$forumid="WHAT";
-
Your original code:
include "config.php"; //$forumid = $_GET['id']; $forumid = "HARD CODE THIS"; print "<link rel='stylesheet' href='style.css' type='text/css'>"; print "<A href='post.php?id=$forumid'>New Topic</a><br>"; print " <table class='maintable'> <tr class='headline'><td width=50%>Topic</td> <td width=20%>Author/td><td>Replies</td> <td>Last reply</td> </tr> "; $info="SELECT * from post_reply where parentid='0' AND forumid='$forumid' ORDER BY lastrepliedto DESC"; $info2=mysql_query($info) or die(mysql_error()); while($info3=mysql_fetch_array($info2)) { $info3[title]=strip_tags($info3[title]); $info3[author]=strip_tags($info3[author]); print " <tr class='mainrow'><td><A href='message.php?id=$info3[postid]'>$info3[title]</a></td> <td>$info3[author]</td> <td>$info3[numreplies]</td> <td>$info3[showtime]<br>Last post by <b>$info3[lastposter]</b> </td> </tr> "; } print "</table>";
If you are using "forumid" to identify then make it an "int" and "auto increment" and make it "key"
-
Then this:
$forumid="what ever you are expecting it to be";
$TEST=mysql_query("SELECT post FROM post_reply WHERE parentid='0' AND forumid='$forumid' ");
-
Now try this:
$TEST=mysql_query("SELECT post FROM post_reply WHERE parentid='0'");
-
<?php include "config.php"; $TEST=mysql_query("SELECT post FROM post_reply"); if (!$TEST){die(mysql_error());} $num_rows = mysql_num_rows($TEST); echo "I have $num_rows in the row forumid and here they are:<br /><br /><br />"; WHILE($row=mysql_fetch_array($TEST)){ $post=$row['post']; echo $post."<br />"; } // CLOSE YOUR CONNECTION?? ?>
-
$forumid=$_POST['forumid']; // TAKE IT OUT
Stupid mistake on my part put this on the test page:
<?php include "config.php"; $TEST=mysql_query("SELECT yourpost FROM post_reply"); if (!$TEST){die(mysql_error());} $num_rows = mysql_num_rows($TEST); echo "I have $num_rows in the row forumid and here they are:<br /><br /><br />"; WHILE($row=mysql_fetch_array($TEST)){ $yourpost=$row['yourpost']; echo $yourpost."<br />"; } // CLOSE YOUR CONNECTION?? ?>
Why is your forumid a text field?
I imagine (since you can't get to phpAdmin) that $yourpost is a text field
-
here is the right code
$insertpost=mysql_query(" INSERT INTO post_reply(author,title,post,forumid,showtime,realtime,lastposter) values('$name','$subject','$yourpost','$forumid','$displaytime','$thedate','$name') "); if (!$insertpost){die(mysql_error());}
-
Now I know it's empty.
You are inserting blank values int the row forumid...
$forumid = $_GET['id']; // THIS MIGHT APPLY TO SOMETHING ELSE BUT NOT ON SUBMIT if(isset($_POST['submit'])) { $forumid=$_POST['forumid']; // YOUR VAR WAS EMPTY $name=$_POST['name']; $yourpost=$_POST['yourpost']; $subject=$_POST['subject'];
You have 4 empty rows.
-
Then I am pretty sure forumid is empty. The problem must be on post.
On your post page...
change:
$insertpost="INSERT INTO post_reply(author,title,post,forumid,showtime,realtime,lastposter) values('$name','$subject','$yourpost','$forumid','$displaytime','$thedate','$name')"; mysql_query($insertpost) or die("Could not insert post");
To:
$insertpost=mysql_query("INSERT INTO post_reply(author,title,post,forumid,showtime,realtime,lastposter) values('$name','$subject','$yourpost','$forumid','$displaytime','$thedate','$name')"; if (!$insertpost){die(mysql_error());}
Try this.
-
You have 4 entries according to num_rows.
Go to your DB (phpMyAdmin) and copy the value of one of the entries...post it
also how many tables do you have with a column name forumid?
-
Post the value of one of the text fields.
-
Just remembered that TEXT/BLOB columns can't have default values.
NULL would be the correct setting but, that shouldn't affect what we're doing.
Change it.
-
oops.
else {echo $forumid."<br />";}
-
<?php include "config.php"; $TEST=mysql_query("SELECT forumid FROM post_reply"); if (!$TEST){die(mysql_error());} $num_rows = mysql_num_rows($TEST); echo "I have $num_rows in the row forumid and here they are:<br /><br /><br />"; WHILE($row=mysql_fetch_array($TEST)){ $forumid=$row['forumid']; if ($num_rows=="0"){ echo" connecting to the wrong DB<br /> AND / OR<br /> connecting to the wrong table<br /> AND / OR<br /> forumid is empty<br /> "; }else {$forumid."<br />";} } // CLOSE YOUR CONNECTION?? ?>
-
Put it on page all by itself.
The last code post.
-
I was a banker for 10 years and if you store credit card numbers without certied through Visa, MC, etc... you go to Jail or will never be allowed to process a credit card again. (Credit Card Blacklist)
-
Are you putting this code on a new page?
Or trying to include it in the forum?
Just tying to narrow down to the problem page
-
If that gave you a blank page:
<?php include "config.php"; $TEST=mysql_query("SELECT forumid FROM post_reply"); if (!$TEST){die(mysql_error());} $num_rows = mysql_num_rows($TEST); echo "I have $num_rows in the row forumid"; WHILE($row=mysql_fetch_array($TEST)){ $forumid=$row['forumid']; if ($num_rows=="0"){ echo" connecting to the wrong DB<br /> AND / OR<br /> connecting to the wrong table<br /> AND / OR<br /> forumid is empty<br /> "; }else {$forumid."<br />";} } // CLOSE YOUR CONNECTION?? ?>
This will not give you a blank page.
-
<?php include "config.php"; $TEST=mysql_query("SELECT forumid FROM post_reply"); WHILE($row=mysql_fetch_array($TEST)){ $forumid=$row['forumid']; echo $forumid."<br />"; } // CLOSE YOUR CONNECTION?? ?>
Try it without the WHERE clause.
-
Does parent id='0'?
Is there a value in forumid?
as far as NULL or NOT NULL change it back and forth and find out if that's the problem
PS. Backup your DB first.
-
<?php include "config.php"; $TEST=mysql_query("SELECT forumid FROM post_reply WHERE parentid='0' "); WHILE($row=mysql_fetch_array($TEST)){ $forumid=$row['forumid']; echo $forumid; } // CLOSE YOUR CONNECTION?? ?> What does this give you?
-
print "<tr class='mainrow'><td><A href='message.php?id=$info3[postid]'>$info3[title]</a></td><td>$info3[author</td <td>$info3[numreplies]</td><td>$info3[showtime]<br>Last post by <b>$info3[lastposter]</b></td></tr>"; $info3[author</td // not closed "]" and the </td is not closed ">" should be: $info3[author]</td>
-
Did you take away the double quotes?
What is wrong here
in PHP Coding Help
Posted
When you navigate to the forum you want to display, does something like this show up in your browser
yourforum.com?forum_id=123456