Jump to content

Elton

Members
  • Content Count

    16
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Elton

  • Rank
    Newbie
  1. $query = "UPDATE `$dbname` SET name='%s', url='%s', short='%s', game='%s' WHERE name;";
  2. https://prnt.sc/sqsm7i it seems like it works partially but it imports incorrectly
  3. $query = "UPDATE `$dbname` SET name=%s, url=%s, short=%s, game=%s";
  4. <?php error_reporting(E_ALL); ini_set('display_errors', true); $dbname='in_dein_fall_test'; $json_datei='https://api.truckyapp.com/v2/traffic/servers'; $mysqli=mysqli_connect('localhost', 'root', '', 'db'); if (mysqli_connect_errno()) die ("Connect failed: " . mysqli_connect_error()); mysqli_set_charset($mysqli, "utf8"); // /* von hier auskommentieren nach ersten aufruf // bis hier auskkommentieren oder löschen*/ $query = "UPDATE `$dbname` SET (`name`, `url`, `short`, `game`) VALUES ('%s','%s','%s', '%s')"; $json = json_decode(file_get_contents($json_datei),true); $queries = array(); foreach ($json['response'] as $data){ $name=mysqli_real_escape_string($mysqli, $data['name']); $url=mysqli_real_escape_string($mysqli, $data['url']); $short=mysqli_real_escape_string($mysqli, $data['short']); $game=mysqli_real_escape_string($mysqli, $data['game']); $queries[] = sprintf($query, $name, $url, $short, $game); } $menge=count($queries); if (mysqli_multi_query($mysqli, implode(";", $queries))){ echo "$menge Datensätze erfolgreich importiert<br>"; }else{ echo "errors<br>"; } echo ""; $mysqli->close(); ?> https://prnt.sc/sqjsnc
  5. Yes the problem is I tried it with update but that does not work
  6. https://prnt.sc/sq96pa . https://prnt.sc/sq96ug whats wrong
  7. I ve already read through but I do not come across the problem
  8. Could they put me in the code I just do not know exactly how I do it so? $query = "INSERT INTO `$dbname` VALUES (`name`, `url`, `short`, `game`) ON DUPLICATE KEY UPDATE `name` = '%s', `url` = '%s', `short` = '%s', `game` = '%s'";
  9. <?php error_reporting(E_ALL); ini_set('display_errors', true); $dbname='in_dein_fall_test'; $json_datei='https://api.truckyapp.com/v2/traffic/servers'; $mysqli=mysqli_connect('localhost', 'root', '', 'db'); if (mysqli_connect_errno()) die ("Connect failed: " . mysqli_connect_error()); mysqli_set_charset($mysqli, "utf8"); // /* von hier auskommentieren nach ersten aufruf // bis hier auskkommentieren oder löschen*/ $query = "INSERT INTO `$dbname` (`name`, `url`, `short`, `game`) ON DUPLICATE KEY UPDATE `name` = '%s', `url` = '%s', `short` = '%s', `game` = '%s'"; $json = json_decode(file_get_contents($json_datei),true); $queries = array(); foreach ($json['response'] as $data){ $name=mysqli_real_escape_string($mysqli, $data['name']); $url=mysqli_real_escape_string($mysqli, $data['url']); $short=mysqli_real_escape_string($mysqli, $data['short']); $game=mysqli_real_escape_string($mysqli, $data['game']); $queries[] = sprintf($query, $name, $url, $short, $game); } $menge=count($queries); if (mysqli_multi_query($mysqli, implode(";", $queries))){ echo "$menge Datensätze erfolgreich importiert<br>"; }else{ echo "Irgendwelche errors<br>"; } echo ""; $mysqli->close(); if ($mysqli -> connect_errno) { echo "Failed to connect to MySQL: " . $mysqli -> connect_error; exit(); } // Perform a query, check for error if (!$mysqli -> query("INSERT INTO `in_dein_fall_test` (name) VALUES ('Glenn')")) { echo("Error description: " . $mysqli -> error); } ?> Thats the code
  10. if I do it so then come still error https://prnt.sc/splbgj $query = "INSERT INTO `$dbname` (`name`, `url`, `short`, `game`) ON DUPLICATE KEY UPDATE `name` = '%s', `url` = '%s', `short` = '%s', `game` = '%s'"; $json = json_decode(file_get_contents($json_datei),true); $queries = array(); foreach ($json['response'] as $data){ $name=mysqli_real_escape_string($mysqli, $data['name']); $url=mysqli_real_escape_string($mysqli, $data['url']); $short=mysqli_real_escape_string($mysqli, $data['short']); $game=mysqli_real_escape_string($mysqli, $data['game']); $queries[] = sprintf($query, $name, $url, $short, $game); } $menge=count($queries); if (mysqli_multi_query($mysqli, implode(";", $queries))){ echo "$menge Datensätze erfolgreich importiert<br>"; }else{ echo "Irgendwelche errors<br>"; } echo ""; $mysqli->close(); ?>
  11. It doesn't really matter, does it? but there are still mistakes https://prnt.sc/spkco6
  12. $query = "INSERT INTO `$dbname` (`name`, `url`, `short`, `game`) VALUES ('%s','%s','%s', '%s') ON DUPLICATE KEY UPDATE `name` = '%s', `url` = '%s', `short` = '%s', `game` = '%s'"; I have tried it with this code but it does not work
×
×
  • Create New...