#1

Hello there,

I have got a question .. Which i don't know if i am allowed to post it here or no, anyways i will give it a try.

I am a newbie in PHP.

I was wondering if there is tutorials like showing ban list from mysql using php or an exmaple for it?

Thanks for reading ...
Reply
#2

http://www.w3schools.com/sql/sql_select.asp

http://php.net/manual/en/function.mysql-fetch-array.php
Reply
#3

I would like an example script, so i can understand.
Reply
#4

Quote:
Originally Posted by Maro06
Посмотреть сообщение
I would like an example script, so i can understand.
The examples are in both pages. Just adapt it to your database structure.

Basically, you're asking for an 'example script' so you don't have to do anything and just copy that one.
Reply
#5

Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
The examples are in both pages. Just adapt it to your database structure.

Basically, you're asking for an 'example script' so you don't have to do anything and just copy that one.
lol.

Actually, how can i even understand from that 2 pages? And i am not going to copy, I will make one by my self, if you don't want to help just dont reply.
Reply
#6

Код:
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
    die("Could not connect: " . mysql_error());
mysql_select_db("mydb");

$result = mysql_query("SELECT id, name FROM mytable");

while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
    printf ("ID: %s  Name: %s", $row[0], $row["name"]);
}

mysql_free_result($result);
?>
Reply
#7

You should use Mysqli, not mysql. Mysql is depreciated.
Reply
#8

Use PDO, Or MySQLi
Reply
#9

Quote:
Originally Posted by TakeiT
Посмотреть сообщение
You should use Mysqli, not mysql. Mysql is depreciated.
Quote:
Originally Posted by iFarbod
Посмотреть сообщение
Use PDO, Or MySQLi
Код:
<?php
    $con = new mysqli("localhost", "mysql_user", "mysql_password");
    if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); }

if($result = mysqli_query($con, "SELECT id, name FROM mytable"))
{

while ($row = mysqli_fetch_assoc($result)) {
    printf ("ID: %s  Name: %s", $row["id"], $row["name"]);
}

mysqli_free_result($result);

}
mysqli_close($con);
?>
Reply
#10

Using mysql_* is bad practice as it's not safe, though. They should either use mysqli_* or PDO.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)