Jump to content

update super problam.


redarrow

Recommended Posts

my code wont update any idears please, there a mysql problam but dont see it can you.


Advance thank you.



[code]
<?


$db=mysql_connect("localhost","xxx","xxx");
mysql_select_db("promotor",$db);


$query="UPDATE member_info SET id='$id' , name='$name', password='$password' , email='$email' , band_name='$band_name' ,
music_played='$music_played' , number_of_musicans='$number_of_musicans' , playing_history='$playing_history' ,
band_personalty='$band_personalty' , number_of_played_venues='$number_of_played_venues' ,
club='$club' , pub='$pub' , partys='$partys' , functions='$functions' , house_party='$house_party' , weedings='$weedings' ,
churches='$churches',how_much_per_hour_do_you_charge='$how_much_per_hour_do_you_charge' , cash='$cash' ,

credit_card='$credit_card' , both='$both' , terms_condition='$terms_condition' , not_play_out_date='$not_play_out_date' ,
dates1='$dates1' , dates2='$dates2' , dates3='$dates3' , dates4='$dates4' ,
date_added='$date_added' , end_date='$end_date' , user_ip='$user_ip' , level='$level'";



$result=mysql_query($query) or die("sorry my_sql problam");
?>


//This insert code works but need update code.

$query="INSERT INTO member_info values('$id','$name','$password','$email','$band_name','$music_played', '$number_of_musicans','$playing_history','$band_personalty','$number_of_played_venues', '$club','$pub','$partys','$functions','$house_party','$weedings','$churches', '$how_much_per_hour_do_you_charge', '$cash', '$credit_card', '$both', '$terms_condition','$not_play_out_date' , '$dates1' , '$dates2' , '$dates3' , '$dates4', '$date_added','$end_date','$user_ip','$level')";

[/code]
Link to comment
Share on other sites

When updating a record, you have to tell it which record to update. You are not doing this. You will tell it which record you want to update by using your table's primary key. Which should be 'id' if your table is set up correctly.

[code]<?php
...
$query="UPDATE member_info SET name='$name', password='$password', email='$email', band_name='$band_name', music_played='$music_played', number_of_musicans='$number_of_musicans', playing_history='$playing_history', band_personalty='$band_personalty', number_of_played_venues='$number_of_played_venues', club='$club' , pub='$pub' , partys='$partys', functions='$functions', house_party='$house_party', weedings='$weedings',
churches='$churches', how_much_per_hour_do_you_charge='$how_much_per_hour_do_you_charge', cash='$cash', credit_card='$credit_card', both='$both', terms_condition='$terms_condition', not_play_out_date='$not_play_out_date', dates1='$dates1', dates2='$dates2', dates3='$dates3', dates4='$dates4',
date_added='$date_added', end_date='$end_date', user_ip='$user_ip', level='$level' WHERE id = $id";
...
?>[/code]

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]
Link to comment
Share on other sites

I added the link from the members main page

echo'<a href="update.php?name=$name">Update Your Informaton</a>';


still an error

session_start on the members page.

The name is in the link at the end and WHERE name='$name' is in the update query wiered.

aAso check the session exists on the update.php all works.

[code]
<? session_start();


$db=mysql_connect("localhost","xxx","xxx");
mysql_select_db("promotor",$db);


$query="UPDATE member_info SET id='$id' , name='$name', password='$password' , email='$email' , band_name='$band_name' ,
music_played='$music_played' , number_of_musicans='$number_of_musicans' , playing_history='$playing_history' ,
band_personalty='$band_personalty' , number_of_played_venues='$number_of_played_venues' ,
club='$club' , pub='$pub' , partys='$partys' , functions='$functions' , house_party='$house_party' , weedings='$weedings' ,
churches='$churches',how_much_per_hour_do_you_charge='$how_much_per_hour_do_you_charge' , cash='$cash' ,

credit_card='$credit_card' , both='$both' , terms_condition='$terms_condition' , not_play_out_date='$not_play_out_date' ,
dates1='$dates1' , dates2='$dates2' , dates3='$dates3' , dates4='$dates4' ,
date_added='$date_added' , end_date='$end_date' , user_ip='$user_ip' , level='$level' WHERE name='$name'";



$result=mysql_query($query) or die("sorry my_sql problam");
?>
[/code]
Link to comment
Share on other sites

[code]<? session_start();
$db=mysql_connect("localhost","xxx","xxx");
mysql_select_db("promotor",$db);
$query="UPDATE member_info SET id='$id' , name='$name', password='$password' , ....[/code]
Exactly where are those variables coming from. Looks like you're relying on register_globals being ON (not true on current versions).

Since $name is passed via URL, it needs to be retrieved from the $_GET array:
[code]$name = $_GET['name'];[/code]

I have no idea where the rest of your variables come from, but test it by echoing the query string to see if what you expected is really what you're getting.
Link to comment
Share on other sites

i can not get this to work any idears please.

[code]
<? session_start();
$db=mysql_connect("localhost" ,"xxx","xxx");
mysql_select_db("promotor",$db);

$query="select * from member_info where id='$id'";
$result=mysql_query($query) or die("sorry my_sql problam");


while($row=mysql_fetch_assoc($result)) {


$number_of_musicans=$row["number_of_musicans"];


$update="update member_info set number_of_musicans='$number_of_musicans' where id='$id' ";
$update_result=mysql_query($update);

echo $update;
}
?>
[/code]


query echoed
[code]
update member_info set number_of_musicans='0' where id='0006'
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.