Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Hoping this will help you.You can do it as:</p> <p><strong>create index.php</strong></p> <pre><code>&lt;table width="300" border="0" align="center" cellpadding="0" cellspacing="1"&gt; &lt;tr&gt; &lt;td&gt;&lt;form name="form2" method="post" action='generate.php'&gt; &lt;table width="100%" border="0" cellspacing="1" cellpadding="3"&gt; &lt;tr&gt; &lt;td colspan="3"&gt;&lt;center&gt;&lt;strong&gt;Select Default Database&lt;/strong&gt;&lt;/center&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;center&gt;&lt;select name="db_used"&gt; &lt;?php $host="localhost"; $username="root"; $password=""; $link = mysql_connect("$host", "$username", "$password")or die("cannot connect"); $result = mysql_list_dbs( $link ); while( $row = mysql_fetch_object( $result ) ){ echo "&lt;option&gt;$row-&gt;Database&lt;/option&gt;"; } ?&gt; &lt;/select&gt;&lt;/center&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" align="center"&gt;&lt;input type="submit" name="Submit" value="Submit"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p><strong>Crate generate.php</strong></p> <pre><code>&lt;?php $HOMEDIR = getcwd() . "/"; # /home/virtual/magicplugin.com/var/www/html/ $TEMPLATEDIR = $HOMEDIR . ""; $fName = $TEMPLATEDIR . "dbConnection.php"; $fh = fopen($fName, "r"); $fContents = fread($fh, filesize($fName)); fclose($fh); $fContents = str_replace("__databaseName__",$_REQUEST['db_used'],$fContents); $outFile ="index.php"; $fp = fopen($outFile,"w"); fwrite($fp,$fContents); fclose($fp); echo"Connection generated.Please Check"; ?&gt; </code></pre> <p><strong>Create dbConnection.php</strong></p> <pre><code>&lt;table width="300" border="0" align="center" cellpadding="0" cellspacing="1"&gt; &lt;tr&gt; &lt;td&gt;&lt;form name="form2" method="post" action='generate.php'&gt; &lt;table width="100%" border="0" cellspacing="1" cellpadding="3"&gt; &lt;tr&gt; &lt;td colspan="3"&gt;&lt;center&gt;&lt;strong&gt;Select Default Database&lt;/strong&gt;&lt;/center&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;center&gt;&lt;select name="db_used"&gt; &lt;?php $host="localhost"; $username="root"; $password=""; $link = mysql_connect("$host", "$username", "$password")or die("cannot connect"); $result = mysql_list_dbs( $link ); while( $row = mysql_fetch_object( $result ) ){ echo "&lt;option&gt;$row-&gt;Database&lt;/option&gt;"; } ?&gt; &lt;/select&gt;&lt;/center&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" align="center"&gt;&lt;input type="submit" name="Submit" value="Submit"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;?php $host="localhost"; $username="root"; $password=""; $db_name = "__databaseName__"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload