php - form to update not updating pretty confused -


ok have tried few different pieces of code find not doing want , should do, have form allows users change row selected when change text in text boxes click submit button goes editdata.php doesn't change it.

any appreciated!

the form:

<table> <?php mysql_connect("localhost", "x", "x") or die(mysql_error()); mysql_select_db("x") or die(mysql_error()); $order = "select track_name, contents track track_id='".$_session['user']['track_id']."'"; $result = mysql_query($order); $row = mysql_fetch_array($result);   ?> <form method="post" action="edit_data.php"> <tr> <th>track name</th> <th>contents</th> </tr> <tr> <td><input type="text" name="track_name" id="track_name" value=" <? echo     ($row['track_name']); ?> "></td> <td><input type="text" name="contents" id="contents" size="20" value=" <? echo ($row['contents']); ?> "></td> </tr> <tr> <td align="right"> <input type="submit" name="submit value" value="edit"> </td> </tr> </form> </table> 

edit_data.php

<?php ob_start();  mysql_connect("localhost", "x", "x") or die(mysql_error());  mysql_select_db("x") or die(mysql_error());  $track_name = $_post['track_name']; $contents = $_post['contents'];    $order = ("update track             set track_name = $track_name,                 contents = $contents              track_id = '".$_session['user']['track_id']."' ")   or die(mysql_error());   header("location:tracks"); ?> 

you can this.

$conn = mysqli_connect("localhost", "x", "x","db_name");  $query = "update track         set track_name = '".$track_name."',             contents = '".$contents."'          track_id = ".$_session['user']['track_id'];  mysqli_query($conn, $query); 

i use mysqli_query since mysql deprecated.

note: edit clause fit if track_id integer. no need put inside quote.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -