note 78638 added to function.mysql-connect

From: Date: Sat, 20 Oct 2007 17:51:58 +0000
Subject: note 78638 added to function.mysql-connect
Groups: php.notes 
Request: Send a blank email to php-notes+get-131585@lists.php.net to get a copy of this message
Sometimes, I want that MySQL service start automatically when my app need it. This is specially true if you work in a development PC and/or in an small intranet environment. You can do something like this: if the mysql_connect() function returns FALSE, try to force the initialization of the MySQL service! For example, under Windows: <?php $link = @mysql_connect($server,$user,$pass); if (empty($link)){ @exec("%SystemRoot%\\system32\\net.exe start mysql"); sleep(5); $link = @mysql_connect($servidor,$usuario,$clave); } ?> In Linux of course you can try "/etc/init.d/mysqld start" but you will need special permissions. Regards. ---- Server IP: 190.2.55.3 Probable Submitter: 201.250.60.5 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-connect.php Edit -- https://master.php.net/note/edit/78638 Del: integrated -- https://master.php.net/note/delete/78638/integrated Del: useless -- https://master.php.net/note/delete/78638/useless Del: bad code -- https://master.php.net/note/delete/78638/bad+code Del: spam -- https://master.php.net/note/delete/78638/spam Del: non-english -- https://master.php.net/note/delete/78638/non-english Del: in docs -- https://master.php.net/note/delete/78638/in+docs Del: other reasons-- https://master.php.net/note/delete/78638 Reject -- https://master.php.net/note/reject/78638 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131585) next »