Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DB Connection:
- <?php
- function connect(){
- session_start();
- $server = "host";
- $benutzer = "Benutzer";
- $pass = "pass";
- $_SESSION['tabelle'] = "tabelle";
- $conn = mysqli_connect($server, $benutzer, $pass, $_SESSION['tabelle']);
- return $conn;
- }
- function getAllUsers($conn){
- $sql = "SELECT * FROM `users`";
- $dbResult = mysqli_query($conn, $sql);
- $userArry = array();
- while($row = mysqli_fetch_array($dbResult)){
- $user = array();
- $user['userName'] = $row['userName'];
- $user['userPassword'] = $row['userPassword'];
- $user['userID'] = $row['userID'];
- $userArry[] = $user;
- }
- return $userArry;
- }
- function getUser($conn, $userId){
- $sql = "SELECT * FROM `users` WHERE `userID` = ".mysqli_real_escape_string($conn, $userId);
- $dbResult = mysqli_query($conn, $sql);
- while($row = mysqli_fetch_array($dbResult)){
- $user = array();
- $user['userName'] = $row['userName'];
- $user['userPassword'] = $row['userPassword'];
- $user['userID'] = $row['userID'];
- return $user;
- }
- return NULL;
- }
- ?>
- Mein Code der den Error Ausgibt:
- <?php
- include("helper.php");
- $database = connect();
- $user = getAllUsers($database);
- $sql = "SELECT * FROM ".$_SESSION['klasse']."";
- $dbResult = mysqli_query($database, $sql);
- while($row = mysqli_fetch_array($dbResult)){
- $chatEntry = array();
- $chatEntry['userID'] = $row['userID'];
- $chatEntry['userText'] = $row['text'];
- $chatEntry['Time'] = $row['time'];
- $user = getUser($database, $chatEntry['userID']);
- $chatText = strip_tags($chatEntry['userText'], '<a></a><img>');
- $urlsuch[]="/([^]_a-z0-9-=\"'\/])((https?|ftp):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si";
- $urlsuch[]="/^((https?|ftp):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si";
- $urlreplace[]="\\1[URL]\\2\\4[/URL]";
- $urlreplace[]="[URL]\\1\\3[/URL]";
- $chatText = preg_replace($urlsuch, $urlreplace, $chatText);
- $chatText = preg_replace("/\[URL\]www.(.*?)\[\/URL\]/si", "<a target=\"_blank\" href=\"http://www.\\1\">www.\\1</a>", $chatText);
- $chatText = preg_replace("/\[URL\](.*?)\[\/URL\]/si", "<a target=\"_blank\" href=\"\\1\">\\1</a>", $chatText);
- $chatText = preg_replace("/(http:\/\/)?(.*\.(de|com|at|net)[^\s]*)/","<a target='_blank' href='http:\/\/$2'>$2</a>", $chatText);
- $chatText = preg_replace("/(:D)/","<img src='img/smilie1.png' style='height:20px; width:20px;'>", $chatText);
- $chatText = preg_replace("/(:\()/","<img src='img/smilie2.png' style='height:20px; width:20px;'>", $chatText);
- $chatText = preg_replace("/(\(creeper\))/","<img src='img/smilie3.png' style='height:20px; width:20px;'>", $chatText);
- $chatText = preg_replace("/(\;\))/","<img src='img/smilie4.png' style='height:20px; width:20px;'>", $chatText);
- $chatText = preg_replace("/(\(fu)\)/","<img src='img/smilie5.png' style='height:20px; width:22px;'>", $chatText);
- echo $user['userName'] . ": <lable style='color:#D8D8D8'>" . $chatText . " </lable>~" . $chatEntry['Time'] . "~";
- echo "<br>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement