0

Mysql seems not inserting in my table even if there is no error displayed, I even used

error_reporting(E_ALL);
ini_set('display_errors', '1');

but it always dosent return anything, there is my code:

the connexion file

<?php
class Connexion
{
    public static function cnx()
    {
        try{
            $db=new PDO('mysql:host=localhost;dbname=championship','root','');
            return $db;
        }
        catch(Exception $e){
            die('Erreur :'.$e->getMessage());
        }   
    }
}
?>

the main file

<?php

session_start();
include_once("../cnx.php");
include_once('theme.php');
include_once('criteria.php');

$num_rows=Criteria::countCriteria();

$id_theme=$_GET['id_theme'];
for ($i = 1; ; $i++) {
    if ($i > $num_rows) {
        break;
    }

    Criteria::saveScoreByCriteria($_SESSION['user']['id'],$i,$_POST["mark_criteria$i"],$_POST["comment_criteria$i"],$id_theme);
}

Theme::saveJudgeScore($id_theme,$_SESSION['user']['id'],$_POST["judge_general_comment"]);
header("location:list_theme.php");

?>

and this the function saveScoreByCriteria($id_judge,$id_criteria,$mark,$comment,$id_theme)

<?php
public static function saveScoreByCriteria($id_judge,$id_criteria,$mark,$comment,$id_theme) 
{
    $cnx=new Connexion();
    $db=$cnx->cnx(); 
    $req=$db->prepare("INSERT INTO `judge_criteria`( `id_judge`, `id_criteria`, `mark`, `comment`, `id_theme`) values (:id_judge,:id_criteria,:mark,:comment,:id_theme)");
    $req->execute(array(':id_judge'=>$id_judge,':id_criteria'=>$id_criteria,':mark'=>$mark,':comment'=>$comment,':id_theme'=>$id_theme));

}
?>

Hope that somebody could help me! thanks.

here is the complete error log file

[Thu Oct 06 08:31:40.250444 2016] [mpm_winnt:notice] [pid 7872:tid 292] AH00428: Parent: child process 5128 exited with status 1073807364 -- Restarting.
[Thu Oct 06 08:35:32.354324 2016] [ssl:warn] [pid 5572:tid 296] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Oct 06 08:35:32.619524 2016] [core:warn] [pid 5572:tid 296] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Thu Oct 06 08:35:33.274725 2016] [ssl:warn] [pid 5572:tid 296] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Oct 06 08:35:36.925132 2016] [mpm_winnt:notice] [pid 5572:tid 296] AH00455: Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9 configured -- resuming normal operations
[Thu Oct 06 08:35:36.925132 2016] [mpm_winnt:notice] [pid 5572:tid 296] AH00456: Apache Lounge VC11 Server built: Nov 21 2013 20:13:01
[Thu Oct 06 08:35:36.925132 2016] [core:notice] [pid 5572:tid 296] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Thu Oct 06 08:35:36.956332 2016] [mpm_winnt:notice] [pid 5572:tid 296] AH00418: Parent: Created child process 4244
[Thu Oct 06 08:35:38.251134 2016] [ssl:warn] [pid 4244:tid 308] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Oct 06 08:35:39.093535 2016] [ssl:warn] [pid 4244:tid 308] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Oct 06 08:35:39.171535 2016] [mpm_winnt:notice] [pid 4244:tid 308] AH00354: Child: Starting 150 worker threads.
[Thu Oct 06 14:06:00.652885 2016] [mpm_winnt:notice] [pid 5572:tid 296] AH00428: Parent: child process 4244 exited with status 1073807364 -- Restarting.
[Thu Oct 06 14:21:10.787495 2016] [ssl:warn] [pid 1200:tid 296] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Oct 06 14:21:10.959095 2016] [core:warn] [pid 1200:tid 296] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Thu Oct 06 14:21:11.473896 2016] [ssl:warn] [pid 1200:tid 296] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Oct 06 14:21:14.709503 2016] [mpm_winnt:notice] [pid 1200:tid 296] AH00455: Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9 configured -- resuming normal operations
[Thu Oct 06 14:21:14.709503 2016] [mpm_winnt:notice] [pid 1200:tid 296] AH00456: Apache Lounge VC11 Server built: Nov 21 2013 20:13:01
[Thu Oct 06 14:21:14.709503 2016] [core:notice] [pid 1200:tid 296] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Thu Oct 06 14:21:14.740703 2016] [mpm_winnt:notice] [pid 1200:tid 296] AH00418: Parent: Created child process 648
[Thu Oct 06 14:21:16.581506 2016] [ssl:warn] [pid 648:tid 308] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Oct 06 14:21:17.252307 2016] [ssl:warn] [pid 648:tid 308] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Oct 06 14:21:17.314707 2016] [mpm_winnt:notice] [pid 648:tid 308] AH00354: Child: Starting 150 worker threads.
  • 2
    Start monitoring your http servers error log file. You _cannot_ program in php in a http server environment _without_ monitoring that file. – arkascha Oct 06 '16 at 15:39
  • can you please explane how that should be , cuz I m a newbie in php – Kamal Essoufi Oct 06 '16 at 15:41
  • Your http server writes an error log file. That is where under normal situations all issues with a request are logged to. So also php issues. That should _always_ be the first place to look at. – arkascha Oct 06 '16 at 15:42
  • Method `cnx` is defined as static. Should you not be calling it as `$cnx = Connexion::cnx()` – RiggsFolly Oct 06 '16 at 15:56
  • In XAMPP there will be a specific `php_error.log` I think (been a while) – RiggsFolly Oct 06 '16 at 15:59

1 Answers1

0

This line may be causing you the problem, using static method on non static manner

  $db = $cnx->cnx();

Use this instead

  $db = Connexion::cnx();
A l w a y s S u n n y
  • 36,497
  • 8
  • 60
  • 103