Answer the question
In order to leave comments, you need to log in
Why doesn't mysql database accept php value?
I get the data, decode it, then using foreach I take the values by variables and put each one into the database.
But nothing changes in the database.
What is the problem?
<?php define('DB_HOST', 'localhost'); define('DB_USER', 'root'); define('DB_PASS', ''); define('DB_NAME', 'prise'); $conn = mysql_connect(DB_HOST, DB_USER, DB_PASS); if (!mysql_connect(DB_HOST, DB_USER, DB_PASS)) { exit('Cannot connect to server'); } if (!mysql_select_db(DB_NAME)) { exit('Cannot select database'); } mysql_query('SET NAMES utf8'); function parseCSMONEY(){ mb_internal_encoding("UTF-8"); $url = 'https://cs.money/load_all_bots_inventory?hash=1496393591316'; $file = file_get_contents($url); $jsondate = json_decode($file, true); //echo $file; foreach ($jsondate[ponyismylife] as $bot1) { $weapon = $bot1['m']; $price = $bot1['p']; $sql = "INSERT INTO prise (weapon, price) VALUES('$weapon','$price')"; } } if ( isset ($_POST['update']) ) { // нажата кнопка: parseCSMONEY(); echo "обновлено";
}
Answer the question
In order to leave comments, you need to log in
try like this
$sql = mysql_query("INSERT INTO prise (weapon, price) VALUES '$weapon','$price');
Reconsider your implementation in favor of PDO , it will be more relevant, simpler, clearer and safer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question