1

Can anybody give me a basic full php-mysql insert into block of code for mysqli() and mysql_connect(). Many thanks

ktm
  • 5,897
  • 24
  • 67
  • 95

3 Answers3

3

The PHP manual has excellent example blocks for almost every command.

Pekka
  • 431,103
  • 135
  • 960
  • 1,075
1

Have a look at:

The mysqli version function usually have an i suffixed after mysql keyword. More on mysqli functions.

Sarfraz
  • 367,681
  • 72
  • 526
  • 573
1

For connecting and selecting a database (selecting is optional):

$con = mysql_connect($username, $password);
$db = mysql_select_db($dbname);

Querying:

$result = mysql_query("SELECT id,name FROM table");
if(!$result) {
  echo mysql_error();
}
while($row = mysql_fetch_assoc($result)) {
   echo "Row data: " . $row['id'] . " - " . $row['name'];
}
halfdan
  • 32,443
  • 8
  • 76
  • 85