<?php
$link = mysql_connect('localhost', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
if (!mysql_select_db('database'))
die("Can't select database");
// choose id 31 from table users
echo $id; //31
echo $name; //id31's name
echo $surname //id31's surname
echo $blablabla //id31's blablabla
mysql_close($link);
?>
<?php $link = mysql_connect(‘localhost’, ‘username’, ‘password’); if (!$link) { die(‘Could not connect: ‘ .
Share
Give this a shot:
Functions Used:
mysql_real_escape_string()– Escapes special characters in a string for use in an SQL statementmysql_query()– Send a MySQL querymysql_fetch_assoc()– Fetch a result row as an associative array