MWojt Posted August 30, 2014 Posted August 30, 2014 (edited) Hi Leute, ich habe mal wieder ein Problem mit einem PHP-Skript. Dieses Mal soll dieses eigentlich eine MySQL-Abfrage tätigen, tut dies allerdings nicht. Durch dieses Skript wird zwar etwas ausgegeben, allerdings nicht das, was ich haben will; wie es scheint sind alle Werte Null. Hier mein Skript: <?php $stmt = mysqli_prepare($db,"SELECT max(id) AS `id` FROM `commies` WHERE `postid` = ? AND `hidden` = 0"); if($stmt == false) { $result = mysqli_query($db,"SHOW TABLES LIKE 'commies'"); if(mysqli_num_rows($result) !== 1) { mysqli_query($db,"CREATE TABLE `commies` ( `id` INT(255) PRIMARY KEY, `userid` INT(255) NOT NULL, `postid` INT(255) NOT NULL, `content` VARCHAR(60000) NOT NULL, `answer` INT(255) NULL, `hidden` BOOLEAN NOT NULL DEFAULT 0, `time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `edittime` TIMESTAMP NULL, `editor` INT(255), `editreason` VARCHAR(300) ) CHARSET UTF8;"); } } else { mysqli_stmt_bind_param($stmt,"i",$_GET['id']); mysqli_stmt_execute($stmt); mysqli_stmt_bind_result($stmt,$max); mysqli_stmt_fetch($stmt); mysqli_stmt_close($stmt); if($max !== 0 && isset($max)) { $less = $max + 1; $stmt = mysqli_prepare($db,"SELECT `id`,`userid`,`content`,`time` FROM `commies` WHERE `hidden` = 0 AND `postid` = ? AND `id` < ? ORDER BY `id` DESC LIMIT 1"); while($less > 0) { mysqli_stmt_bind_param($stmt,"ii",$_GET['id'],$less); mysqli_stmt_execute($stmt); mysqli_stmt_bind_result($stmt,$less,$userid,$content,$mtime); $error = mysqli_stmt_fetch($stmt); if(!$error) { $userpic = userValue($db,$userid,"userpic"); $time = inttotime(strtotime($mtime)); if(!isset($userpic)) { $userpic = config($db,1,"defaultpic"); } $username = getUserName($db,$userid); echo('<article class="commie"><span class="abovecommie"><table><tr><th class="pic" rowspan="3"><img class="commiepic" src="'.$userpic.'"></img><th>'.$username.'</th></tr><tr><th>'.$time.'</th></tr><tr><th></th></tr></table></span>Nom</article>'); } } } } ?> Ich würde mich freuen, wenn jemand den Fehler fände und ihn mir sagen würde. In der MySQL-Datenbank steht: id userid postid content answer hidden time edittime editor editreason 1 1 3 Hallo NULL 0 2014-08-27 20:12:26 NULL NULL NULL PS: Entschuldigung für etwaige Fehler oder dumme Formulierungen etc, bin schon etwas müde. //EDIT: Es lag wohl daran, dass ich "if(!$error)" statt "if($error)" geschrieben habe. Problem behoben. Danke im Voraus, MWojt Edited August 31, 2014 by MWojt
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now