Page 1 of 2
Simple Smiles Not so simple
Posted: Tue Sep 12, 2006 10:58 am
by danharibo
My Code to Change : ) to

isnt working to good :/
Code: Select all
<?
function addbbcode ($vartoproc);
{
$Procstringsmile = str_replace(':)', '<img src="./image/smile.gif">', $vartoproc);
return $Procstringsile;
}
?>
Parse error: parse error, expecting `'{'' in c:\program files\easyphp1-8\www\sufsite\function\bb_code.php on line 2
What am i doing wrong this time

Edit I just noticed One problems thank to your php Tags

Posted: Tue Sep 12, 2006 11:02 am
by JayBird
take the semi-colon off this line
Posted: Tue Sep 12, 2006 11:02 am
by jayshields
Code: Select all
<?php
function addbbcode ($vartoproc)
{
$Procstringsmile = str_replace(':)', '<img src="./image/smile.gif">', $vartoproc);
return $Procstringsmile;
}
?>
Fixed short tags. Fixed semi colon on line 1. Fixed variable spelling.
Posted: Tue Sep 12, 2006 11:23 am
by danharibo
Now its not Changing

to <img....>
Posted: Tue Sep 12, 2006 11:36 am
by jayshields
How do you know?
Run this and tell us the output
Code: Select all
<?php
function addbbcode($vartoproc) {
return str_replace(":)", '<img src="./image/smile.gif">', $vartoproc);
}
echo addbbcode('Hello ');
?>
Posted: Tue Sep 12, 2006 11:39 am
by danharibo
that worked

Posted: Tue Sep 12, 2006 11:42 am
by danharibo
But the Main String won't Print it

Posted: Tue Sep 12, 2006 11:43 am
by jayshields
danharibo wrote:But the Main String won't Print it

Explain further.
Posted: Tue Sep 12, 2006 11:49 am
by danharibo
look:
http://danharibo.dyndns.org/sufsite
It prints : ) instead of ./image/smile.gif
Posted: Tue Sep 12, 2006 11:55 am
by jayshields
I thought it worked?
What are you doing differently there to the example I gave you?
Posted: Tue Sep 12, 2006 12:00 pm
by danharibo
ptinting it FROM another file?
Posted: Tue Sep 12, 2006 12:01 pm
by jayshields
Printing what from another file? I don't understand.
Show your full code.
Posted: Tue Sep 12, 2006 12:08 pm
by danharibo
Index,php:
Code: Select all
<Head>
<Title>******</Title>
</Head>
<body bgcolor="#00000" TEXT="#fffff">
<? include('Header.php'); // Include Head file
include('./function/bb_code.php');
?>
<table Align="Left" >
<tr ALIGN="center"><td>Navigation</td></tr>
<tr ALIGN="center"><td>[<a href="./index.php">Home</a>]</td></tr>
</table>
<Table align="center" >
<Tr>
<td>
<?
if(isset($_GET['page']))
{
$page = $_GET['page'];
$page2 = str_replace('..', '', $page);
$temp= $page2.'.txt';
$page2 = $temp;
$fp = fopen($page2, 'r'); // Open Page .txt for reading from beginning
$read = fread($fp, '1000'); // Read from the file pointer
$output = addbbcode($read);
echo $output;
}
else{
$fp = fopen('index.txt', 'r'); // Open Page .txt for reading from beginning
$read = fread($fp, '1000'); // Read from the file pointer
print($read);
}
?>
</td>
</Tr>
</Table>
<center>
<? include('./Footer.php'); //Include the footer, to sav e us having to Change all the files Individualy
?>
bb_code.php:
Code: Select all
<?
function addbbcode($vartoproc) {
return str_replace("Smile", '<img src="./image/smile.gif">', $vartoproc);
}
?>
Posted: Tue Sep 12, 2006 12:27 pm
by jayshields
I presume your addbbcode function actually has
in it rather than
?
Posted: Tue Sep 12, 2006 12:29 pm
by danharibo
Still won't work