1

PDO接続をdbconnect.phpファイルに追加してから、すべてのヘッダーリダイレクトが機能しなくなりました。これが私の接続ファイルです

connect.php

<?php 

$connect_error = 'Sorry there is a problem with the database connection.';
mysql_connect('Localhost', 'customn7', 'I<3deadlifts!') or die($connect_error);
mysql_select_db('customn7_cm') or die($connect_error) or die($connect_error);
?>

<?php   

//PDO database connect
$config['db'] = array(
    'host'      => 'Localhost',
    'username'  => 'customn7',
    'password'  => 'I<3deadlifts!',
    'dbname'    => 'customn7_cm'
);

try {
$db = new PDO('mysql:host=' .$config['db']['host']. ';dbname=' .$config['db']['dbname'], $config['db']['username'], $config['db']['password']);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->exec("SET CHARACTER SET utf8");
} 

catch(PDOException $e) {
echo "ERROR: " . $e->getMessage() . "<br />";
die();
}


?>

そして、これが突然機能しなくなったリダイレクトです。この時点では、HTMLはブラウザに送信されていません。

login.php

// Post Selected name to current class.
if (isset($_POST['exist_to_class'])){
if (empty($_POST['client_data']) === true){
    $errors [] = 'You much select a client to be added to the class.';
} else {
    if (isset($_POST['client_data']) && !empty($_POST['client_data']));
    foreach ($_POST['client_data'] as $cd){
     exist_client_to_class($db, $cd);
     header('Location: view_class.php?class_id='.$class_id.' ');
    } // foreach $cd
} // else

} //isset

init.php

<?php
session_start();

error_reporting(E_ALL);
error_reporting(E_NOTICE);


require 'database/connect.php';
require 'functions/users.php';
require 'functions/general.php';
require 'functions/trainer.php';
?>

connect.php

<?php 

$connect_error = 'Sorry there is a problem with the database connection.';
mysql_connect('Localhost', 'customn7', '**********') or die($connect_error);
mysql_select_db('customn7_cm') or die($connect_error) or die($connect_error);
?>
4

1 に答える 1

2

何かを印刷した場合、header. エラー処理を再検討することをお勧めします。

于 2012-11-21T18:06:59.640 に答える