shockyz Posted November 7, 2009 Share Posted November 7, 2009 Please help! :/ I got this generator file (http://www.sto-posto-zabava.com/generate_pages.php) which has some problem in code. It shows an error: Parse error: syntax error, unexpected T_LNUMBER in /home/spzabava/public_html/generate_pages.php on line 32 <?php require "cs_config.php"; require DIR_VICEVI."includes/class.db.php"; require DIR_VICEVI."includes/functions.php"; $search = array("\""); $replace = array("''"); $db = new db; $db->connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $sql=$db->query(" SELECT content FROM ".TABLE_CONTENT_VICEVI." WHERE active=1 AND active_date<=NOW() AND mark=NOW() LIMIT 1" ); if ($db->num_rows($sql)==0) { $sql=$db->query(" SELECT content FROM ".TABLE_CONTENT_VICEVI." WHERE active=1 AND mark<=NOW() ORDER BY mark DESC LIMIT 1" ); } $sqldata=$db->fetch_array($sql); $vic_dana='document.write("'.nl2brStrict(utf2html(str_replace($search, $replace, $sqldata['content']))).'<br>[<a target=_blank title='100% Zabava - Vicevi - Zanimljivosti - Vesti - Video Klipovi - Tekstovi - Forum - Chat - Ankete' href=http://www.sto-posto-zabava.com>100% Zabava</a>]");'; $fp = fopen("vic.js", "wb"); fwrite($fp, $vic_dana); fclose($fp); $sql=$db->query(" SELECT content FROM ".TABLE_CONTENT_ZANIMLJIVOSTI." WHERE active=1 AND active_date<=NOW() ORDER BY date_time DESC LIMIT 1" ); $sqldata=$db->fetch_array($sql); $zanimljivost='document.write("'.nl2brStrict(utf2html(str_replace($search, $replace, $sqldata['content']))).'<br>[<a target=_blank title='100% Zabava - Vicevi - Zanimljivosti - Vesti - Video Klipovi - Tekstovi - Forum - Chat - Ankete' href=http://www.sto-posto-zabava.com>100% Zabava</a>]");'; $fp = fopen("zanimljivost.js", "wb"); fwrite($fp, $zanimljivost); fclose($fp); $sql=$db->query(" SELECT id, title, name, content, date_time FROM ".TABLE_CONTENT_VESTI." WHERE active=1 ORDER BY date_time DESC LIMIT 1" ); $sqldata=$db->fetch_array($sql); $sqldata['content'] = utf2html(str_replace($search, $replace, $sqldata['content'])); $pos = strpos($sqldata['content'], "\r\n\r\n"); if ($pos!==false) $sqldata['content']=substr($sqldata['content'], 0, $pos).' <a href=http://zanimljive-vesti.sto-posto-zabava.com/comments.php?cid=1&cnt='.$sqldata['id'].' title='Nastavak zanimljive vesti' target=_blank>dalje>>></a>'; $datum=full_date($sqldata['date_time']); $title=$sqldata['title']; $izvor='Izvor: '.$sqldata['name']; $vest='document.write("'.nl2brStrict(utf2html(str_replace($search, $replace, $datum.'.<br>'.$izvor.'<br><b>'.$title.'</b><br><br>')).$sqldata['content']).'");'; $fp = fopen("vest.js", "wb"); fwrite($fp, $vest); fclose($fp); function nl2brStrict($text, $replacement = '<br>') { return preg_replace("((\r\n)+)", trim($replacement), $text); } ?> Can someone please take a look and help me with this, I'd appreciate it... Link to comment https://forums.phpfreaks.com/topic/180674-parse-error/ Share on other sites More sharing options...
Mchl Posted November 7, 2009 Share Posted November 7, 2009 http://www.php.net/manual/en/language.types.string.php To specify a literal single quote, escape it with a backslash (\). To specify a literal backslash before a single quote, or at the end of the string, double it (\\). Note that attempting to escape any other character will print the backslash too. Link to comment https://forums.phpfreaks.com/topic/180674-parse-error/#findComment-953217 Share on other sites More sharing options...
shockyz Posted November 7, 2009 Author Share Posted November 7, 2009 Does it mean that I simply need to replace every " character with \? I messed up the code a bit somehow, but don't remember code not containing " at all... Link to comment https://forums.phpfreaks.com/topic/180674-parse-error/#findComment-953228 Share on other sites More sharing options...
Mchl Posted November 7, 2009 Share Posted November 7, 2009 Your string is delimited with ' (single quotes) If you want to use single quotes within this string, you have to add \ before them, like this: $vic_dana='document.write("'.nl2brStrict(utf2html(str_replace($search, $replace, $sqldata['content']))).'<br>[<a target=_blank title=\'100% Zabava - Vicevi - Zanimljivosti - Vesti - Video Klipovi - Tekstovi - Forum - Chat - Ankete\' href=http://www.sto-posto-zabava.com>100% Zabava</a>]");'; Link to comment https://forums.phpfreaks.com/topic/180674-parse-error/#findComment-953240 Share on other sites More sharing options...
shockyz Posted November 7, 2009 Author Share Posted November 7, 2009 Thanx for ur answers! Now that I placed \ in front of ' I got these error messages: Warning: fopen(vic.js): failed to open stream: Permission denied in /home/spzabava/public_html/generate_pages.php on line 34 Warning: fwrite(): supplied argument is not a valid stream resource in /home/spzabava/public_html/generate_pages.php on line 35 Warning: fclose(): supplied argument is not a valid stream resource in /home/spzabava/public_html/generate_pages.php on line 36 Warning: fopen(zanimljivost.js): failed to open stream: Permission denied in /home/spzabava/public_html/generate_pages.php on line 50 Warning: fwrite(): supplied argument is not a valid stream resource in /home/spzabava/public_html/generate_pages.php on line 51 Warning: fclose(): supplied argument is not a valid stream resource in /home/spzabava/public_html/generate_pages.php on line 52 Warning: fopen(vest.js): failed to open stream: Permission denied in /home/spzabava/public_html/generate_pages.php on line 74 Warning: fwrite(): supplied argument is not a valid stream resource in /home/spzabava/public_html/generate_pages.php on line 75 Warning: fclose(): supplied argument is not a valid stream resource in /home/spzabava/public_html/generate_pages.php on line 76 Code is now: <?php require "cs_config.php"; require DIR_VICEVI."includes/class.db.php"; require DIR_VICEVI."includes/functions.php"; $search = array("\""); $replace = array("''"); $db = new db; $db->connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $sql=$db->query(" SELECT content FROM ".TABLE_CONTENT_VICEVI." WHERE active=1 AND active_date<=NOW() AND mark=NOW() LIMIT 1" ); if ($db->num_rows($sql)==0) { $sql=$db->query(" SELECT content FROM ".TABLE_CONTENT_VICEVI." WHERE active=1 AND mark<=NOW() ORDER BY mark DESC LIMIT 1" ); } $sqldata=$db->fetch_array($sql); $vic_dana='document.write("'.nl2brStrict(utf2html(str_replace($search, $replace, $sqldata['content']))).'<br>[<a target=_blank title=\'100% Zabava - Vicevi - Zanimljivosti - Vesti - Video Klipovi - Tekstovi - Forum - Chat - Ankete\' href=http://www.sto-posto-zabava.com>100% Zabava</a>]");'; $fp = fopen("vic.js", "wb"); fwrite($fp, $vic_dana); fclose($fp); $sql=$db->query(" SELECT content FROM ".TABLE_CONTENT_ZANIMLJIVOSTI." WHERE active=1 AND active_date<=NOW() ORDER BY date_time DESC LIMIT 1" ); $sqldata=$db->fetch_array($sql); $zanimljivost='document.write("'.nl2brStrict(utf2html(str_replace($search, $replace, $sqldata['content']))).'<br>[<a target=_blank title=\'100% Zabava - Vicevi - Zanimljivosti - Vesti - Video Klipovi - Tekstovi - Forum - Chat - Ankete\' href=http://www.sto-posto-zabava.com>100% Zabava</a>]");'; $fp = fopen("zanimljivost.js", "wb"); fwrite($fp, $zanimljivost); fclose($fp); $sql=$db->query(" SELECT id, title, name, content, date_time FROM ".TABLE_CONTENT_VESTI." WHERE active=1 ORDER BY date_time DESC LIMIT 1" ); $sqldata=$db->fetch_array($sql); $sqldata['content'] = utf2html(str_replace($search, $replace, $sqldata['content'])); $pos = strpos($sqldata['content'], "\r\n\r\n"); if ($pos!==false) $sqldata['content']=substr($sqldata['content'], 0, $pos).' <a href=http://zanimljive-vesti.sto-posto-zabava.com/comments.php?cid=1&cnt='.$sqldata['id'].' title=\'Nastavak zanimljive vesti\' target=_blank>dalje>>></a>'; $datum=full_date($sqldata['date_time']); $title=$sqldata['title']; $izvor='Izvor: '.$sqldata['name']; $vest='document.write("'.nl2brStrict(utf2html(str_replace($search, $replace, $datum.'.<br>'.$izvor.'<br><b>'.$title.'</b><br><br>')).$sqldata['content']).'");'; $fp = fopen("vest.js", "wb"); fwrite($fp, $vest); fclose($fp); function nl2brStrict($text, $replacement = '<br>') { return preg_replace("((\r\n)+)", trim($replacement), $text); } ?> Link to comment https://forums.phpfreaks.com/topic/180674-parse-error/#findComment-953250 Share on other sites More sharing options...
Mchl Posted November 7, 2009 Share Posted November 7, 2009 You must should check if PHP has write permissions to the folder you're running the script in. Link to comment https://forums.phpfreaks.com/topic/180674-parse-error/#findComment-953257 Share on other sites More sharing options...
shockyz Posted November 7, 2009 Author Share Posted November 7, 2009 I'm not sure what is the thing you're asking me about, but I guess it has, because it all worked fine untill I started making small changes in generate_pages.php file, and 3 .js files it affects... Link to comment https://forums.phpfreaks.com/topic/180674-parse-error/#findComment-953265 Share on other sites More sharing options...
Mchl Posted November 7, 2009 Share Posted November 7, 2009 Again from manual: If you are experiencing problems with reading and writing to files and you're using the server module version of PHP, remember to make sure that the files and directories you're using are accessible to the server process. Link to comment https://forums.phpfreaks.com/topic/180674-parse-error/#findComment-953295 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.