++$errors; $Body .= "<p>The passwords do not match.</p>\n"; $password = ""; $password2 = ""; } } // Connect to database server and open internships database.\ $DBConnect = FALSE; if ($errors == 0) { $DBConnect = @mysql_connect("localhost", "root", ""); if ($DBConnect === FALSE) { $Body .= "<p>Unable to connect to the database server. " . "error code " . mysql_errno() . ": " . mysql_error() . "</p>\n"; ++$errors; } else { $DBName = "internships"; $result = @mysql_connect_db($DBName, $DBConnect); if ($result === FALSE) { $Body .= "<p>Unable to select the database. " . "Error code " . mysql_errno($DBConnect) . ": " . mysql_error($DBConnect) . "</p>\n"; ++$errors; } } } // Verify that the e-mail address entered is not already in interns table $TableName = "interns"; if ($errors == 0) { $SQLstring = "SELECT count(*) FROM {$TableName} " . "where email='{$email}'"; $QueryResult = @mysql_query($SQLstring, $DBConnect); if ($QueryResult !== FALSE) { $Row = mysql_fetch_row($QueryResult); if ($Row[0] > 0) { $Body .= "<p>The email address entered (" . htmlentities($email) . ") is already registered.</p>\n";
<?php $obj = json_decode($_POST['value']); $con = mysql_connect("localhost", "username", "password"); mysql_connect_db('your_database', $con); $result = json_decode($obj); foreach ($result as $key => $value) { if ($value) { //works for array, not sure if for single object //mysql table names,host,databasename or password yet unknown //how to use json array to insert data in Database mysql_query("INSERT INTO matches (team_1, team_2, team_score_1,team_score_2,start_time,end_time) VALUES ({$value->team_1}, {$value->team_2},{$value->team_score_1},{$value->team_score_2},{$value->start_time},{$value->end_time})"); } mysql_close($con); } ?>
<? $inputuser=$POST['user']; $inputpass=$POST['pass']; $user=""; $password=""; $connect=mysql_connect("www.mottle.de", $user, $password); @mysql_connect_db($tutorial) or ("Databasd not found"); $query="SELECT * FROM 'users' WHERE 'user'='$inputuser'"; $querypass="******"; echo $query; echo $querypass; mysql_close(); /* if ($inputuser=="Hirsch" && $inputuser=="123"){ echo "Welcome" header('Location: Home.php'); } else{ echo "Not Welcome" header('Location: Fail.php'); }*/ ?>
public function __construct(iDBConfigReader $conf) { $host = $conf->getHost(); $user = $conf->getUser(); $pass = $conf->getPassword(); $db = $conf->getDatabase(); $cnx = mysql_connect($host, $user, $pass); if (!$cnx or !mysql_connect_db($db, $cnx)) { throw new RuntimeException(mysql_error(), mysql_errno()); } $this->connection = $cnx; }