scheda Posted March 29, 2010 Share Posted March 29, 2010 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) Quote Link to comment https://forums.phpfreaks.com/topic/196834-simplexml-base64_encode-and-form-submission-issue/ Share on other sites More sharing options...
salathe Posted March 29, 2010 Share Posted March 29, 2010 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; Quote Link to comment https://forums.phpfreaks.com/topic/196834-simplexml-base64_encode-and-form-submission-issue/#findComment-1033423 Share on other sites More sharing options...
scheda Posted March 29, 2010 Author Share Posted March 29, 2010 Well, that would explain it then! Changing the XML is easy, so I'll just do that instead. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/196834-simplexml-base64_encode-and-form-submission-issue/#findComment-1033505 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.