Forum Moderators: coopster

Message Too Old, No Replies

i lost my update form

         

myacidpacemaker

1:40 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



i accidently saved over my edit/modify form for updating info in db & cant remember the sql to do it.

this is coding for my add form

<?php
error_reporting(E_ALL);
require '../main.inc.php';

$ACTION = @$_REQUEST['action'];
if(!$ACTION) $ACTION = 'index';

if($ACTION == 'index') {
$profile_id = $_GET['profile_id'];
$contact = mysql_query("SELECT profile_id FROM profiles WHERE $profile_id = profile_id");
}
elseif($ACTION == 'post_mix') {
$dj_name = $_GET['dj_name'];
$profile_id = $_GET['profile_id'];

// add the mix entry to the database
// fields are:
$infields = array('mix_id','dj_name','mix_name','mix_date','mix_style','mix_tracklist', 'mix_size', 'mix_duration','mix_bitrate', 'mix_comments', 'mix_url','cue_url','stream_url','stats_url','active');

// the id's are in the format of '002' etc
list($lastid) = mysql_fetch_row(mysql_query("SELECT mix_id FROM mixes ORDER BY mix_id DESC LIMIT 1"));
$thisid = '0' . sprintf("%02d", intval(substr($lastid,1)) + 1);

// insert into the mixes table
$res = mysql_query("INSERT INTO mixes VALUES('$thisid', '".addslashes($dj_name)."','". addslashes($mix_name). "','".addslashes($mix_date)."','".addslashes($mix_style) ."','".addslashes($mix_tracklist)."','". addslashes($mix_size). "','".addslashes($mix_duration). "','".addslashes($mix_bitrate). "','".addslashes($mix_comments). "','".addslashes($mix_url)."','". addslashes($cue_url)."','". addslashes($stream_url)."','". addslashes($stats_url)."','". addslashes($active)."')");
if(!$res) die(mysql_error());

//done, go back to the index
header("Location: saved_mix.php?profile_id=$profile_id");
exit;
}
?>

would appreciate anyone's help/. thnx in advance

[edited by: jatar_k at 4:53 pm (utc) on Aug. 10, 2005]
[edit reason] fixed sidescroll [/edit]

myacidpacemaker

1:46 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



i know i need to add a

$mix_id = $_GET['mix_id']; to get the id from the url & to change the insert line to something like...

// update the mixes table
$res = mysql_query("UPDATE mixes SET... WHERE $mix_id = mix_id");

FiRe

1:56 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



other way round!

$res = mysql_query("UPDATE mixes SET... WHERE mix_id = '$mix_id'");

coopster

2:09 am on Aug 12, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, myacidpacemaker.

Nice catch, FiRe. Did you get it sorted, myacidpacemaker?

myacidpacemaker

4:00 am on Aug 17, 2005 (gmt 0)

10+ Year Member



thnx for the welcome coopster.

i kinda got it sorted. the page pulls the data from db correctly & when i make changesto the data & click submit it goes to my saved changes page except it doesnt actually update the data. i must have missed something. code is below

<?php

error_reporting(E_ALL);

require '../main.inc.php';

$ACTION = @$_REQUEST['action'];

if(!$ACTION) $ACTION = 'index';

if($ACTION == 'index') {

$profile_id = $_GET['profile_id'];

$menu_breadcrumb = mysql_query("SELECT profile_id FROM profiles WHERE $profile_id = profile_id");

$edit_mix = mysql_query("SELECT * FROM mixes WHERE mix_id = $mix_id");

}

elseif($ACTION == 'post_mix') {

$dj_name = $_GET['dj_name'];

$profile_id = $_GET['profile_id'];

$mix_id = $_GET['mix_id'];

// add the mix entry to the database

// fields are:

$infields = array('mix_id','dj_name','mix_name','mix_date','mix_style','mix_tracklist', 'mix_size', 'mix_duration','mix_bitrate', 'mix_comments');

// update the mixes table

$res = mysql_query("UPDATE mixes SET dj_name='$dj_name', mix_name='$mix_name', mix_date='$mix_date', mix_style='$mix_style', mix_tracklist='$mix_tracklist', mix_size='$mix_size', mix_duration='$mix_duration', mix_bitrate='$mix_bitrate', mix_comments='$mix_comments' WHERE $mix_id = 'mix_id'");

if(!$res) die(mysql_error());

//done, go back to the index

header("Location: saved_mix.php?profile_id=$profile_id");

exit;

}

?>