Jump to content

Recommended Posts

Hey all,

 

Should be relatively easy, but my brain is fizzled at the moment, so I can't see the issue here.

 

I'm putting a >> on the lines in question.

 

<?php
include("functions.php");
if (isset($_POST['title'])) {
	//set vars
	$title = $_POST['title'];
	$description = $_POST['description'];
	$keywords = $_POST['keywords'];
	$adsense_bar = base64_encode($_POST['adsense-bar']);
	$adsense_box = base64_encode($_POST['adsense-box']);
	$adsense_square = base64_encode($_POST['adsense-square']);
	$article_title = $_POST['article-tite'];
	$article_content = base64_encode($_POST['article-content']);

	//edit file
	$xml -> title = $title;
	$xml -> description = $description;
	$xml -> keywords = $keywords;
	>>$xml -> adsense-bar = $adsense_bar;
	>>$xml -> adsense-box = $adsense_box;
	>>$xml -> adsense-square = $adsense_square;
	$xml -> article -> title = $article_title;
	$xml -> article -> body = $article_content;

	//save file
	file_put_contents('data.xml', $xml->asXml());
}

header("Location: admin.php");
?>

 

When running those lines, I'm getting this error.

 

Parse error: parse error in C:\wamp\www\one-click-cms\action.php on line 18

 

Of course the script breaks at that point and goes no further. If I comment out line 18, line 19 spouts the error. Again for 20.

 

Any idea what could be causing this?

 

(And yes - I should be doing this in OO, but this is a quick run through to make sure I can get everything to work before real production)

PHP class property names cannot contain the hyphen character (-) like that. Ideally you can use an underscore instead though this will obviously change the names in your XML. 

 

$xml->adsense_bar = $adsense_bar;
$xml->adsense_box = $adsense_box;
$xml->adsense_square = $adsense_square;

 

If you really want to use hyphens then you can do (but it isn't advised):

 

$xml->{'adsense-bar'} = $adsense_bar;
$xml->{'adsense-box'} = $adsense_box;
$xml->{'adsense-square'} = $adsense_square;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.