Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MySQL] mysql_connect() - brak dostepu
MiChaSSs
post 11.07.2009, 15:33:05
Post #1





Grupa: Zarejestrowani
Postów: 65
Pomógł: 4
Dołączył: 6.09.2007

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


Hej,
Mam problem z uzyskaniem dostepu poprzez PHP do bazy danych. Wszystko dziala na localhoscie z takimi parametrami:

  1. <?php
  2. [ebuild     U ] dev-lang/php-5.2.10-r1 [5.2.9-r2] USE=&#092;"apache2 berkdb bzip2 cgi cli crypt curl curlwrappers gd gdbm iconv ipv6 mssql mysql ncurses nls pcre readline reflection session simplexml spl ssl threads truetype unicode xml xmlreader xmlwriter zip zlib -adabas -bcmath -birdstep -calendar -cdb -cjk -concurrentmodphp -ctype -db2 -dbase -dbmaker -debug -discard-path -doc -empress -empress-bcs -esoob -exif -fastbuild -fdftk -filter -firebird -flatfile -force-cgi-redirect -frontbase -ftp -gd-external -gmp -hash -imap -inifile -interbase -iodbc (-java-external) -json -kerberos -kolab -ldap -ldap-sasl -libedit -mcve -mhash -msql -mysqli -oci8 -oci8-instant-client -odbc -pcntl -pdo -pic -posix -postgres -qdbm -recode -sapdb -sharedext -sharedmem -snmp -soap -sockets -solid -spell -sqlite -suhosin -sybase -sybase-ct -sysvipc -tidy -tokenizer -wddx -xmlrpc -xpm -xsl -yaz (-zip-external%)\" 8,614 kB
  3.  
  4. [ebuild   R   ] dev-db/mysql-5.0.83  USE=&#092;"berkdb community perl ssl -big-tables -cluster -debug -embedded -extraengine -latin1 -max-idx-128 -minimal -profiling (-selinux) -static\" 0 kB
  5. ?>


Skrypt, poprzez ktory probuje sie dostac wyglada nastepujaco:

  1. <?php
  2. function create_tables($mysql_login, $mysql_password, $mysql_database, $mysql_host)
  3. {
  4.    // Polaczenie do bazy danych MySQL
  5.    $mysql_connection = @mysql_connect($mysql_host, $mysql_login, $mysql_database)
  6.    // Gdy polaczenie sie nie powiedzie to wyswietl komunikat i przerwij skrypt
  7.    or die(&#092;"Error while connecting to MySQL -> \".mysql_error().\"\n\");
  8.    // Wybor bazy danych
  9.    $mysql_db = @mysql_select_db($mysql_database, $mysql_connection)
  10.    // Gdy wybor bazy danych sie nie powiedzie wyswietl komunikat i przerwij skrypt
  11.    or die(&#092;"Error while selecting database\n\");
  12.  
  13.    echo(&#092;"udalo sie\");
  14.    mysql_close($mysql_connection);
  15. }
  16.  
  17. /*--------------------------------------------------------------------------------------------------------------------------*/
  18.  
  19. ini_set('display_errors',1);
  20. error_reporting(E_ALL | E_STRICT);
  21. create_tables('login', 'haslo', 'nazwa_bazy', 'localhost');
  22. ?>


Gdy loguje sie do MySQL-a poprzez linie komend wszystko jest okej

  1. <?php
  2. michasss@laptop ~ $ mysql -u michasss -p
  3. Enter password:
  4. Welcome to the MySQL monitor.  Commands end with ; or g.
  5. Your MySQL connection id is 16
  6. Server version: 5.0.83-log Gentoo Linux mysql-5.0.83
  7.  
  8. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
  9.  
  10. mysql> show databases;
  11. +--------------------+
  12. | Database           |
  13. +--------------------+
  14. | information_schema |
  15. | michasss           |
  16. +--------------------+
  17. 2 rows in set (0.00 sec)
  18.  
  19. mysql>
  20. ?>


Moje jest jakas "specjalna" opcja w php.ini albo my.conf ktora musze dopisac / zaznaczyc / odznaczyc ? Prosze o pomoc, pozdrawiam Michal smile.gif

Ten post edytował MiChaSSs 11.07.2009, 15:55:53
Go to the top of the page
+Quote Post

Posty w temacie


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: 31.07.2025 - 10:50