Jump to content


Photo

update super problam.


  • Please log in to reply
5 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 May 2006 - 08:31 PM

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


Advance thank you.



<?


$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')";


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 07 May 2006 - 08:59 PM

you need to tell it where to update
update tablename set col1 = '$value1', col2 = '$value2'  where rowid = '$id'


#3 jeremywesselman

jeremywesselman
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts
  • LocationIndependence, KY

Posted 07 May 2006 - 09:00 PM

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.

<?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";
...
?>

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 May 2006 - 09:12 PM

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.

<? 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");
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 07 May 2006 - 09:22 PM

<? session_start();
$db=mysql_connect("localhost","xxx","xxx");
mysql_select_db("promotor",$db);
$query="UPDATE member_info SET id='$id' , name='$name', password='$password' , ....

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:
$name = $_GET['name'];


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.
Legend has it that reading the manual never killed anyone.
My site

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 May 2006 - 01:02 AM

i can not get this to work any idears please.

<? 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;
}
?>


query echoed
update member_info set number_of_musicans='0' where id='0006' 

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users