Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Directory Submission Service   I Sell Pagerank   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 11-24-2006, 11:12 PM   #1 (permalink)
Inactive
 
Join Date: 01-05-04
Location: Detroit
Posts: 166
iTrader: 0 / 0%
Latest Blog:
None

al2six is liked by somebodyal2six is liked by somebodyal2six is liked by somebody
Using Brackets in PHP

I'm modifying the news script for my site to also add the article to my forum. I'm trying to use bbcodes to format the body of the post, but I keep getting parse errors. I have something like the following:

Code:
$post="[ b ]Heading[/ b ] Article";
Every time i get this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

I figured out that if i have [tag] it works fine. but then as soon as i add the closing tag ([/tag]) i get the error. any ideas how i can fix this?
al2six is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 11-25-2006, 12:29 AM   #2 (permalink)
Contributing Member
 
Join Date: 07-08-06
Location: Here
Posts: 236
iTrader: 0 / 0%
Latest Blog:
None

daboss is a jewel in the roughdaboss is a jewel in the roughdaboss is a jewel in the roughdaboss is a jewel in the roughdaboss is a jewel in the roughdaboss is a jewel in the rough
try this before you insert/update the database:

$post = mysql_real_escape_string($post);
daboss is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-27-2006, 11:14 AM   #3 (permalink)
Contributing Member
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,067
iTrader: 0 / 0%
Latest Blog:
Moved In!

Izzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to behold
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Why does the bbcode have spaces in it?

Also,
do this:
PHP Code:
$post addslashes($post); 
This will add the necessary escape slashes you will need. Because, instead of it being [ /b], it should be [ //b]
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-27-2006, 11:56 AM   #4 (permalink)
Contributing Member
 
DragonEye's Avatar
 
Join Date: 10-13-03
Location: Belgium
Posts: 322
iTrader: 0 / 0%
Latest Blog:
None

DragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebody
Send a message via MSN to DragonEye
hmmm,

maybe: $post="[ b ]Heading[\/ b ] Article";

could work...?

Strange error message, are you sure that that is the cause of the error?

Matt.
DragonEye is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-28-2006, 01:08 PM   #5 (permalink)
Inactive
 
Join Date: 11-27-06
Location: California
Posts: 37
iTrader: 0 / 0%
Latest Blog:
None

Shockt is liked by many
Send a message via AIM to Shockt Send a message via MSN to Shockt
Quote:
Originally Posted by Izzmo View Post
...instead of it being [ /b], it should be [ //b]
It actually should be [\/b], since \ is the escape character.

But as others above have suggested, try addslashes($post). Then when you are ready to output the information, remember to stripslashes($post).
Shockt is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-28-2006, 07:47 PM   #6 (permalink)
Contributing Member
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,067
iTrader: 0 / 0%
Latest Blog:
Moved In!

Izzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to behold
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
oh doy! lol, I was off doing something when I wrote this lol.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-28-2006, 07:54 PM   #7 (permalink)
Inactive
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 678
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
It's something else. Can you post the actual code for that particular function and, maybe, specify some character that you are using in your post to get around the forum programming? (i.e. [ b ] uses space chars to get around the automatic bolding functions.) I mention "something else" because of "T_ENCAPSED_AND_WHITESPACE".

A forward slash shouldn't break that particular variable.

Last edited by StupidScript : 11-28-2006 at 08:00 PM.
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-28-2006, 08:36 PM   #8 (permalink)
Technical Support
 
Paul M's Avatar
 
Join Date: 12-14-05
Posts: 128
iTrader: 0 / 0%
Paul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of light
I believe it should work fine if you used single quotes to enclose it ;

PHP Code:
$post='[b]Heading[/b] Article'
Paul M is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 01:38 PM.
© Copyright 2008 V7 Inc

Click Here