Jump to content

What is wrong here


Ashoar

Recommended Posts

  • Replies 71
  • Created
  • Last Reply
<?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??

?>

Sorry, thought you wanted to see another text row.

 

Not to sure how to get that from inside the db, never had to do it before.

How do i? :)

 

EDIT: Only 1 column name forumid.

I have another table with a column called forum_id though, that table is used to create the boards through the admin panel, the id on that is used in the url to access it. e.g. board.php?id=3

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.

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.

"Parse error: syntax error, unexpected ';' "

 

That is the one at the end of the mysql query.

 

If i remove it i get:

 

"Parse error: syntax error, unexpected T_IF"

 

-------

 

Added in the blank variable bit you mentioned and used the original post page.

Still now threads showing though.

 

EDIT:

$forumid = $_GET['id']; // THIS MIGHT APPLY TO SOMETHING ELSE BUT NOT ON SUBMIT

 

That is used to grab the ID from the url.

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());}

$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

I assumed it would be the easiest mysql row to use, which is why i asked earlier if it was the correct one.

 

Now i get:

"Unknown column 'yourpost' in 'field list'"

 

I have no row called yourpost, the row for that is post, it is mediumtext.

 

EDIT: i know that, that row have data because if i remove or the id stuff and don't try to fetch it with the id, all the posts show up, just they show up in all the forums as well as the one it was posted in.

<?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??

?>

Archived

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

×
×
  • 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.