Форум программистов, компьютерный форум, киберфорум
PHP для начинающих
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.67/9: Рейтинг темы: голосов - 9, средняя оценка - 4.67
0 / 0 / 1
Регистрация: 09.04.2018
Сообщений: 3

Define HOST_WWW_ROOT

10.04.2018, 00:57. Показов 1815. Ответов 2
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Всем привет!
Не могу понять в чём проблема, если я правильно понимаю то мне нужно указать правильно путь к папкам, что я и делал но похоже не правильно
нужно указать где будут лежать картинки после загрузки.
Использую Wampserver32.
Каталог где лежат примеры
C:\wamp\www\Primer\primer9

create_user_html
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<html>
 <head>
  <link href="../phpMM2/css/phpMM.css" rel="stylesheet" type="text/css" />
 </head>
 
 <body>
  <div id="header"><h1>PHP & MySQL: The Missing Manual</h1></div>
  <div id="example">Example 7-2</div>
 
  <div id="content">
    <h1>Join the Missing Manual (Digital) Social Club</h1>
    <p>Please enter your online connections below:</p>
    <form action="create_user.php" method="POST"
          enctype="multipart/form-data">
      <fieldset>
        <label for="first_name">First Name:</label> 
        <input type="text" name="first_name" size="20" /><br />
        <label for="last_name">Last Name:</label> 
        <input type="text" name="last_name" size="20" /><br />
        <label for="email">E-Mail Address:</label> 
        <input type="text" name="email" size="50" /><br />
        <label for="facebook_url">Facebook URL:</label> 
        <input type="text" name="facebook_url" size="50" /><br />
        <label for="twitter_handle">Twitter Handle:</label> 
        <input type="text" name="twitter_handle" size="20" /><br />
        <input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
        <label for="user_pic_path">Upload a picture:</label> 
        <input type="file" name="user_pic_path" size="30" /><br />
        <label for="bio">Bio:</label> 
        <textarea name="bio" cols="40" rows="10"></textarea>
      </fieldset>
      <br />
      <fieldset class="center">
        <input type="submit" value="Join the Club" />
        <input type="reset" value="Clear and Restart" />
      </fieldset>
    </form>
  </div>
 
  <div id="footer"></div>
 </body>
</html>
create_user_php
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
 
require_once 'scripts/app_config.php';
require_once 'scripts/database_connection.php';
 
$upload_dir = HOST_WWW_ROOT . "/localhost/primer/uploads/";
$image_fieldname = "user_pic_path";
 
// Potential PHP upload errors
$php_errors = array(1 => 'Maximum file size in php.ini exceeded',
                    2 => 'Maximum file size in HTML form exceeded',
                    3 => 'Only part of the file was uploaded',
                    4 => 'No file was selected to upload.');
 
$first_name = trim($_REQUEST['first_name']);
$last_name = trim($_REQUEST['last_name']);
$email = trim($_REQUEST['email']);
$bio = trim($_REQUEST['bio']);
$facebook_url = str_replace("facebook.org", "facebook.com", 
                            trim($_REQUEST['facebook_url']));
$position = strpos($facebook_url, "facebook.com");
if ($position === false) {
  $facebook_url = "http://www.facebook.com/" . $facebook_url;
}
 
$twitter_handle = trim($_REQUEST['twitter_handle']);
$twitter_url = "http://www.twitter.com/";
$position = strpos($twitter_handle, "@");
if ($position === false) {
  $twitter_url = $twitter_url . $twitter_handle;
} else {
  $twitter_url = $twitter_url . substr($twitter_handle, $position + 1);
}
 
// Make sure we didn't have an error uploading the image
($_FILES[$image_fieldname]['error'] == 0)
  or handle_error("the server couldn't upload the image you selected.",
                  $php_errors[$_FILES[$image_fieldname]['error']]);
 
// Is this file the result of a valid upload?
@is_uploaded_file($_FILES[$image_fieldname]['tmp_name'])
  or handle_error("you were trying to do something naughty. Shame on you!",
                  "Uploaded request: file named " .
                  "'{$_FILES[$image_fieldname]['tmp_name']}'");
 
// Is this actually an image?
@getimagesize($_FILES[$image_fieldname]['tmp_name'])
  or handle_error("you selected a file for your picture " .
                  "that isn't an image.",
                  "{$_FILES[$image_fieldname]['tmp_name']} " .
                  "isn't a valid image file.");
 
// Name the file uniquely
$now = time();
while (file_exists($upload_filename = $upload_dir . $now .
                                     '-' .
                                     $_FILES[$image_fieldname]['name'])) {
    $now++;
}
 
// Finally, move the file to its permanent location
@move_uploaded_file($_FILES[$image_fieldname]['tmp_name'], $upload_filename)
  or handle_error("we had a problem saving your image to " .
                  "its permanent location.",
                  "permissions or related error moving " .
                  "file to {$upload_filename}");
 
$insert_sql = "INSERT INTO users (first_name, last_name, email, bio," .
                                 "facebook_url, twitter_handle," .
                                 "user_pic_path) " .
              "VALUES ('{$first_name}', '{$last_name}', '{$email}', '{$bio}', " .
                      "'{$facebook_url}', '{$twitter_handle}', " .
                      "'{$upload_filename}');";
 
// Insert the user into the database
mysql_query($insert_sql)
  or die(mysql_error());
 
// Redirect the user to the page that displays user information
header("Location: show_user.php?user_id=" . mysql_insert_id());
exit();
?>
show_user.php
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
 
require_once 'scripts/database_connection.php';
 
// Get the user ID of the user to show
$user_id = $_REQUEST['user_id'];
 
// Build the SELECT statement
$select_query = "SELECT * FROM users WHERE user_id = " . $user_id;
 
// Run the query
$result = mysql_query($select_query);
if ($result) {
  $row = mysql_fetch_array($result);
  $first_name     = $row['first_name'];
  $last_name      = $row['last_name'];
  $bio            = preg_replace("/[\r\n]+/", "</p><p>", $row['bio']);
  $email          = $row['email'];
  $facebook_url   = $row['facebook_url'];
  $twitter_handle = $row['twitter_handle'];
  $user_image     = get_web_path($row['user_pic_path']);
 
  // Turn $twitter_handle into a URL
  $twitter_url = "http://www.twitter.com/" . 
                 substr($twitter_handle, $position + 1);
} else {
  handle_error("There was a problem finding your " .
               "information in our system.",
               "Error locating user with ID {$user_id}");
 
}
 
?>                                  
 
<html>
 <head>
  <link href="../phpMM2/css/phpMM.css" rel="stylesheet" type="text/css" />
 </head>
 
 <body>
  <div id="header"><h1>PHP & MySQL: The Missing Manual</h1></div>
  <div id="example">User Profile</div>
 
  <div id="content">
    <div class="user_profile">
      <h1><?php echo "{$first_name} {$last_name}"; ?></h1>
      <p><img src="<?php echo $user_image; ?>" class="user_pic" />
        <?php echo $bio; ?></p>
      <p class="contact_info">Get in touch with <?php echo $first_name; ?>:</p>
      <ul>
        <li>...by emailing them at
          <a href="<?php echo $email; ?>"><?php echo $email; ?></a></li>
        <li>...by
          <a href="<?php echo $facebook_url; ?>">checking them out 
             on Facebook</a></li>
        <li>...by <a href="<?php echo $twitter_url; ?>">following them 
             on Twitter</a></li>
      </ul>
    </div>
  </div>
  <div id="footer"></div>
 </body>
</html>
app_config.php
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
 
// Set up debug mode
define("DEBUG_MODE", true);
 
// Site root
//в случае ошибки указать нормальный путь 
define("SITE_ROOT", "/primer/primer9/scripts/");
 
// Location of web files on host
define("HOST_WWW_ROOT", "/localhost/uploads/");
 
// Database connection constants
define("DATABASE_HOST", "localhost");
define("DATABASE_USERNAME", "root");
define("DATABASE_PASSWORD", "");
define("DATABASE_NAME", "mysql");
 
function debug_print($message) {
  if (DEBUG_MODE) {
    echo $message;
  }
}
 
function handle_error($user_error_message, $system_error_message) {
  header("Location: " . SITE_ROOT . "show_error.php?" .
         "error_message={$user_error_message}&" . 
         "system_error_message={$system_error_message}");
  exit();
}
 
function get_web_path($file_system_path) {
  return str_replace($_SERVER['DOCUMENT_ROOT'], '', $file_system_path);
}
?>
databases_connection.php
PHP
1
2
3
4
5
6
7
8
9
10
11
12
<?php
  require_once 'app_config.php';
 
  mysql_connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD)
    or handle_error("There was a problem connecting to the database " .
              "that holds the information we need to get you connected.",
              mysql_error());
 
  mysql_select_db(DATABASE_NAME)
    or handle_error("There's a configuration problem with our database.",
                     mysql_error());
?>
show_error.php
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
  require_once "app_config.php";
 
  if (isset($_REQUEST['error_message'])) {
    $error_message = preg_replace("/\\\\/", '', 
                                  $_REQUEST['error_message']);
  } else {
    $error_message = "Something went wrong, and that's " .
                     "how you ended up here.";
  }
 
  if (isset($_REQUEST['system_error_message'])) {
    $system_error_message = preg_replace("/\\\\/", '',
                            $_REQUEST['system_error_message']);  
  } else {
    $system_error_message = "No system-level error message was reported.";
  }
?>
 
<html>
 <head>
  <link href="../../phpMM2/css/phpMM.css" rel="stylesheet" type="text/css" />
 </head>
 
 <body>
  <div id="header"><h1>PHP & MySQL: The Missing Manual</h1></div>
  <div id="example">Uh oh... sorry!</div>
  <div id="content">
    <h1>We're really sorry...</h1>
    <p><img src="../images/error.jpg" class="error" />
      <?php echo $error_message; ?>
      <span></p>
    <p>Don't worry, though, we've been notified that there's a 
problem, and we take these things seriously. In fact, if you want to 
contact us to find out more about what's happened, or you have any 
concerns, just <a href="mailto:info@yellowtagmedia.com">email us</a> 
and we'll be happy to get right back to you.</p>
    <p>In the meantime, if you want to go back to the page that caused 
the problem, you can do that <a href="javascript:history.go(-1);">by 
clicking here.</a> If the same problem occurs, though, you may 
want to come back a bit later. We bet we'll have things figured 
out by then. Thanks again... we'll see you soon. And again, we're 
really sorry for the inconvenience.</p>
    <?php
      debug_print("<hr />");
      debug_print("<p>The following system-level message was received: <b>{$system_error_message}</b></p>");
    ?>
  </div>
  <div id="footer"></div> 
 </body>
</html>
Добавлено через 2 минуты
Если я правильно понимаю вот в этих строчках надо указать правильный путь, я указывал по разному но он так и не загружает картинку
Цитата Сообщение от Justeps25 Посмотреть сообщение
$upload_dir = HOST_WWW_ROOT . "/localhost/primer/uploads/";
Цитата Сообщение от Justeps25 Посмотреть сообщение
define("HOST_WWW_ROOT", "/localhost/uploads/");
Добавлено через 1 час 5 минут
нашёл ответ тут Error locating user with ID
0
cpp_developer
Эксперт
20123 / 5690 / 1417
Регистрация: 09.04.2010
Сообщений: 22,546
Блог
10.04.2018, 00:57
Ответы с готовыми решениями:

define
Здравствуйте define(name_1, 'Имя №1'); define(name_2, 'Имя №2'); define(name_3, 'Имя №3'); как вывести с цыклом?

по поводу функции DEFINE()
прочитал на php.su что функция обладает 3 параметрами - название, значение и учет регистра. вот открыл файл index.php в движке wordpress а...

Работает ли define в поисковике?
Добрый вечер, ребята! Подскажите если в тег title забивать константу define, будут ли это понимать поисковые системы? Вот вкратце...

2
0 / 0 / 1
Регистрация: 09.04.2018
Сообщений: 3
10.04.2018, 00:58  [ТС]
но появилась другая проблема не пойму в чем она вот скрин
Миниатюры
Define HOST_WWW_ROOT  
0
0 / 0 / 1
Регистрация: 09.04.2018
Сообщений: 3
10.04.2018, 01:10  [ТС]
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
 
require_once 'scripts/app_config.php';
require_once 'scripts/database_connection.php';
 
$upload_dir = HOST_WWW_ROOT . "uploads/profile_pics/";
$image_fieldname = "user_pic";
 
// Potential PHP upload errors
$php_errors = array(1 => 'Maximum file size in php.ini exceeded',
                    2 => 'Maximum file size in HTML form exceeded',
                    3 => 'Only part of the file was uploaded',
                    4 => 'No file was selected to upload.');
 
$first_name = trim($_REQUEST['first_name']);
$last_name = trim($_REQUEST['last_name']);
$email = trim($_REQUEST['email']);
$bio = trim($_REQUEST['bio']);
$facebook_url = str_replace("facebook.org", "facebook.com", 
                            trim($_REQUEST['facebook_url']));
$position = strpos($facebook_url, "facebook.com");
if ($position === false) {
  $facebook_url = "http://www.facebook.com/" . $facebook_url;
}
 
$twitter_handle = trim($_REQUEST['twitter_handle']);
$twitter_url = "http://www.twitter.com/";
$position = strpos($twitter_handle, "@");
if ($position === false) {
  $twitter_url = $twitter_url . $twitter_handle;
} else {
  $twitter_url = $twitter_url . substr($twitter_handle, $position + 1);
}
 
// Make sure we didn't have an error uploading the image
($_FILES[$image_fieldname]['error'] == 0)
  or handle_error("the server couldn't upload the image you selected.",
                  $php_errors[$_FILES[$image_fieldname]['error']]);
 
// Is this file the result of a valid upload?
@is_uploaded_file($_FILES[$image_fieldname]['tmp_name'])
  or handle_error("you were trying to do something naughty. Shame on you!",
                  "Uploaded request: file named " .
                  "'{$_FILES[$image_fieldname]['tmp_name']}'");
 
// Is this actually an image?
@getimagesize($_FILES[$image_fieldname]['tmp_name'])
  or handle_error("you selected a file for your picture " .
                  "that isn't an image.",
                  "{$_FILES[$image_fieldname]['tmp_name']} " .
                  "isn't a valid image file.");
 
// Name the file uniquely
$now = time();
while (file_exists($upload_filename = $upload_dir . $now .
                                     '-' .
                                     $_FILES[$image_fieldname]['name'])) {
    $now++;
}
 
// Finally, move the file to its permanent location
@move_uploaded_file($_FILES[$image_fieldname]['tmp_name'], $upload_filename)
  or handle_error("we had a problem saving your image to " .
                  "its permanent location.",
                  "permissions or related error moving " .
                  "file to {$upload_filename}");
 
$insert_sql = "INSERT INTO users (first_name, last_name, email, bio," .
                                 "facebook_url, twitter_handle," .
                                 "user_pic_path) " .
              "VALUES ('{$first_name}', '{$last_name}', '{$email}', '{$bio}', " .
                      "'{$facebook_url}', '{$twitter_handle}', " .
                      "'{$upload_filename}');";
 
// Insert the user into the database
mysql_query($con, $insert_sql)
  or die(mysql_error());
 
// Redirect the user to the page that displays user information
header("Location: show_user.php?user_id=" . mysql_insert_id($con));
exit();
?>
Добавлено через 10 минут
Рабочий код

HTML5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<html>
 <head>
  <link href="../phpMM2/css/phpMM.css" rel="stylesheet" type="text/css" />
 </head>
 
 <body>
  <div id="header"><h1>PHP & MySQL: The Missing Manual</h1></div>
  <div id="example">Example 7-2</div>
 
  <div id="content">
    <h1>Join the Missing Manual (Digital) Social Club</h1>
    <p>Please enter your online connections below:</p>
    <form action="create_user.php" method="POST"
          enctype="multipart/form-data">
      <fieldset>
        <label for="first_name">First Name:</label> 
        <input type="text" name="first_name" size="20" /><br />
        <label for="last_name">Last Name:</label> 
        <input type="text" name="last_name" size="20" /><br />
        <label for="email">E-Mail Address:</label> 
        <input type="text" name="email" size="50" /><br />
        <label for="facebook_url">Facebook URL:</label> 
        <input type="text" name="facebook_url" size="50" /><br />
        <label for="twitter_handle">Twitter Handle:</label> 
        <input type="text" name="twitter_handle" size="20" /><br />
        <input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
        <label for="user_pic">Upload a picture:</label> 
        <input type="file" name="user_pic" size="30" /><br />
        <label for="bio">Bio:</label> 
        <textarea name="bio" cols="40" rows="10"></textarea>
      </fieldset>
      <br />
      <fieldset class="center">
        <input type="submit" value="Join the Club" />
        <input type="reset" value="Clear and Restart" />
      </fieldset>
    </form>
  </div>
 
  <div id="footer"></div>
 </body>
</html>
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
 
require_once 'scripts/app_config.php';
require_once 'scripts/database_connection.php';
 
$upload_dir = HOST_WWW_ROOT . "uploads/profile_pics/";
$image_fieldname = "user_pic";
 
// Potential PHP upload errors
$php_errors = array(1 => 'Maximum file size in php.ini exceeded',
                    2 => 'Maximum file size in HTML form exceeded',
                    3 => 'Only part of the file was uploaded',
                    4 => 'No file was selected to upload.');
 
$first_name = trim($_REQUEST['first_name']);
$last_name = trim($_REQUEST['last_name']);
$email = trim($_REQUEST['email']);
$bio = trim($_REQUEST['bio']);
$facebook_url = str_replace("facebook.org", "facebook.com", 
                            trim($_REQUEST['facebook_url']));
$position = strpos($facebook_url, "facebook.com");
if ($position === false) {
  $facebook_url = "http://www.facebook.com/" . $facebook_url;
}
 
$twitter_handle = trim($_REQUEST['twitter_handle']);
$twitter_url = "http://www.twitter.com/";
$position = strpos($twitter_handle, "@");
if ($position === false) {
  $twitter_url = $twitter_url . $twitter_handle;
} else {
  $twitter_url = $twitter_url . substr($twitter_handle, $position + 1);
}
 
// Make sure we didn't have an error uploading the image
($_FILES[$image_fieldname]['error'] == 0)
  or handle_error("the server couldn't upload the image you selected.",
                  $php_errors[$_FILES[$image_fieldname]['error']]);
 
// Is this file the result of a valid upload?
@is_uploaded_file($_FILES[$image_fieldname]['tmp_name'])
  or handle_error("you were trying to do something naughty. Shame on you!",
                  "Uploaded request: file named " .
                  "'{$_FILES[$image_fieldname]['tmp_name']}'");
 
// Is this actually an image?
@getimagesize($_FILES[$image_fieldname]['tmp_name'])
  or handle_error("you selected a file for your picture " .
                  "that isn't an image.",
                  "{$_FILES[$image_fieldname]['tmp_name']} " .
                  "isn't a valid image file.");
 
// Name the file uniquely
$now = time();
while (file_exists($upload_filename = $upload_dir . $now .
                                     '-' .
                                     $_FILES[$image_fieldname]['name'])) {
    $now++;
}
 
// Finally, move the file to its permanent location
@move_uploaded_file($_FILES[$image_fieldname]['tmp_name'], $upload_filename)
  or handle_error("we had a problem saving your image to " .
                  "its permanent location.",
                  "permissions or related error moving " .
                  "file to {$upload_filename}");
 
$insert_sql = "INSERT INTO users (first_name, last_name, email, bio," .
                                 "facebook_url, twitter_handle," .
                                 "user_pic_path) " .
              "VALUES ('{$first_name}', '{$last_name}', '{$email}', '{$bio}', " .
                      "'{$facebook_url}', '{$twitter_handle}', " .
                      "'{$upload_filename}');";
 
// Insert the user into the database
mysql_query( $insert_sql)
  or die(mysql_error());
 
// Redirect the user to the page that displays user information
header("Location: show_user.php?user_id=" . mysql_insert_id());
exit();
?>
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
 
require_once 'scripts/database_connection.php';
 
// Get the user ID of the user to show
$user_id = $_REQUEST['user_id'];
 
// Build the SELECT statement
$select_query = "SELECT * FROM users WHERE user_id = " . $user_id;
 
// Run the query
$result = mysql_query($select_query);
if ($result) {
  $row = mysql_fetch_array($result);
  $first_name     = $row['first_name'];
  $last_name      = $row['last_name'];
  $bio            = preg_replace("/[\r\n]+/", "</p><p>", $row['bio']);
  $email          = $row['email'];
  $facebook_url   = $row['facebook_url'];
  $twitter_handle = $row['twitter_handle'];
  $user_image     = get_web_path($row['user_pic_path']);
 
  // Turn $twitter_handle into a URL
  $twitter_url = "http://www.twitter.com/" . 
                 substr($twitter_handle, $position + 1);
} else {
  handle_error("There was a problem finding your " .
               "information in our system.",
               "Error locating user with ID {$user_id}");
 
}
 
?>                                  
 
<html>
 <head>
  <link href="../phpMM2/css/phpMM.css" rel="stylesheet" type="text/css" />
 </head>
 
 <body>
  <div id="header"><h1>PHP & MySQL: The Missing Manual</h1></div>
  <div id="example">User Profile</div>
 
  <div id="content">
    <div class="user_profile">
      <h1><?php echo "{$first_name} {$last_name}"; ?></h1>
      <p><img src="<?php echo $user_image; ?>" class="user_pic" />
        <?php echo $bio; ?></p>
      <p class="contact_info">Get in touch with <?php echo $first_name; ?>:</p>
      <ul>
        <li>...by emailing them at
          <a href="<?php echo $email; ?>"><?php echo $email; ?></a></li>
        <li>...by
          <a href="<?php echo $facebook_url; ?>">checking them out 
             on Facebook</a></li>
        <li>...by <a href="<?php echo $twitter_url; ?>">following them 
             on Twitter</a></li>
      </ul>
    </div>
  </div>
  <div id="footer"></div>
 </body>
</html>
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
 
// Set up debug mode
define("DEBUG_MODE", true);
 
// Site root
//в случае ошибки указать нормальный путь 
define("SITE_ROOT", "/primer/primer9/scripts/");
 
// Location of web files on host
define("HOST_WWW_ROOT", "C:/wamp/www/Primer/");
 
// Database connection constants
define("DATABASE_HOST", "localhost");
define("DATABASE_USERNAME", "root");
define("DATABASE_PASSWORD", "");
define("DATABASE_NAME", "mysql");
 
function debug_print($message) {
  if (DEBUG_MODE) {
    echo $message;
  }
}
 
function handle_error($user_error_message, $system_error_message) {
  header("Location: " . SITE_ROOT . "show_error.php?" .
         "error_message={$user_error_message}&" . 
         "system_error_message={$system_error_message}");
  exit();
}
 
function get_web_path($file_system_path) {
  return str_replace($_SERVER['DOCUMENT_ROOT'], '', $file_system_path);
}
?>
PHP
1
2
3
4
5
6
7
8
9
10
11
12
<?php
  require_once 'app_config.php';
 
  mysql_connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD)
    or handle_error("There was a problem connecting to the database " .
              "that holds the information we need to get you connected.",
              mysql_error());
 
  mysql_select_db(DATABASE_NAME)
    or handle_error("There's a configuration problem with our database.",
                     mysql_error());
?>
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
  require_once "app_config.php";
 
  if (isset($_REQUEST['error_message'])) {
    $error_message = preg_replace("/\\\\/", '', 
                                  $_REQUEST['error_message']);
  } else {
    $error_message = "Something went wrong, and that's " .
                     "how you ended up here.";
  }
 
  if (isset($_REQUEST['system_error_message'])) {
    $system_error_message = preg_replace("/\\\\/", '',
                            $_REQUEST['system_error_message']);  
  } else {
    $system_error_message = "No system-level error message was reported.";
  }
?>
 
<html>
 <head>
  <link href="../../phpMM2/css/phpMM.css" rel="stylesheet" type="text/css" />
 </head>
 
 <body>
  <div id="header"><h1>PHP & MySQL: The Missing Manual</h1></div>
  <div id="example">Uh oh... sorry!</div>
  <div id="content">
    <h1>We're really sorry...</h1>
    <p><img src="https://www.cyberforum.ru/images/error.jpg" class="error" />
      <?php echo $error_message; ?>
      <span></p>
    <p>Don't worry, though, we've been notified that there's a 
problem, and we take these things seriously. In fact, if you want to 
contact us to find out more about what's happened, or you have any 
concerns, just <a href="mailto:info@yellowtagmedia.com">email us</a> 
and we'll be happy to get right back to you.</p>
    <p>In the meantime, if you want to go back to the page that caused 
the problem, you can do that <a href="javascript:history.go(-1);">by 
clicking here.</a> If the same problem occurs, though, you may 
want to come back a bit later. We bet we'll have things figured 
out by then. Thanks again... we'll see you soon. And again, we're 
really sorry for the inconvenience.</p>
    <?php
      debug_print("<hr />");
      debug_print("<p>The following system-level message was received: <b>{$system_error_message}</b></p>");
    ?>
  </div>
  <div id="footer"></div> 
 </body>
</html>
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
raxper
Эксперт
30234 / 6612 / 1498
Регистрация: 28.12.2010
Сообщений: 21,154
Блог
10.04.2018, 01:10
Помогаю со студенческими работами здесь

Можно ли в define() задать html код?
Всем привет.Подскажите можно ли в define() задать html код.Те.,сейчас текстовые переменные на сайте задаются с помощью этой ф-ции ...

Как реализовать директиву #define для создания шаблона отпределения #define ?
Здравствуйте уважаемые. При написании программы появилась необходимость задать шаблон создания #define через #define (извините за...

Скрытие столбцов. Ошибка App-define od obj-define error
Привет) помогите, пожалуйста, ответить на следующие вопросы: 1) выскакивает ошибка: App-define od obj-define error - как бы найти ее...

#define
#define зачем нужна это заголовочный файл какие у него функции и как им ползоватса?

c++11 и $define
Есть код который прекрасно компилируется без -std=c++11, но как только я включаю эту опцию то константы препроцессора не заменяются и...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
3
Ответ Создать тему
Новые блоги и статьи
Krabik - рыболовный бот для WoW 3.3.5a
AmbA 21.03.2026
без регистрации и смс. Это не торговля, приложение не содержит рекламы. Выполняет свою непосредственную задачу - автоматизацию рыбалки в WoW - и ничего более. Однако если админы будут против -. . .
Программный отбор значения справочника
Maks 21.03.2026
Процедура ВодителиНачалоВыбора(Элемент, ДанныеВыбора, ВыборДобавлением, СтандартнаяОбработка) / / Отключаем стандартную обработку (стандартное открытие формы выбора без фильтров) . . .
Переходник USB-CAN-GPIO
Eddy_Em 20.03.2026
Достаточно давно на работе возникла необходимость в переходнике CAN-USB с гальваноразвязкой, оный и был разработан. Однако, все меня терзала совесть, что аж 48-ногий МК используется так тупо: просто. . .
Оттенки серого
Argus19 18.03.2026
Оттенки серого Нашёл в интернете 3 прекрасных модуля: Модуль класса открытия диалога открытия/ сохранения файла на Win32 API; Модуль класса быстрого перекодирования цветного изображения в оттенки. . .
SDL3 для Desktop (MinGW): Рисуем цветные прямоугольники с помощью рисовальщика SDL3 на Си и C++
8Observer8 17.03.2026
Содержание блога Финальные проекты на Си и на C++: finish-rectangles-sdl3-c. zip finish-rectangles-sdl3-cpp. zip
Символические и жёсткие ссылки в Linux.
algri14 15.03.2026
Существует два типа ссылок — символические и жёсткие. Ссылка в Linux — это запись в каталоге, которая может указывать либо на inode «файла-ИСТОЧНИКА», тогда это будет «жёсткая ссылка» (hard link),. . .
[Owen Logic] Поддержание уровня воды в резервуаре количеством включённых насосов: моделирование и выбор регулятора
ФедосеевПавел 14.03.2026
Поддержание уровня воды в резервуаре количеством включённых насосов: моделирование и выбор регулятора ВВЕДЕНИЕ Выполняя задание на управление насосной группой заполнения резервуара,. . .
делаю науч статью по влиянию грибов на сукцессию
anaschu 13.03.2026
прикрепляю статью
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru