Jump to content

Archived

This topic is now archived and is closed to further replies.

scheols

Where can i learn Mysqli

Recommended Posts

One: how did you manage to fill in the register form of this website?
Two: who allowed you?
Three: ever heard of google?
Four: manuals ever heard of?
Five: here is your damn tutorial/manual http://devzone.zend.com/node/view/id/686

It is always nice to see, people doing some effort to get something...

Share this post


Link to post
Share on other sites
yeah is some sort of an extension... mysqli (MySQL Improved) never used it though, maybe some day...

Share this post


Link to post
Share on other sites
Looking for more of a manual not a tutorial

can i ask a question mysqli is way different then regular MySQL and yes i heard of google

mysql
[code=php:0]

<?
$uname ="Uname";//Username
$upass ="upass";//Userpassword
$database="dbname";//Database name
mysql_connect("localhost",$uname,$upass);
mysql_select_db($database) or die(mysql_error());
?>
[/code]

mysqli
[code=php:0]
<?php

/* Connect to a MySQL server */
$link = mysqli_connect(
            'localhost',  /* The host to connect to */
            'user',      /* The user to connect as */
            'password',  /* The password to use */
            'world');    /* The default database to query */

if (!$link) {
  printf("Can't connect to MySQL Server. Errorcode: %s\n", mysqli_connect_error());
  exit;
}
?>
[/code]

Share this post


Link to post
Share on other sites
thanks benjamin for your support im learning all this so i can open up my PHP site soon and mysqli is just a weekpoint of my coding abilities.

Anybody got a quick referrence couldnt find anything on google.

Share this post


Link to post
Share on other sites
hearing of it is not enough, its using it that defines you...
look, i'm not trying to insult you or anything, but "where can you learn mysqli?" on php.net or read a book, want help with something involving mysqli (a function not working, strange error's, etc...), that's what we are here for, we're not gonna play your teacher..

@scheols if you know mysql, you will be easily picking up with mysqli, because the changes aren't that big... you still connect with your database through mysqli_connect(); the only difference is that mysql_select_db() is left out and an i has been added to the connect function! You also have the ability to directly put your database name in your connect function

here a direct link to it: http://php.belnet.be/manual/nl/function.mysqli-connect.php i will post a tutorial/manual later on to explain its use

Share this post


Link to post
Share on other sites
[quote author=ignace link=topic=103195.msg410809#msg410809 date=1154889446]
hearing of it is not enough, its using it that defines you...
look, i'm not trying to insult you or anything, but "where can you learn mysqli?" on php.net or read a book, want help with something involving mysqli (a function not working, strange error's, etc...), that's what we are here for, we're not gonna play your teacher..

@scheols if you know mysql, you will be easily picking up with mysqli, because the changes aren't that big... you still connect with your database through mysqli_connect(); the only difference is that mysql_select_db() is left out and an i has been added to the connect function! You also have the ability to directly put your database name in your connect function
[/quote]its more then just mysqli_connect kid now if you dont want 2 help fine with me leave this thread as i said i know mysql i want to know more about mysqli do u understand? its a help forum, now im looking forsomeone who can tell me where i can learn this mysqli functions etc..  please stop posting.

Share this post


Link to post
Share on other sites
Has this forum suddenly turned into somewhere for people to slag each other off?

Anyways, scheols, without further irritating anyone, from what you have said, ignace is right; the manual has to be the best place to start. You just said you are looking to learn about mysqli functions, and the manual gives details about all of them. The menu on this page:
http://uk.php.net/mysqli_connect
Has all of the functions. Why not try looking at them and if there are specific functions you need help with, then ask away.

Share this post


Link to post
Share on other sites
Now, what you originally requested..

first of all mysqli can be used like you have always used mysql or in oop style

[b]"Normal" mode:[/b]
[code]
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
 
/* check connection */
if (mysqli_connect_errno()) {
  printf("Connect failed: %s\n", mysqli_connect_error());
  exit();
}
 
mysqli_query($link, "CREATE TABLE myCity LIKE City");

/* Prepare an insert statement */
$query = "INSERT INTO myCity (Name, CountryCode, District) VALUES (?,?,?)";
$stmt = mysqli_prepare($link, $query);

mysqli_stmt_bind_param($stmt, "sss", $val1, $val2, $val3);

$val1 = 'Stuttgart';
$val2 = 'DEU';
$val3 = 'Baden-Wuerttemberg';
 
/* Execute the statement */
mysqli_stmt_execute($stmt);

$val1 = 'Bordeaux';
$val2 = 'FRA';
$val3 = 'Aquitaine';
 
/* Execute the statement */
mysqli_stmt_execute($stmt);

/* close statement */
mysqli_stmt_close($stmt);

/* retrieve all rows from myCity */
$query = "SELECT Name, CountryCode, District FROM myCity";
if ($result = mysqli_query($link, $query)) {
  while ($row = mysqli_fetch_row($result)) {
      printf("%s (%s,%s)\n", $row[0], $row[1], $row[2]);
  }
  /* free result set */
  mysqli_free_result($result);
}

/* remove table */
mysqli_query($link, "DROP TABLE myCity");

/* close connection */   
mysqli_close($link);
?>
[/code]

[b]Using Object Oriented Style[/b]
[code]
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
 
/* check connection */
if (mysqli_connect_errno()) {
  printf("Connect failed: %s\n", mysqli_connect_error());
  exit();
}
 
$mysqli->query("CREATE TABLE myCity LIKE City");

/* Prepare an insert statement */
$query = "INSERT INTO myCity (Name, CountryCode, District) VALUES (?,?,?)";
$stmt = $mysqli->prepare($query);

$stmt->bind_param("sss", $val1, $val2, $val3);

$val1 = 'Stuttgart';
$val2 = 'DEU';
$val3 = 'Baden-Wuerttemberg';
 
/* Execute the statement */
$stmt->execute();

$val1 = 'Bordeaux';
$val2 = 'FRA';
$val3 = 'Aquitaine';
 
/* Execute the statement */
$stmt->execute();

/* close statement */
$stmt->close();

/* retrieve all rows from myCity */
$query = "SELECT Name, CountryCode, District FROM myCity";
if ($result = $mysqli->query($query)) {
  while ($row = $result->fetch_row()) {
      printf("%s (%s,%s)\n", $row[0], $row[1], $row[2]);
  }
  /* free result set */
  $result->close();
}

/* remove table */
$mysqli->query("DROP TABLE myCity");

/* close connection */   
$mysqli->close();
?>
[/code]

if there is something you don't understand, then i'll probably will be hearing from you...

Share this post


Link to post
Share on other sites
[b]If there is anymore swearing/slagging each other off in this thread again this thread will be closed. I have gone through and removed much of the swearing from this thread, please keep in mind there is possibly minors browsing this forum.

Also ignace if you dont like people asking these types of questions then don't bother replying.[/b]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.