Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: PHP Warning: mysqli_select_db() expects exactly 2 parameters
Форумы портала PHP.SU » » Вопросы новичков » PHP Warning: mysqli_select_db() expects exactly 2 parameters

Страниц (1): [1]
 

1. iKenny - 18 Апреля, 2013 - 10:35:00 - перейти к сообщению
Ребят, всем привет.

Есть такой вопрос, я в принципе по большей части занимаюсь ip телефонией. В данный момент настраиваю факс на yate. Кстати, могу помочь в этом вопросе.
Весь процесс разделил на 2 этапа, принятие .tif файла на хард, затем скриптом из crontab раз в N время
слать этот файл на e-mail. Скрипты писал не я, лежали в нете. Проблема вот в чем:
1. На этапе тестирования, подсовывая файл скрипту в папку(тестовый файл называется 1_022985493_022766520.TIF
Насколько я понял скрипт, он берет номер телефона и e-mail из базы данных. Вот содержание таблички users:
mysql> select * from users;
+----+-----------+----------+--------+------+----------+----------+-----------+----------------------+------+
| id | username | password | enable | mac | contract | vmstatus | faxstatus | fax2email | city |
+----+-----------+----------+--------+------+----------+----------+-----------+----------------------+------+
| 1 | 022766520 | NULL | NULL | NULL | NULL | NULL | 1 | kennyg1988@gmail.com | NULL |
+----+-----------+----------+--------+------+----------+----------+-----------+----------------------+------+
1 row in set (0.00 sec)

При выполнении скрипта получаю следующее:

./fax2email.php
PHP Notice: Undefined offset: 1 in /home/fax2email.php on line 19

Notice: Undefined offset: 1 in /home/fax2email.php on line 19
PHP Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in /home/fax2email.php on line 31

Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in /home/fax2email.php on line 31
PHP Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/fax2email.php on line 32

Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/fax2email.php on line 32
PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/fax2email.php on line 33

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/fax2email.php on line 33
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/fax2email.php on line 35

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/fax2email.php on line 35

Еще вопрос состоит в названии файла, насколько я понял часть скрипта:

PHP:
скопировать код в буфер обмена
  1. $caller = shell_exec('echo "'.$findcaller[1].'" | sed "s/[^_]*\_//"');
  2. $cutbillid = shell_exec('echo "'.$file.'" | sed "s/[^_]*\_//"');
  3. $findnumber = shell_exec('echo "'.$cutbillid.'" | sed "s/[^-]*\-//"');


его изменяет. Правильное-ли название .tif файла?

Вот сам скрипт.


PHP:
скопировать код в буфер обмена
  1. #!/usr/bin/php -q
  2. <?PHP
  3.  
  4. ini_set('display_errors', 'On');
  5.  
  6. /** ***********************************************************
  7. * Yate send fax2email
  8. * *************************************************************
  9. */
  10.  
  11. $faxdir = '/var/spool/fax/';
  12.  
  13. $dir = opendir("/var/spool/fax/");
  14. while(($file = readdir($dir)) !== false){
  15.         if (($file != ".") && ($file != "..")){
  16.                 $findcaller = explode('_', $file);
  17.                 $findcaller = explode('-', $file);
  18.                 $caller = shell_exec('echo "'.$findcaller[1].'" | sed "s/[^_]*\_//"');
  19.                 $cutbillid = shell_exec('echo "'.$file.'" | sed "s/[^_]*\_//"');
  20.                 $findnumber = shell_exec('echo "'.$cutbillid.'" | sed "s/[^-]*\-//"');
  21.                 $findnumber=str_replace(array("\r","\n"),"",$findnumber);
  22.                 $key = '.tif';
  23.                 $number=preg_replace('/'.$key.'.*/','',$findnumber);
  24.                 $showstatus = shell_exec('lsof | grep "'.$faxdir.'"*"'.$findnumber.'"');
  25.                 if ($showstatus <> ""){
  26.                         exit(0);
  27.                 }else{
  28. $db_link = mysqli_connect("127.0.0.1", "root", "admin")
  29.                                 or die("Could not connect: " . mysql_error());
  30.                         mysqli_select_db("centrexdb");
  31.                         $querry = mysqli_query("SELECT `fax2email` FROM users WHERE username='".$number."' AND faxstatus='1'");
  32.                         $fax2email = mysqli_fetch_array($querry);
  33.                         if ($fax2email[0] == ''){
  34.                                 $currdate = shell_exec('echo "'. date('Y-m-d_H:i:s') .'"');
  35.                                 $noemail = shell_exec('mv /var/spool/fax/"'.$file.'" /var/spool/fax-nomail/"'.$currdate.'"--"'.$file.'"$
  36.                        } else {
  37.                                $findcaller = explode('_', $file);
  38.                                $findcaller = explode('-', $file);
  39.                                $caller = shell_exec('echo "'.$findcaller[1].'" | sed "s/[^_]*\_//"');
  40.                                $caller=str_replace(array("\r","\n"),"",$caller);
  41.                                $sendmail = shell_exec('echo | mutt -a "'.$faxdir.'"*"'.$caller.'"-"'.$number.'".tif -s "Fax-"'.$caller$
  42.                                unlink(''.$faxdir.''.$file.'');
  43.                        }
  44.                        mysqli_close($db_link);
  45.                }
  46.        }
  47. }
  48.  
  49. exit(0);
  50. ?>


postfix и mutt я проверил, вручную комманда срабатывает.

При каждом выполнении скрипта файл помещается в папку no-email, т.е. в чем-то ошибка, толи с мускулем скрипт связаться не может, толи что-то с самим скриптом. Не подскажите в чем тут может быть проблема?

Система centos 5.8

Сам файл
http://www[dot]filedropper[dot]com/1022985493022766520
2. DeepVarvar - 18 Апреля, 2013 - 10:42:04 - перейти к сообщению
Содержимое файла *.tlf ?
(Добавление)
iKenny пишет:
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/fax2email.php on line 35
Тут все написано что надо сделать. Установить часовой пояс:

(Добавление)
iKenny пишет:
PHP Notice: Undefined offset: 1 in /home/fax2email.php on line 19

Формат файла не соответствует тому, что хочет разобрать скрипт, именно поэтому я просил его содержимое.
(Добавление)
iKenny пишет:
Warning: mysqli_select_db() expects exactly 2 parameters
Тут тоже все написано. Нужен линк на соединение:
PHP:
скопировать код в буфер обмена
  1. mysqli_select_db($db_link, "centrexdb");
3. iKenny - 18 Апреля, 2013 - 10:51:56 - перейти к сообщению
DeepVarvar пишет:
Содержимое файла *.tlf ?
(Добавление)
iKenny пишет:
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/fax2email.php on line 35
Тут все написано что надо сделать. Установить часовой пояс:

(Добавление)
iKenny пишет:
PHP Notice: Undefined offset: 1 in /home/fax2email.php on line 19

Формат файла не соответствует тому, что хочет разобрать скрипт, именно поэтому я просил его содержимое.
(Добавление)
iKenny пишет:
Warning: mysqli_select_db() expects exactly 2 parameters
Тут тоже все написано. Нужен линк на соединение:


Вот сам файл
http://www[dot]filedropper[dot]com/1022985493022766520
(Добавление)
C датой и файлом кажется разобрались, в скрипте раширение строчными, а в самом файле заглавными.
Дату вставил в скрипт.

Вот что получаю сейчас
PHP Notice: Undefined offset: 1 in /home/fax2email.php on line 21

Notice: Undefined offset: 1 in /home/fax2email.php on line 21
PHP Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/fax2email.php on line 34

Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/fax2email.php on line 34
PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/fax2email.php on line 35

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/fax2email.php on line 35
4. iKenny - 18 Апреля, 2013 - 14:04:13 - перейти к сообщению
Есть еще небольшой вопрос

Часть скрипта

if (($file != ".") && ($file != "..")){
$findcaller = explode('_', $file);
$findcaller = explode('-', $file);
$caller = shell_exec('echo "'.$findcaller[1].'" | sed "s/[^_]*\_//"');
$cutbillid = shell_exec('echo "'.$file.'" | sed "s/[^_]*\_//"');
$findnumber = shell_exec('echo "'.$cutbillid.'" | sed "s/[^-]*\-//"');

Эта часть скрипта, при имени файла 111_222-333.tif
Какие значения вернутся?

Заранее благодарю.

 

Powered by ExBB FM 1.0 RC1