Jump to content

Recommended Posts

Posted

Salut, nu stiu daca am postat unde trebuie, dar am o problema si nu inteleg de la ce .Nu mi se face update-ul.

<?php
$get_status = Config::$dbh->prepare(' SELECT * FROM `settings` WHERE `id` = 1 ');
$get_status->execute();
$get_info_about_status = $get_status->fetch(PDO::FETCH_ASSOC);

$get_status_logical_express = $get_info_about_status['val'];
if( $get_status_logical_express == 0 ) {
$status = 1;
} elseif ($get_status_logical_express == 1) {
$status = 0;
}

if( isset( $_POST['start_maintenance'] ) ) {

$qas = Config::$dbh->prepare(' UPDATE `settings` SET `val` = ? WHERE `id` = 1 ');
$qas->execute( array( $status ) );

}
?>

<form method="POST">
  <button type="submit" name="start_maintenance">Da</button>
</form>

Sper sa mi se explice civilizat :) . 

  • gaby changed the title to PHP start maintenance: am gresit ceva?

  • Moderators
Posted

Ajunge sa intre in?:

if( isset( $_POST['start_maintenance'] ) ) {

Poti verifica cu un echo, var_dump, log in fisier, etc.

Dupa cum arata codu ar trebuii sa intre fara probleme, poti verifica si logu de erori de la apache sau ce folosesti sa testezi local / server.

PHP Developer - Not available for freelancing right now

Daca ai de gand sa postezi la categoria IPB, nu uita sa citesti regulamentul: Link regulament

Posted
2 hours ago, gadeas said:

Ajunge sa intre in?:


if( isset( $_POST['start_maintenance'] ) ) {

Poti verifica cu un echo, var_dump, log in fisier, etc.

Dupa cum arata codu ar trebuii sa intre fara probleme, poti verifica si logu de erori de la apache sau ce folosesti sa testezi local / server.

Pai, am verificat tot (am dat var_dump/print/echo la tot) si in log-uri nu am nicio eroare 

Poate am gresit ceva in baza de date :s 

2 hours ago, gadeas said:

Ajunge sa intre in?:

Scuze, nu am inteles la ce te referi

db.PNG

  • Moderators
Posted

Ma refer daca pui un echo sau var_dump inauntru if-ului, iti apare afisat pe pagina odata ce apesi butonu Da?

PHP Developer - Not available for freelancing right now

Daca ai de gand sa postezi la categoria IPB, nu uita sa citesti regulamentul: Link regulament

  • Moderators
Posted

Nu prea inteleg, daca totu e ok, ar trebuii sa mearga fara probleme, uita codu meu de probe:
 

<?php
$host = 'localhost';
$dbName = 'testing';
$username = 'alex';
$password = 'pctTest';

$dbCon = new PDO("mysql:host=" . $host . ";dbname=" . $dbName, $username, $password);
//$qas = $dbCon->prepare('INSERT INTO `settings` (`set_name`, `val`, `opt_text`) VALUES (?, ?, ?)');
//$qas->execute(array('Testing', '0', 'Test insert and update'));

if (isset($_POST['start_maintenance'])) {
    $get_status = $dbCon->prepare(' SELECT * FROM `settings` WHERE `id` = 1 ');
    $get_status->execute();
    $get_info_about_status = $get_status->fetch(PDO::FETCH_ASSOC);

    $get_status_logical_express = $get_info_about_status['val'];
    if ($get_status_logical_express == 0) {
        $status = 1;
    } elseif ($get_status_logical_express == 1) {
        $status = 0;
    }

    echo "Old status is: {$get_status_logical_express}, the new one is: {$status}";
    $qas = $dbCon->prepare(' UPDATE `settings` SET `val` = ? WHERE `id` = 1 ');
    $qas->execute(array($status));
}
?>

<form method="POST">
    <button type="submit" name="start_maintenance">Da</button>
</form>

 

  • Like 1
  • Thanks 1

PHP Developer - Not available for freelancing right now

Daca ai de gand sa postezi la categoria IPB, nu uita sa citesti regulamentul: Link regulament

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.