Hellinger Posted July 5, 2021 Share Posted July 5, 2021 (edited) Hi there, im new to programing and got a problem with my code, it wont connect to my MySQL Workbench on my PC and i dont know why. <?php include("dbconnect.php"); ?> !DOCTYPE html> <html> <head> <meta charset="utf-8"> <!--Festlegung Website Titel--> <title>Auftragsübersicht dcl</title> </head> <body> <!--Festlegung Titel--> <h1>Auftragsübersicht</h1> <!--Öffnen Tabelle mit Größenangabe--> <table width="700" border="3" > <thead> <tr> <!--Festlegung der Ersten Zeile--> <th align=left width=350h>Abteilung</th><th align=left width=350>Offene Aufträge</th> </tr> </thead> <tbody> <tr> <td>Produktion</td><td> <?php $db = mysqli_connect("localhost", "Benutzername", "Passwort", "Datenbankname"); if(!$db) { exit("Verbindungsfehler: ".mysqli_connect_error()); } // verbindung zur Datenbank // Abfrage der Datensätze zur Produktion$res = mysql_query("SELECT arbeitsschrittname FROM auftrag WHERE arbeitsschrittname = 'Produktion'"); $num = mysql_num_rows($res); echo "$num"; ?> </td> </tr> <tr> <td>Installation</td><td> <?php // Abfrage der Datensätze zur Installation $res1 = mysql_query("SELECT arbeitsschrittname FROM auftrag WHERE arbeitsschrittname = 'Installation'"); $num1 = mysql_num_rows($res1); echo "$num1"; ?> </td> </tr> <tr> <td>Verpackung</td><td> <?php // Abfrage der Datensätze zur Verpackung $res2 = mysql_query("SELECT arbeitsschrittname FROM auftrag WHERE arbeitsschrittname = 'Verpackung'"); $num2 = mysql_num_rows($res2); echo "$num2"; ?> Edited July 5, 2021 by Barand code tags added Quote Link to comment https://forums.phpfreaks.com/topic/313045-php-conection-to-mysql-workbench/ Share on other sites More sharing options...
Barand Posted July 5, 2021 Share Posted July 5, 2021 With the exception of mysqli_connect(), all your other db code is using the obsolete mysql_ library. I would recommend using PDO instead of mysqli. Quote Link to comment https://forums.phpfreaks.com/topic/313045-php-conection-to-mysql-workbench/#findComment-1587850 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.