Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP i MySQL] Problem z kodem
Storm93
post 18.11.2007, 01:06:54
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 18.11.2007

Ostrzeżenie: (0%)
-----


Więc mam taki kod:
CODE

<?php
$sql = mysql_connect (host, username, chcialbys wiedziec);
mysql_query($sql);
mysql_select_db("****");
$reg = "INSERT INTO members(nick, pass, mail) VALUES ("$_POST['usrname']","$_POST['pass']","$_POST['mail']")";
if ($_POST['usrname'] == '')
echo 'Nie podałeś nazwy uzytkownika!';
else if ($_POST['pass'] == '')
echo 'Nie podales hasla!';
else if ($_POST['mail'] == '')
echo 'Nie podales adresu e-mail!';
else
mysql_query($reg);

?>


I niestety otrzymuje taki błąd:
Kod
[b]Parse error[/b]:  syntax error, unexpected T_VARIABLE in [b]/var/www/sites/yoyo.pl/e/l/elodreipaj/reg.php[/b] on line [b]5


Nie wiem co jest grane - może ktoś pomóc? smile.gif
[/b]
Go to the top of the page
+Quote Post
Darti
post 18.11.2007, 03:16:38
Post #2





Grupa: Zarejestrowani
Postów: 1 076
Pomógł: 62
Dołączył: 6.03.2005
Skąd: Wroc

Ostrzeżenie: (0%)
-----


  1. <?php
  2. $reg = "INSERT INTO members(nick, pass, mail) VALUES (".$_POST['usrname'].",".$_POST['pass'].",".$_POST['mail'].")";
  3. ?>


--------------------
The answer is out there, Neo. It's looking for you. And it will find you, if you want it to.
SERVER_SOFTWARE : Apache/2.2.4 (Win32) PHP/5.2.1
MySQL Client API version : 5.0.27
Go to the top of the page
+Quote Post
Storm93
post 18.11.2007, 09:36:50
Post #3





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 18.11.2007

Ostrzeżenie: (0%)
-----


No teraz niby działa, ale mam błąd z mysql - mam nadzieję, że to wina hostingu:
CODE

Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /var/www/sites/yoyo.pl/e/l/elodreipaj/najladniejsze/reg.php on line 2

Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /var/www/sites/yoyo.pl/e/l/elodreipaj/najladniejsze/reg.php on line 3

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /var/www/sites/yoyo.pl/e/l/elodreipaj/najladniejsze/reg.php on line 3

Warning: mysql_select_db() [function.mysql-select-db]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /var/www/sites/yoyo.pl/e/l/elodreipaj/najladniejsze/reg.php on line 4

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /var/www/sites/yoyo.pl/e/l/elodreipaj/najladniejsze/reg.php on line 4
Go to the top of the page
+Quote Post
phpion
post 18.11.2007, 11:28:47
Post #4





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




  1. <?php
  2. $sql = mysql_connect ('host', 'username', 'chcialbys wiedziec');
  3. mysql_select_db("****", $sql);
  4. // cala reszta
  5. ?>


Ten post edytował phpion.com 18.11.2007, 11:29:19
Go to the top of the page
+Quote Post
Storm93
post 18.11.2007, 18:27:26
Post #5





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 18.11.2007

Ostrzeżenie: (0%)
-----


Nadal coś nie tak :/

CODE
Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /var/www/sites/yoyo.pl/e/l/elodreipaj/najladniejsze/reg.php on line 2

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /var/www/sites/yoyo.pl/e/l/elodreipaj/najladniejsze/reg.php on line 3
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 6.07.2025 - 11:45