Jump to content

I need suggestions


burn1337

Recommended Posts

Ok so just recently I noticed that on the public version of my forum (I have it laid out for a seperate administration CMS type of thing) My forum does not display, I just copied the function that gets and displays the threads from my administration script (without risking tmi) I have error_reporting set to E_ALL at this present time, although it doesn't show any errors, but it also doesn't show my threads either, I have gone through and double checked all my vars, and ; and syntax I can't seem to find anything wrong with it.. could this be a possible XSS problem? Any suggestions as to what to check and/or change next?

Link to comment
Share on other sites

No not just a white blank page, the top and sides of my site layout displays,  but not the middle where the content goes or the bottom. it is obvious that something is keeping it from executing any farther, but I have no control statements that are active that would stop it, I see no actual problem that it could be, I have double and triple checked my syntax for the entire forum, it shows no errors. I do use the or die(), I haven't tried die(mysql_error()) but I'm going to in a min

Link to comment
Share on other sites

But people are trying to help you now? Can't because we can't actually help you find the problem... Often when I've been trying to find a problem for a long time, a break or a fresh pair of eyes helps you find it much faster...

 

Adam

Link to comment
Share on other sites

The Forum thread code:

function NTop($id) {
	$get = "select TopicId from Topics where ThreadId='$id'";
	$do = mysql_query($get);
	$count = mysql_num_rows($do);
	echo $count;
}

function DThreads($Thread) {
	echo '<tr>';
	echo '<td>';
	$id = $Thread[0];
	$page = "thread.php?threadid=$id";
	echo "<a href=$page>";
	echo $Thread[1];
	echo '</a>';
	echo '</td>';
	echo '<td>';
	echo $Thread[2];
	echo '</td>';
	echo '<td>';
	//$this->NTop($id);
	echo '</td>';
	echo '</tr>';		
}


function DisThread() {

	$text = 'select ThreadId from Threads';
	$tt = mysql_query($text) or die('Could not get count query');
	$count = mysql_num_rows($tt) or die('Could not get count');
	$I = $count - 1;
	for ($N = $I; $N >= 0; $N--) {
		$Id = mysql_result($tt, $N, 0);
		$what = "select * from Threads where ThreadID='$Id'";
		$get = mysql_query($what);
		$Thread = mysql_fetch_array($get);
		$this->DThreads($Thread);

	}
}

The Forum Thread page:


include('indexobj.php');
$Index = new Index;
$Index->Start();
$Index->Header();
$Index->Links();
//$login = new Login;
//$login->Must();
include('forumobj.php');
$forum = new Forum;
echo '<table border=1>';
$forum->DisThread();
echo '</table>';

$Index->Footer();
$Index->End();

Link to comment
Share on other sites

Sorry mate but that doesn't make much sense to me. From what I can understand, you're going a hell of a long way round to do simple things. I'd suggest rewriting them in a simpler, clearer form and then debugging any errors.

 

An example of what I'm talking about is in the DisThread function; you're running a query to select all the thread IDs.. counting up the results.. then using a for loop to perform a query for each thread, to then pass the array onto the DTThreads function, when you could do all that in one function, with far less code and only one query!

 

Adam

Link to comment
Share on other sites

Well first I tried the die(mysql_error()) thing and it's still not showing any errors.

 

MrAdam, I take it you propose a foreach loop? I was thinking that, and I have tried it with fewer lines of code, thats the code I use for my admin script that I just put in the public script (or course a little different though) cause it works just fine in my admin pages, but won't work on the public pages...

Link to comment
Share on other sites

Not sure why your so stressed out about it?

 

And no, not a foreach loop.. not sure wether you require the DThreads function to be seperate? But that could easily be added to the DisThread function, which itself could be cut down to far less lines.. for example:

 

function DisThread() {
$tt = mysql_query("SELECT * FROM Threads") or die('SELECT Error: ' .mysql_error());
$count = mysql_num_rows($tt) or die('COUNT Error: ' .mysql_error());
while ($Thread = mysql_fetch_assoc($tt)) {
	$this->DThreads($Thread);
}
}

 

Adam

Link to comment
Share on other sites

It has been Solved.. and once again I feel completely exploited cause my code is out in the open and yea... once again no one comes up with a solution... how ironic

 

Believe me, no one wants to steal code that runs like 100x slower than it should because of poor design.  Honestly, no one here wants to steal your code, they just want to help.

Link to comment
Share on other sites

I appologize if I come off rude or something. I don't necessarily think anyone is out to steal my code first off. I just feel weird about posting my code thats simply it.

 

Actually, I have been trying to get whiles, and do whiles to work, maybe when I was trying them I was syntacticly incorrect, but for some reason I couldn't get any results with whiles, or do whiles, I even used the manual with php.net, and tried to go off that syntax but it wouldn't do anything it would just error out, or do absolutely nothing not even an error.  I even tried basicly exactly what you suggested the only difference was the mysql_error(); and it wouldn't do anything. I could get them to work if I did nothing with querys, but as soon as I tried to do it with a query it wouldn't work for me. so I finally got everything to work with the for() loop. I know my code may not be exactly "professional" but I have also only been using php and mysql for less then 6 months, theoretically I am still a newb with php.

Not to mention I am also farely new with OOP as well. So I guess you could say this is also a learning experiance for me.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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