-1

i found this code that works in mysql to update a table form another tabel

UPDATE `tabel_overzicht` set indoor_km = (select sum(indoor_km) as total FROM `Fietsen_2018` WHERE datum LIKE '%/11/%'), outdoor_km = (select sum(outdoor_km) as total FROM `Fietsen_2018` WHERE datum LIKE '%/11/%'), indoor_hoogte = (select sum(indoor_hoogte) as total FROM `Fietsen_2018` WHERE datum LIKE '%/11/%'),outdoor_hoogte = (select sum(outdoor_hoogte) as total FROM `Fietsen_2018` WHERE datum LIKE '%/11/%'),totaal_km = (select sum(indoor_km) + sum(round(outdoor_km)) as total from Fietsen_2018 WHERE datum LIKE '%/11/%'),totaal_hoogte = (select sum(indoor_hoogte) + sum(round(outdoor_hoogte)) as total from Fietsen_2018 WHERE datum LIKE '%/11/%') where maand = "11-nov"

i putted this code in an php page

<?php
    session_start();
    $db = mysqli_connect('localhost', 'xx', 'xx', 'bruggie');// Check connection if (!$db) {die("Connection failed: " . mysqli_connect_error());}$sql = ($db, "UPDATE tabel_overzicht SET indoor_km = (select sum(indoor_km) as total FROM Fietsen_2018 WHERE datum LIKE '%/11/%'), outdoor_km = (select sum($
            $_SESSION['message'] = "Tabel zelf update uitgevoerd";
    }?>

but when i launch my php page i get an error

This page isn’t working www.bruggie.be is currently unable to handle this request. HTTP ERROR 500

  • Most likely a server related issue. PHP wouldn’t throw a 500 error given your script. – user9189147 Nov 02 '18 at 15:09
  • 1
    Go to the web server logs and solve the 5xx error. –  Nov 02 '18 at 15:19
  • You could try to setup a local DB with those tables and some example data, and run that PHP snippet locally against the DB. If that works this would mean as said by our fellow commenters that the error is indeed something serverside ¿is DB down? ¿are connection strings OK? ¿something else serverside?. If, and only if you discover it's actually a code problem, come back and update the question accordingly, if not, first try to solve the serverside quiestion, and if you can't, try to ask a clear and concise question maybe at https://serverfault.com/ – ElMesa Nov 02 '18 at 15:26
  • Note: The object-oriented interface to `mysqli` is significantly less verbose, making code easier to read and audit, and is not easily confused with the obsolete `mysql_query` interface. Before you get too invested in the procedural style it’s worth switching over. Example: `$db = new mysqli(…)` and `$db->prepare("…")` The procedural interface is an artifact from the PHP 4 era when `mysqli` API was introduced and should not be used in new code. – tadman Nov 02 '18 at 17:28
  • If you get errors like this the first thing to do is look at your server error logs. PHP is usually very specific about the exact problem that's happening and what line of code generated the fault. If you don't know where those logs are, look at your PHP config. If you're not logging errors for some reason, turn that on and run the page again. – tadman Nov 02 '18 at 17:29

1 Answers1

0

I see a closing curly brace } in your code but not an opening. Maybe that's causing the error.