alan2010 Posted October 9, 2010 Share Posted October 9, 2010 Good day, I have a php code and it is showing error at line 111, do not know what to do, because I revised the code several times. Please if anyone knows where the mistake is there post your answer. Thank you all! <?php define(IS_INSTALLPAGE,TRUE); require_once('functions.inc.php'); if(INSTALLED){ header('Location: ./'); exit; } $page_title = $config->get('title').' : '._('Installation'); $no_phpfotologhead = TRUE; require_once('head_html.inc.php'); ?> <h1><?=_('Install phpFotolog');?></h1> <? if(is_writable('./')){ touch(INSTALL_LOCK_FILE); define(INSTALLED,FALSE); }else{ print "<p class=\"error\">"._('The phpfotolog directory is not writable. Please give the necessary permissions.')."</p>"; $pref_errors['directory'] = 1; } if($submit_install){ if(!$dbprefs['host']) $db_errors['host'] = _('You must enter a valid database host.'); if(!$dbprefs['name']) $db_errors['name'] = _('You must enter a valid database name.'); if(!$dbprefs['user']) $db_errors['user'] = _('You must enter a valid user name.'); if(!$prefs['title']) $pref_errors['title'] = _('You must enter a fotolog title.'); if(!$prefs['author']) $pref_errors['author'] = _('You must enter a fotolog author.'); if(!$prefs['username']) $pref_errors['username'] = _('You must enter a fotolog username.'); if(!$prefs['password']) $pref_errors['password'] = _('You must enter a fotolog password.'); else if($prefs['password'] != $prefs['password2']) $pref_errors['password'] = _('Password does not match confirmation.'); else if(strlen($prefs['password'])<6) $pref_errors['password'] = _('Password is too short.'); else if(!preg_match('/[a-zA-Z]/',$prefs['password']) || !preg_match('/[0-9]/',$prefs['password'])) $pref_errors['password'] = _('Password is too easy.'); if(!$db_errors && !$pref_errors){ // comprueba si existe la base de datos $db = new db($dbprefs['host'],$dbprefs['user'],$dbprefs['pass']); if($db->link){ $db->list_dbs(); if(!in_array($dbprefs['name'],$db->result)){ print sprintf(_('Database %s not found, trying to create...'),$dbprefs['name'])."<br/>\n"; $db->query("CREATE DATABASE `".$dbprefs['name']."`"); $db->list_dbs(); if(!in_array($dbprefs['name'],$db->result)){ $pref_errors['general'] = _('There was a problem creating the database.'); $pref_errors['general'] .= _('Check if the user has the correct permissions.'); } } }else{ $pref_errors['general'] = _('Could not connect to the selected server.'); $pref_errors['general'] .= _('Please check database username and password.')."<br/>\n"; } } if(!$db_errors && !$pref_errors){ // intenta conectar a la base de datos $db = new db($dbprefs['host'],$dbprefs['user'],$dbprefs['pass'],$dbprefs['name']); if(!$db->link){ $pref_errors['general'] = _('Could not connect to the selected database.'); $pref_errors['general'] .= _('Please check database settings.')."<br/>\n"; } } if(!$db_errors && !$pref_errors){ // crea el directorio de fotos print _('Creating photo directory...')."<br/>\n"; if(file_exists($prefs['fotosdir'])){ if(is_dir($prefs['fotosdir'])){ if(!is_writable($prefs['fotosdir'])){ $pref_errors['general'] = _('There was a problem creating the foto directory'); $pref_errors['general'] .= _('The foto direcotry exists but is not writable.'); } }else{ $pref_errors['general'] = _('There was a problem creating the foto directory'); $pref_errors['general'] .= _('There is a file with the same name as the foto direcotry.'); } }else{ if(mkdir($prefs['fotosdir'])){ chmod($prefs['fotosdir'],0775); }else{ $pref_errors['general'] = _('There was a problem creating the foto directory'); $pref_errors['general'] .= _('Check if the webserver has the necessary permissions.'); } } } if(!$db_errors && !$pref_errors){ // escribiendo fichero de configuración print _('Writing database configuration file db_config.inc.php...')."<br/>\n"; $filename = './db_config.inc.php'; $file = "<?php define(DB_HOST,'".$dbprefs['host']."'); define(DB_NAME,'".$dbprefs['name']."'); define(DB_USER,'".$dbprefs['user']."'); define(DB_PASS,'".$dbprefs['pass']."'); ?>"; $fh = @fopen($filename,'w'); if($fh){ fwrite($fh,$file); fclose($fh); }else{ $pref_errors['general'] = _('There was a problem creating the database configuration file'); $pref_errors['general'] .= _('Check if the webserver has the necessary permissions.'); } } if(!$db_errors && !$pref_errors){ // conecta y carga las tablas print _('Connecting to the database and creating tables...')."<br/>\n"; $fh = fopen('phpfotolog.sql','r'); if($fh){ $sql = fread($fh,2048); fclose($fh); $db->query($sql); print $db->error(); }else{ $pref_errors['general'] = _('There was a problem reading the database structure file'); $pref_errors['general'] .= _('Check if phpfotolog.sql exists.'); } } if(!$db_errors && !$pref_errors){ print _('Writing configuration to database...')."<br/>\n"; $config = new config(); $admin = new admin(); $admin->register($prefs['username'],$prefs['password']); unset($prefs['username'],$prefs['password'],$prefs['password2']); $config->set($prefs); } if(!$db_errors && !$pref_errors){ print _('Removing install lock...')."<br/>\n"; unlink(INSTALL_LOCK_FILE); print _('phpfotolog installed!')."<br/>\n"; print _('Remember to restore original phpfotolog directory permisions and to delete install.php')."<br/>\n"; printf(_('Now <a href="%s">upload</a> your first photo.'),'./upload.php'); print "</body>\n</html>"; exit; } }else{ $dbprefs = array( 'host' => 'localhost', 'name' => 'phpfotolog', 'user' => 'root', 'pass' => '' ); $prefs = $config->get('title','author','username','locale','fotosdir','fotosurl'); } ?> <?=($pref_errors['general'])?('<div class="error">'.$pref_errors['general'].'</div>')'');?> <form method="post"> <h2>Database configuration</h2> <table id="installdatabase"> <tr><th><?=_('Server name');?></th><td> <?=($db_errors['host'])?('<div class="error">'.$db_errors['host'].'</div>')'');?> <input type="text" name="dbprefs[host]" value="<?=$dbprefs['host'];?>" size="30"/> </td></tr> <tr><th><?=_('Database name');?></th><td> <?=($db_errors['name'])?('<div class="error">'.$db_errors['name'].'</div>')'');?> <input type="text" name="dbprefs[name]" value="<?=$dbprefs['name'];?>" size="30"/> </td></tr> <tr><th><?=_('Database username');?></th><td> <?=($db_errors['user'])?('<div class="error">'.$db_errors['user'].'</div>')'');?> <input type="text" name="dbprefs[user]" value="<?=$dbprefs['user'];?>" size="30"/> </td></tr> <tr><th><?=_('Database password');?></th><td> <input type="password" name="dbprefs[pass]" size="30"/> </td></tr> </table> <br/> <h2>Fotolog configuration</h2> <table id="installfotolog"> <tr><th><?=_('Title');?></th><td> <?=($pref_errors['title'])?('<div class="error">'.$pref_errors['title'].'</div>')'');?> <input type="text" name="prefs[title]" value="<?=$prefs['title'];?>" size="30"/> </td></tr> <tr><th><?=_('Author');?></th><td> <?=($pref_errors['author'])?('<div class="error">'.$pref_errors['author'].'</div>')'');?> <input type="text" name="prefs[author]" value="<?=$prefs['author'];?>"/> </td></tr> <tr><th><?=_('Username');?></th><td> <?=($pref_errors['username'])?('<div class="error">'.$pref_errors['username'].'</div>')'');?> <input type="text" name="prefs[username]" value="<?=$prefs['username'];?>"/> </td></tr> <tr><th><?=_('Password');?></th><td> <?=($pref_errors['password'])?('<div class="error">'.$pref_errors['password'].'</div>')'');?> <input type="password" name="prefs[password]" /> </td></tr> <tr><th><?=_('Confirm password');?></th><td> <input type="password" name="prefs[password2]" /> </td></tr> <tr><th><?=_('Locale');?></th><td> <?=locale_select($prefs['locale'],'prefs');?> </td></tr> <tr><th><?=_('Fotos dir');?></th><td> <?=($pref_errors['fotosdir'])?('<div class="error">'.$pref_errors['fotosdir'].'</div>')'');?> <input type="text" name="prefs[fotosdir]" value="<?=$prefs['fotosdir'];?>"/> </td></tr> <tr><th><?=_('Fotos url');?></th><td> <?=($pref_errors['fotosurl'])?('<div class="error">'.$pref_errors['fotosurl'].'</div>')'');?> <input type="text" name="prefs[fotosurl]" value="<?=$prefs['fotosurl'];?>"/> </td></tr> </table> <input type="submit" name="submit_install" value="Install" /> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
frizi Posted October 9, 2010 Share Posted October 9, 2010 It would definitively help to see the concrete error message but as far I see there should not be any error there. just wondering what does the print _() do. Shouldn't be print_r(); or so? (I might not know such usage, sorry if so :] ). Quote Link to comment Share on other sites More sharing options...
alan2010 Posted October 9, 2010 Author Share Posted October 9, 2010 hello, now the error on line 122 (Parse error: parse error in C:\wamp\www\foto\install.php on line 122) :'(. what to do? I want to step to analyze the code for you? He is a php script to install a fotolog! Quote Link to comment Share on other sites More sharing options...
frizi Posted October 12, 2010 Share Posted October 12, 2010 It might be unknown for me but what is the _ doing before the () and printf ? Try to comment som parts of the code for instance the 122 line and see if there will be the next line with error. If so the problem is in a row before the 122. Try netbeams or Eclipse to see if the code is OK. Quote Link to comment 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.