mortalc Posted June 28, 2010 Share Posted June 28, 2010 SOmething went wrong on this line: if (isset($_POST['name'])) file_put_contents("Position.htm", "<div id=\"$_POST['name']\">"."<h3>".$_POST["name"]."</h3>"."</div>"."<small>".Date("d.M.Y", "H:i:s")."</small>"."<br />".$_POST["reply"]."<br />"); Link to comment Share on other sites More sharing options...
boen_robot Posted June 28, 2010 Share Posted June 28, 2010 What is "something" supposed to mean? The actual error message? The code around this line of code? If it's a parse error, it's usually not at the place of the error, but somewhere around it. Link to comment Share on other sites More sharing options...
23.12.2012 Posted June 28, 2010 Share Posted June 28, 2010 I suspect a problem with the date() function. The second argument does not look legit. But I could be wrong. Link to comment Share on other sites More sharing options...
wirehopper Posted June 28, 2010 Share Posted June 28, 2010 date should also be lowercase Link to comment Share on other sites More sharing options...
RobberBaron Posted June 28, 2010 Share Posted June 28, 2010 Can you give us the exact error details?I would also do it something more like this: if (isset($_POST['name'])) { file_put_contents('Position.htm', '<div id="'.$_POST['name'].'><h3>'.$_POST['name'].'</h3></div><br /><small>'.date('d.M.Y', 'H:i:s').'</small><br />'.$_POST['reply'].'<br />');}; Link to comment Share on other sites More sharing options...
23.12.2012 Posted June 28, 2010 Share Posted June 28, 2010 date should also be lowercaseFunctions are case-insensitive in PHP. I'm thinking more and more that the second argument of the date() function is illegal, but another, less likely problem would be the lack of writing permissions for Position.htm Link to comment Share on other sites More sharing options...
End User Posted June 29, 2010 Share Posted June 29, 2010 Yep, the second parameter in date() shouldn't have any quotes around it. Try:date('d.M.Y', H:i:s) Functions are case-insensitive in PHP. I'm thinking more and more that the second argument of the date() function is illegal, but another, less likely problem would be the lack of writing permissions for Position.htm Link to comment Share on other sites More sharing options...
Synook Posted June 29, 2010 Share Posted June 29, 2010 Err, the second parameter in date() should be a valid UNIX timestamp, not some string.P.S. it is never valid to write a string literal without quotes. Link to comment Share on other sites More sharing options...
mortalc Posted June 29, 2010 Author Share Posted June 29, 2010 Here is the error message: PHP Error Message Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a3312652/public_html/Position.php on line 34Will try suggested fixes now.Ed::faceslap:It should have been if $_POST['reply'] is set....Nope, something is still wrong.Wait - RobberBaron used {}. I thought they weren't used in PHP?Ed 2:Monster faceslap! I've just checked, and I never uploaded position.htm! Link to comment Share on other sites More sharing options...
23.12.2012 Posted June 29, 2010 Share Posted June 29, 2010 I would also do it something more like this:if (isset($_POST['name'])) { file_put_contents('Position.htm', '<div id="'.$_POST['name'].'><h3>'.$_POST['name'].'</h3></div><br /><small>'.date('d.M.Y', 'H:i:s').'</small><br />'.$_POST['reply'].'<br />');}; One error in your code: you do not put a semi-colon after a curly brace.Here is the error message:Wait - RobberBaron used {}. I thought they weren't used in PHP?Ed 2:Monster faceslap! I've just checked, and I never uploaded position.htm!Of course the curly braces are used in PHP, but they are only required in compound statements. Yours wasn't one. Although not uploading the file would throw an error, the specified one is not related to this. Do check the manual for date. Link to comment Share on other sites More sharing options...
jeffman Posted June 29, 2010 Share Posted June 29, 2010 file_put_contents will create the file if it does not exist.The date function is certainly used incorrectly.As you can tell, trying to debug a long concatenated string with embedded function calls is PITA. Terse code is neither required nor generally useful in this environment. You have plenty of RAM and HD space. Use it.I strongly suggest building this string in multiple statements. Assign it to a variable, and pass the variable to file_put_contents. In addition, assign the return value of date() to a variable before adding it to the data string. Being able to var_dump variables is essential to debugging, as is the ability to comment out lines of code to see which ones are broken. Link to comment Share on other sites More sharing options...
End User Posted June 29, 2010 Share Posted June 29, 2010 Err, the second parameter in date() should be a valid UNIX timestamp, not some string.You're absolutely right, I was mixed up there and goofed it up. It should either be a timestamp or an equivalent, or nothing (which will default to the current time). It would be something like: date('d.M.Y H:i:s') or date('d.M.Y H:i:s', $some_timestamp) Link to comment Share on other sites More sharing options...
justsomeguy Posted June 29, 2010 Share Posted June 29, 2010 One error in your code: you do not put a semi-colon after a curly brace.That's not an error, it just translates to a "noop" (no operation). It's basically just a waste of time for PHP, but it's not an error. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.