php - SQL database not inserting data? -


i working on program takes html code made wysiwyg editor , inserting database, redirecting user completed page, reads code off database. can manually enter code in phpmyadmin , works in php code not overwrite entry in code column id specified. have provided php code me. php not giving me parse errors. incorrect following code?

<?php  //post variables------------------------------------------------------------------------    //$rawcode = $_post[ 'editor1' ];    //$code = mysqli_real_escape_string($rawcode);    $code = 'good';    $id = "1";    echo "$code";   //sql variables-------------------------------------------------------------------------    $database = mysqli_connect("localhost" , "root" , "password" , "database");  //insert query data here----------------------------------------------------------------    $queryw = "insert users (code) values('$code') id = '" . $id . "'";    mysqli_query($queryw, $database);  //redirect login page----------------------------------------------------------------    echo "<script type='text/javascript'>\n";    echo "window.location = 'http://url.com/users/" . $id . "/default.htm';\n";    echo "</script>"; ?> 

your problem mysql insert not support where. change query to:

insert users (code) values ('$code') 

then update record, use

update users set code = '$code' id = $id 

of course, prepare statements.

additionally, mysqli_query requires first parameter connection , second string. have reversed. see here: http://php.net/manual/en/mysqli.query.php

it should noted kind of procedure should run before output browser. if so, can use php's header relocate instead of js workaround. however, method still work want. considered cleaner if queries , relocation done @ beginning of script.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -