Pentru usurarea lucrului cu bazele de date am facut functiile urmatoare function mysql_query_assoc($sql) – Returneaza un tablou cu rezultatele query-ului $sql ex: daca avem o tabela care are 3 linii – mysql_query_assoc(„SELECT nume, prenume FROM elevi LIMIT 3”); returneaza array( 0 => ( ‘nume’->’Popescu’, ‘prenume’=>’Adrian’), 1 => ( ‘nume’->’Ionescu’, ‘prenume’=>’Cristian’), 2 => ( ‘nume’->’Georgescu’, ‘prenume’=>’Victor’), […]
Inserare rand in tabela mysql
$a=array(); $a[`camp1`]=`valoare1`; … $a[`campX`]=`valoareX`; mysql_query(„INSERT INTO table („.implode(`,`,array_keys($a)).”) VALUES (`”.implode(„`,`”,$a).”`)”);
Instalare MySQL 5
To upgrade to MySQL 5.0.68, do the following at a command prompt: yum upgrade mysql –enablerepo=centosplus signal-event post-upgrade; signal-event reboot mysql_upgrade signal-event post-upgrade; signal-event reboot Errors like this in /var/log/httpd/admin_access_log: Premature end of script headers (index.cgi)Can’t do setuid (cannot exec sperl)Should be fixed by doing this: yum install perl-suidperl signal-event post-upgrade; signal-event reboot […]
Sterge articole duplicat
Pentru a sterge articolele duplicat dintr-o tabela MySQL se foloseste DISTINCT astfel : DELETE FROM table1 USING table1, table1 AS vtable WHERE (table1.id > vtable.id) AND (table1.field_name=vtable.field_name)
Localizare geografica dupa IP
O baza de date cu locatiile (tarile) de provenienta ale IP-urilor (geolocalizare) se poate gasi, in format CSV, aici. Baza de date se updateaza lunar. Pentru a determina IP-ul vizitatorului, in PHP se foloseste $_SERVER[‘REMOTE_ADDR’]
Error Handling
Prevent public display of PHP errors via htaccess # supress php errorsphp_flag display_startup_errors offphp_flag display_errors offphp_flag html_errors offphp_value docref_root 0php_value docref_ext 0 Preserve (log) your site’s PHP errors via htaccess # enable PHP error loggingphp_flag log_errors onphp_value error_log /home/path/public_html/domain/PHP_errors.log
Activare .htaccess
Enable .htaccess in iBay log on using shell (putty, etc.) with the root username and password. login as: rootroot@server’s password: password Enter the following commands: (where: my_ibay_name is the name of the ibay we want to enable for .htaccess override) [root@server ~] db accounts setprop my_ibay_name AllowOverride All[root@server ~] signal-event ibay-modify my_ibay_name Allow FollowSymLinks When […]
Facebook Login
<html> <head> <title>My Facebook Login Page</title> </head> <body> <div id=”fb-root”></div> <script src=”http://connect.facebook.net/en_US/all.js”> </script> <script> FB.init({ appId:’YOUR_APP_ID’, cookie:true, status:true, xfbml:true }); </script> <fb:login-button perms=”email,user_checkins”> Login with Facebook </fb:login-button> </body> </html> A full list of permissions is available in the permissions reference.
Static Map
Static map sau harta Statica este o unealta prin care inserezi in pagina ta o harta Google fara a necesita javascript sau alt continut dinamic Harta se generaza ca o imagine si se personalizeaza prin parametrii din adresa imaginii http://maps.googleapis.com/maps/api/staticmap?[parametrii] unde parametrii sunt : center : stablieste centrul hartii. Personal prefer ca centrul hartii sa […]
Timp maxim de executie
How do I change the PHP maximum execution time? In an .htaccess file in the same directory as the executing script, include this line: php_value max_execution_time ? Replace „?” with the with the value you need to replace it with. Our default time is set to 30 seconds and a successful modification of the maximum […]