Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Old 11-25-2006, 12:12 AM   #1 (permalink)
Senior Member
 
Join Date: 01-05-04
Location: Detroit
Posts: 146
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
Old 11-25-2006, 01:29 AM   #2 (permalink)
Contributing Member
 
Join Date: 07-08-06
Location: Here
Posts: 189
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, 12:14 PM   #3 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
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, 12:56 PM   #4 (permalink)
Senior Member
 
DragonEye's Avatar
 
Join Date: 10-13-03
Location: Belgium
Posts: 231
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, 02:08 PM   #5 (permalink)
Member
 
Shockt's Avatar
 
Join Date: 11-27-06
Location: California
Posts: 32
iTrader: 0 / 0%
Latest Blog:
None

Shockt is liked by many
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, 08:47 PM   #6 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
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, 08:54 PM   #7 (permalink)
Senior Member
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 663
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 09:00 PM..
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-28-2006, 09:36 PM   #8 (permalink)
v7n Mentor
 
Paul M's Avatar
 
Join Date: 12-14-05
Posts: 73
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 > 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

BB 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! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 07:40 AM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.