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
https://forums.phpfreaks.com/topic/9265-update-super-problam/
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
https://forums.phpfreaks.com/topic/9265-update-super-problam/#findComment-34129
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
https://forums.phpfreaks.com/topic/9265-update-super-problam/#findComment-34137
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
https://forums.phpfreaks.com/topic/9265-update-super-problam/#findComment-34140
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
https://forums.phpfreaks.com/topic/9265-update-super-problam/#findComment-34183
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.