Skip to content

Instantly share code, notes, and snippets.

@ggendre
Created April 5, 2012 08:19
Show Gist options
  • Save ggendre/2308969 to your computer and use it in GitHub Desktop.
Save ggendre/2308969 to your computer and use it in GitHub Desktop.
php mysql small connection script
<?php
if ( !isset($_GET['host']) || !isset($_GET['login']) ||
!isset($_GET['pwd']) || !isset($_GET['base'])
){
echo "<h4>script usage : </h4><ul><li>mysqlconnect.php?host=<b>yourHost</b>&login=<b>yourLogin</b>&pwd=<b>yourPassword</b>&base=<b>yourDatabase</b></li></ul>";
}else{
$connection = mysql_connect($_GET['host'],$_GET['login'],$_GET['pwd']);
if ( !$connection ){
die ("can't connect");
mysql_error();
}
echo "connected to server<br>";
mysql_select_db($_GET['base']) or die (mysql_error());
echo "connected to database<br>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment