1

I´m new to SQL and PHP, so pardon me for asking something that´s probably very simple, but for some reason, even though I don´t have any loops in my code, when it get´s to this part, it continues loading the page indefinitely. Here is the snippet of the code that does that.

mysql_connect("localhost:8080", "root@localhost") or
die("Could not connect: " . mysql_error());

mysql_select_db("tickets");

$val1 = $_POST["Name"];
$val2 = $_POST["Mail"];
$val3 = $_POST["Betreff"];
$val4 = $_POST["Wichtigkeitsstufe"];
$val5 = $_POST["Nachricht"];

$sql = "INSERT INTO Ticket (Name, E-MailOderErreichbarkeitBeiRückfragen, RaumbezeichnungBzwNummer, Wichtigkeitsstufe, Problembeschreibungausführlich)
        VALUES ({$val1}, {$val2}, {$val3}, {$val4}, {$val5})";

I get the values for $val1,2,3,... from input boxes in an html file. Thanks in advance, cheers!

Edit: I was running both the DB and the webserver on the same ports. Thanks again for the help!

aakk
  • 334
  • 4
  • 15
  • Is your database really at port 8080? Try using simply `localhost`, or `localhost:3306` (default Mysql port) – Damien Pirsy Feb 23 '16 at 10:00
  • @Damien Pirsy it´s on port 4433 and 8080, I changed the ports because 80 and 433 were apparently busy and I didn´t know by what. Supposedly Skype likes those ports, but I don´t have Skype installed on this PC. going on localhost::3306 gives me: X��� 5.5.5-10.1.9-MariaDB� ��^WxxpKe<�ÿ÷�? ����������9JJpy.v*iTIP�mysql_native_password�!��ÿ„#08S01Got packets out of order – aakk Feb 23 '16 at 10:01
  • So the DB is on 4433? – Damien Pirsy Feb 23 '16 at 10:03
  • I can understand your webserver being on ports 4433 and 8080; but MySQL?!? Why not simply use the standard port 3306 for MySQL? – Mark Baker Feb 23 '16 at 10:03
  • @Mark Baker is that bad? Does putting both the webserver and the DB on the same ports overlap each other? It didn´t give me any errors when I ran them so I guessed that was the way I had to do it. Like I said, new to anything web-related. :( – aakk Feb 23 '16 at 10:05
  • 3
    Yes, using the same ports for both the webserver and for the database is bad, no wonder the poor servers are confused – Mark Baker Feb 23 '16 at 10:06
  • Haha alright, thanks a bunch. Should be working now, cheers! – aakk Feb 23 '16 at 10:06
  • Your code is vulnerable to attacks and functions are deprecated, don't ever use it in production. You should read this: http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php and this: http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php – rap-2-h Feb 23 '16 at 10:17
  • @rap-2-h it´s just for a tiny project for school, nothing more. I´ll look into it though, thanks! – aakk Feb 23 '16 at 10:24

0 Answers0