0
<?
function outError($text){
		print "<center><b><font  color = red>$text</font></b><br><br></center>";
}
<option value="0"   <?= ($installtype == "0") ? "selected" : ""; ?> >Install with CPanel Info (can create  MySQL  DB  automatically)</option>

I have a script with such unusual tags and the script won't work. I cannot replace them since they are a thousands in number. And search and replace also didn't work.

thank you.

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by cwarn23
0

Hi gouthamvel and welcome to DaniWeb :)

I think we may need a bit more information to help you on this one. Can you please post the code for the select tag that this option tag is a part of? What do you mean by the script won't work? Does the page load? Is it just not displaying the options in the select? Are there any error messages? Is it the function that doesn't work as you would like and if so does anything happen when you call it?

0

I have attached one of the file. I am confused with <?php and <?. I got a parse error when <? was used and when I replaced it with <?php the error got away. I use php 5.x, apache 2.2

Attachments
<html>



<head>



 <title>RSS to Blog V4.5 :: Install</title>



</head>



<style>



 body, td  {



        background-color: #fff;



        font-family: Arial, Helvetica, sans-serif;



        font-size: 12px;



        font-weight: normal;







}



input {



   border: 1px solid black;



}



</style>



<body >



<center><h1><img width=650 height=125 src="images/rsstoblog-hd.jpg"></h1></center>



<?php





$mysqlserver = "localhost";

$ftpdir = dirname(__file__);

if (strpos($ftpdir, "/public_html"))

{

		$ftpdir = substr($ftpdir, strpos($ftpdir, "/public_html"));

}

else

{

		$ftpdir = "";

}

extract($_POST);

extract($_GET);

function printForm()

{

		global $mysqlserver;

		global $cpaneldom;

		global $cpaneluser;

		global $cpanelpwd;

		global $cpaneltheme;

		global $email;

		global $usemy;

		global $mysqldb;

		global $mysqlusername;

		global $mysqlpassword;

		global $ftpserver;

		global $ftpuser;

		global $ftppwd;

		global $ftpdir;

		global $installtype;

		if ($cpaneldom == "")

		{

				$cpaneldom = $_SERVER["HTTP_HOST"];

		}

		if ($ftpserver == "")

		{

				$ftpserver = $_SERVER["HTTP_HOST"];

		}











?>



<script>



 function myuseChange() {



    if (document.getElementById('usemy').checked) {



        document.getElementById('mydbnameTR').style.display = '';



        document.getElementById('myunameTR').style.display = '';



        document.getElementById('mypwdTR').style.display = '';







    }



    if (!document.getElementById('usemy').checked) {



        document.getElementById('mydbnameTR').style.display = 'none';



        document.getElementById('myunameTR').style.display = 'none';



        document.getElementById('mypwdTR').style.display = 'none';







    }



}







var oldcpanelch = <?php  ($usemy == "1") ? 'true' : 'false'; ?>;



function installtypeChange() {







    if (document.getElementById('installtype').value == 0) {



        document.getElementById('usemy').checked = oldcpanelch;



        myuseChange();







        document.getElementById('ftpserverTR').style.display = 'none';



        document.getElementById('ftpuserTR').style.display = 'none';



        document.getElementById('ftppwdTR').style.display = 'none';



        document.getElementById('ftpdirTR').style.display = 'none';







        document.getElementById('usemyTR').style.display = '';



        document.getElementById('cpaneldomTR').style.display = '';



        document.getElementById('cpaneluserTR').style.display = '';



        document.getElementById('cpanelpwdTR').style.display = '';



        document.getElementById('cpanelthemeTR').style.display = '';



    } else {



        oldcpanelch = document.getElementById('usemy').checked;



        document.getElementById('usemy').checked = true;



        myuseChange();







        document.getElementById('ftpserverTR').style.display = '';



        document.getElementById('ftpuserTR').style.display = '';



        document.getElementById('ftppwdTR').style.display = '';



        document.getElementById('ftpdirTR').style.display = '';







        document.getElementById('usemyTR').style.display = 'none';



        document.getElementById('cpaneldomTR').style.display = 'none';



        document.getElementById('cpaneluserTR').style.display = 'none';



        document.getElementById('cpanelpwdTR').style.display = 'none';



        document.getElementById('cpanelthemeTR').style.display = 'none';



    }











}







</script>







<form action="install.php" method="post" >



     <fieldlist>



     <TABLE align=center>







        <TR>



          <TD>Install Type</TD>



          <TD>



           <select name='installtype'  onChange="installtypeChange()"   id='installtype' >



            <option value="0"   <?php  ($installtype == "0") ? "selected" : ""; ?> >Install with CPanel Info (can create  MySQL  DB  automatically)</option>



            <option value="1"   <?php  ($installtype == "1") ? "selected" : ""; ?> >Install with FTP Info (can not create  MySQL  DB  automatically)</option>



           </select>



          </TD>



        </TR>







        <TR id="ftpserverTR" >



          <TD>FTP Server</TD>



          <TD><INPUT type=text size=57  name="ftpserver" value="<?php  $ftpserver ?>"></TD>



        </TR>



        <TR id="ftpuserTR" >



          <TD>FTP User</TD>



          <TD><INPUT type=text size=57  name="ftpuser" value="<?php  $ftpuser ?>"></TD>



        </TR>



        <TR id="ftppwdTR" >



          <TD>FTP Password</TD>



          <TD><INPUT type=text size=57  name="ftppwd" value="<?php  $ftppwd ?>"></TD>



        </TR>



        <TR id="ftpdirTR" >



          <TD>FTP Program Path</TD>



          <TD><INPUT type=text size=57  name="ftpdir" value="<?php  $ftpdir ?>"></TD>



        </TR>











        <TR id="cpaneldomTR" >



          <TD>CPanel domain</TD>



          <TD><INPUT type=text size=57  name="cpaneldom" value="<?php  $cpaneldom ?>"></TD>



        </TR>



        <TR id="cpaneluserTR" >



          <TD>CPanel User</TD>



          <TD><INPUT type=text size=57  name="cpaneluser" value="<?php  $cpaneluser ?>"></TD>



        </TR>



        <TR id="cpanelpwdTR" >



          <TD>CPanel Password</TD>



          <TD><INPUT type=text size=57  name="cpanelpwd" value="<?php  $cpanelpwd ?>"></TD>



        </TR>



        <TR id="cpanelthemeTR" >



          <TD>CPanel Theme</TD>



          <TD>



           <select name='cpaneltheme' >



            <option value="x"   <?php  ($cpaneltheme == "x") ? "selected" : ""; ?> >x</option>

            <option value="x2"  <?php  ($cpaneltheme == "x2") ? "selected" : ""; ?> >x2</option>

   <option value="seo_x"  <?php  ($cpaneltheme == "seo_x") ? "selected" : ""; ?> >seo_x</option>

            <option value="brand"  <?php  ($cpaneltheme == "brand") ? "selected" : ""; ?> >brand</option>

   <option value="rvlightteal"  <?php  ($cpaneltheme == "rvlightteal") ? "selected" : ""; ?> >rvlightteal</option>

           </select>



          </TD>



        </TR>







        <TR id="emailTR" >



          <TD>User e-mail</TD>



          <TD><INPUT type=text size=57  name="email" value="<?php  $email ?>"></TD>



        </TR>











        <TR>



          <TD>MySQL Server</TD>



          <TD><INPUT type=text size=57  name="mysqlserver" value="<?php  $mysqlserver ?>"></TD>



        </TR>











        <TR id="usemyTR" >



          <TD>Use existing MySQL DB</TD>



          <TD><INPUT type=checkbox  onChange="myuseChange()" <?php  ($usemy == "1") ? "checked" : ""; ?>  name="usemy" id="usemy" value="1"></TD>



        </TR>



        <TR id="mydbnameTR" >



          <TD>MySQL DB Name</TD>



          <TD><INPUT type=text size=57  name="mysqldb" value="<?php  $mysqldb ?>"></TD>



        </TR>



        <TR id="myunameTR">



          <TD>MySQL Username</TD>



          <TD><INPUT type=text size=57  name="mysqlusername" value="<?php  $mysqlusername ?>"></TD>



        </TR>



        <TR id="mypwdTR" >



          <TD>MySQL Password</TD>



          <TD><INPUT type=text size=57  name="mysqlpassword" value="<?php  $mysqlpassword ?>"></TD>



        </TR>







        <TR >



          <TD colspan= 2 align=center > <input type="submit" value="Install" >  </TD>



        </TR>















      </TABLE>







           </fieldlist>







</form>



<script>myuseChange(); installtypeChange();</script>







<?



}

function outError($text)

{

		print "<center><b><font  color = red>$text</font></b><br><br></center>";

}

function DBInstall()

{

		global $mysql_sqldumpfile, $output_mysql_instructions;

		if ($mysql_sqldumpfile == "") return;

		$file_path = dirname(__file__) . "/$mysql_sqldumpfile";

		if (file_exists($file_path))

		{

				$fp = fopen($file_path, "r");

				$cmd_execfile = false;

				while (!feof($fp))

				{

						$line = fgets($fp);

						if ($line[0] == '#' || $line == "\r" || $line == "\n" || $line[0] == "\r\n") continue;

						$line = " " . $line;

						if (strpos($line, "CREATE"))

						{

								$cmd_execfile = true;

						}

						if (strpos($line, "INSERT"))

						{

								$cmd_execfile = true;

						}

						if (strpos($line, "DROP"))

						{

								$cmd_execfile = true;

						}

						if (trim($sqlcmd) != "" && $cmd_execfile)

						{

								if ($output_mysql_instructions) print $sqlcmd . "<br><br>";

								mysql_query($sqlcmd);

								if (mysql_errno())

								{

										outError("<font color=red>MySQL error  for  $sqlcmd " . mysql_error() . "</font><br>");

								}

								$sqlcmd = "";

								$cmd_execfile = false;

						}

						$sqlcmd .= $line;

				}

				mysql_query($sqlcmd);

				fclose($fp);

		}

		else

		{

				outError("Can not  find $mysql_sqldumpfile for  MySQL DB tables creation");

				return false;

		}

		return true;

}

function cpanelSetPermissions($files, $dirs)

{

		global $cpaneldom;

		global $cpaneluser;

		global $cpanelpwd;

		global $cpaneltheme;

		$cpanel_url_prefix = "http://" . urlencode($cpaneluser) . ":" . urlencode($cpanelpwd) . "@$cpaneldom:2082/frontend/" . $cpaneltheme;

		$page = @file_get_contents($url = "$cpanel_url_prefix/files/index.html");

		if ($page == "")

		{

				outError("Can not  connect to CPanel ($url) check connection info (user,password,domain). Click <a href='$url' target=_blank >here</a> for more info.");

				return false;

		}

		$dr = dirname(__file__);

		foreach ($files as $key => $val)

		{

				$subdir = dirname($val);

				$fle = basename($val);

				$checkfile = str_replace("//", "/", $dr . "/" . $val);

				if (!file_exists($checkfile))

				{

						outError("File $checkfile does  not  exists. Upload all files  and  directories.");

						return false;

				}

				$checkfile = str_replace("//", "/", $dr . "/" . $val);

				@chmod($checkfile, 0777);

				if (is_writable($checkfile))

				{

						continue;

				}

				if ($subdir == "." || $subdir == "/" || $subdir == "./") $subdir = "";

				$page = @file_get_contents($url = "$cpanel_url_prefix/files/changeperm.html?file=" . urlencode($fle)
0

I think these lines

<option value="0"   <?php  ($installtype == "0") ? "selected" : ""; ?> >Install with CPanel Info (can create  MySQL  DB  automatically)</option>

should be

<option value="0"   selected=<?php  ($installtype == "0") ? "selected" : ""; ?> >Install with CPanel Info (can create  MySQL  DB  automatically)</option>

Also, you should always use <?php in favour of the shorthand tags. Some servers do not support the shorthand tags, so for maximum compatibility use the longer version (it's only 3 more characters and the benefit is certainly worth it).

1

Actually it should be as follows:

<option value="0"   <?php echo ($installtype == "0" || $installtype == 0) ? "selected" : ""; ?> >Install with CPanel Info (can create  MySQL  DB  automatically)</option>
Votes + Comments
Well spotted!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.