PDA

View Full Version : Help please ;]



Ini
17-06-2007, 02:54 PM
Posting here becuase no1 looks at coding section, which sucks.

Whats wrong with this?



<?
function BBCODE($bbcode)
{
$bbc_a=array(
",
"" target=_blank>",
"",
"&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><div style='overflow:auto; width:450px'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px dashed #000000;'><tr><td><b>&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><div style='overflow:auto; width:450px'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px dashed #000000;'><tr><td><b>CODE:</b></td></tr></table></b></td></tr></table>",
"</div></fieldset>",
"<img src="",
"" border="0">",
"<i>",
"</i>",
"",
"",
"<b>",
"</b>",
"<u>",
"</u>"
);
$bbc_b=array(
"<a href='",
"'>Link</a>",
"<strong>&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><div style='overflow:auto; width:450px'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px dashed #000000;'><tr><td><b>CODE:</b></td></tr></table></strong><div style=\"margin:0px 5px;padding:5px;border:1px dashed #000000;width:90%; overflow:auto; width:90%\"></em>",
"</em></div>",
"<img src='",
"'>",
"<i>",
"</i>",
"<strike>",
"</strike>",
"<b>",
"</b>",
"<u>",
"</u>"
);

$bbc_num=count($bbc_a);
$loop=0;
while($loop<$bbc_num)
{
$bbcode=str_replace($bbc_a[$loop], $bbc_b[$loop], $bbcode);
$loop++;
}
return $bbcode;
}
?>


I can't figure it out ;[

My error is..


Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/****/public_html/users/bbcode.php on line 6


Line 6:


"" target=_blank>",

+rep for all help.

Blob
17-06-2007, 03:00 PM
I added indents and made it look better and fixed it.


<?
function BBCODE( $bbcode )
{
$bbc_a = array(
",
"\" target=_blank>",
"",
"&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><div style='overflow:auto; width:450px'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px dashed #000000;'><tr><td><b>&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><div style='overflow:auto; width:450px'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px dashed #000000;'><tr><td><b>CODE:</b></td></tr></table></b></td></tr></table>",
"</div></fieldset>",
"<img src="",
"\" border="0">",
"<i>",
"</i>",
"",
"",
"<b>",
"</b>",
"<u>",
"</u>"
);
$bbc_b = array(
"<a href='",
"'>Link</a>",
"<strong>&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><div style='overflow:auto; width:450px'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px dashed #000000;'><tr><td><b>CODE:</b></td></tr></table></strong><div style=\"margin:0px 5px;padding:5px;border:1px dashed #000000;width:90%; overflow:auto; width:90%\"></em>",
"</em></div>",
"<img src='",
"'>",
"<i>",
"</i>",
"<strike>",
"</strike>",
"<b>",
"</b>",
"<u>",
"</u>"
);

$bbc_num = count( $bbc_a );
$loop = 0;
while( $loop<$bbc_num )
{
$bbcode=str_replace( $bbc_a[$loop], $bbc_b[$loop], $bbcode );
$loop++;
}
return $bbcode;
}
?>

Ini
17-06-2007, 03:08 PM
Tried it and now i get:



Parse error: syntax error, unexpected T_STRING, expecting ')' in /home/thirty/public_html/users/bbcode.php on line 6

Blob
17-06-2007, 03:14 PM
Tried it and now i get:



Parse error: syntax error, unexpected T_STRING, expecting ')' in /home/thirty/public_html/users/bbcode.php on line 6


Works on my localhost..

Try this


<?
function BBCODE( $bbcode )
{
$bbc_a = array(
"",
"\" target=_blank>",
"",
"&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><div style='overflow:auto; width:450px'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px dashed #000000;'><tr><td><b>&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><div style='overflow:auto; width:450px'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px dashed #000000;'><tr><td><b>CODE:</b></td></tr></table></b></td></tr></table>",
"</div></fieldset>",
"<img src="",
"" border="0">",
"<i>",
"</i>",
"",
"",
"<b>",
"</b>",
"<u>",
"</u>"
);
$bbc_b = array(
"<a href='",
"'>Link</a>",
"<strong>&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><div style='overflow:auto; width:450px'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px dashed #000000;'><tr><td><b>CODE:</b></td></tr></table></strong><div style=\"margin:0px 5px;padding:5px;border:1px dashed #000000;width:90%; overflow:auto; width:90%\"></em>",
"</em></div>",
"<img src='",
"'>",
"<i>",
"</i>",
"<strike>",
"</strike>",
"<b>",
"</b>",
"<u>",
"</u>"
);

$bbc_num = count( $bbc_a );
$loop = 0;
while( $loop<$bbc_num )
{
$bbcode=str_replace( $bbc_a[$loop], $bbc_b[$loop], $bbcode );
$loop++;
}
return $bbcode;
}
?>

Ini
17-06-2007, 03:22 PM
Okay.. That worked ;]

but i get a new error now




Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/thirty/public_html/users/bbcode.php on line 11



Line 11:



"" border="0">",

Blob
17-06-2007, 03:29 PM
<?
function BBCODE( $bbcode )
{
$bbc_a = array(
"",
"\" target=_blank>",
"",
"&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><div style='overflow:auto; width:450px'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px dashed #000000;'><tr><td><b>&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><div style='overflow:auto; width:450px'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px dashed #000000;'><tr><td><b>CODE:</b></td></tr></table></b></td></tr></table>",
"</div></fieldset>",
"<img src=\"",
"\" border=\"0\">",
"<i>",
"</i>",
"",
"",
"<b>",
"</b>",
"<u>",
"</u>"
);
$bbc_b = array(
"<a href='",
"'>Link</a>",
"<strong>&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><div style='overflow:auto; width:450px'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px dashed #000000;'><tr><td><b>CODE:</b></td></tr></table></strong><div style=\"margin:0px 5px;padding:5px;border:1px dashed #000000;width:90%; overflow:auto; width:90%\"></em>",
"</em></div>",
"<img src='",
"'>",
"<i>",
"</i>",
"<strike>",
"</strike>",
"<b>",
"</b>",
"<u>",
"</u>"
);

$bbc_num = count( $bbc_a );
$loop = 0;
while( $loop<$bbc_num )
{
$bbcode=str_replace( $bbc_a[$loop], $bbc_b[$loop], $bbcode );
$loop++;
}
return $bbcode;
}
?>

Ini
17-06-2007, 03:33 PM
Yay! finally lmao!! +rep

Also could you tell me wth is wrong with:



$fetch2 = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$_GET[id]' ORDER BY DESC");
while ($thread = mysql_fetch_array($fetch2))
{
$threadtitle = "$thread[title]";
$bbctt1 = BBCODE($threadtitle);

if($thread[sticky] == Yes)


Is really annoying.

The error is get is:




Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/thirty/public_html/users/forum.php on line 63



Line 63:



while ($thread = mysql_fetch_array($fetch2))



Thanks

Blob
17-06-2007, 03:53 PM
$fetch2 = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '{$_GET[id]}' ORDER BY `id` DESC");

?

Invent
17-06-2007, 03:55 PM
Maybe because there is no thread with that ID?..So the mysql_fetch_array() has nothing to fetch.

Ini
17-06-2007, 03:58 PM
i have made loads of threads and they are all in the DB, but they aren't showing ;l

Blob it worked but it only shows the first one and not the rest.

Blob
17-06-2007, 04:09 PM
i have made loads of threads and they are all in the DB, but they aren't showing ;l

Blob it worked but it only shows the first one and not the rest.

Isnt the id supposed to be unique so no other one will have it?

Ini
17-06-2007, 04:13 PM
Yes and when you add a new thread it inserts it into the database with a new id but for some reason it will only display the first one in each.


EDIT: Yeah i no what you mean.

I have serious coded this forum all wrong lol

think i will just scrap it

Blob
17-06-2007, 04:24 PM
$fetch2 = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '{$_GET[id]}'");

Ini
17-06-2007, 04:42 PM
Nope don't work ;[

This is the only problem i have the category's work and so do posts.

Want to hide these adverts? Register an account for free!