PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
danharibo
Forum Commoner
Posts: 76 Joined: Thu Aug 17, 2006 8:56 am
Post
by danharibo » Tue Sep 12, 2006 10:58 am
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
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue Sep 12, 2006 11:02 am
take the semi-colon off this line
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Tue Sep 12, 2006 11:02 am
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.
danharibo
Forum Commoner
Posts: 76 Joined: Thu Aug 17, 2006 8:56 am
Post
by danharibo » Tue Sep 12, 2006 11:23 am
Now its not Changing
to <img....>
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Tue Sep 12, 2006 11:36 am
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 ');
?>
danharibo
Forum Commoner
Posts: 76 Joined: Thu Aug 17, 2006 8:56 am
Post
by danharibo » Tue Sep 12, 2006 11:39 am
that worked
danharibo
Forum Commoner
Posts: 76 Joined: Thu Aug 17, 2006 8:56 am
Post
by danharibo » Tue Sep 12, 2006 11:42 am
But the Main String won't Print it
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Tue Sep 12, 2006 11:43 am
danharibo wrote: But the Main String won't Print it
Explain further.
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Tue Sep 12, 2006 11:55 am
I thought it worked?
What are you doing differently there to the example I gave you?
danharibo
Forum Commoner
Posts: 76 Joined: Thu Aug 17, 2006 8:56 am
Post
by danharibo » Tue Sep 12, 2006 12:00 pm
ptinting it FROM another file?
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Tue Sep 12, 2006 12:01 pm
Printing what from another file? I don't understand.
Show your full code.
danharibo
Forum Commoner
Posts: 76 Joined: Thu Aug 17, 2006 8:56 am
Post
by danharibo » Tue Sep 12, 2006 12:08 pm
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);
}
?>
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Tue Sep 12, 2006 12:27 pm
I presume your addbbcode function actually has
in it rather than
?
danharibo
Forum Commoner
Posts: 76 Joined: Thu Aug 17, 2006 8:56 am
Post
by danharibo » Tue Sep 12, 2006 12:29 pm
Still won't work