14. januar 2002 - 20:12
Der er
25 kommentarer og 1 løsning
UPDATE
Hej Jeg kan ikke få denne til at virke, kan nogen hjælpe? $updateProfile = sprintf(\"UPDATE insite_users name=$name, adresse=$adresse, postnummer=$postnummer, bynavn=$bynavn, password=$password, birthday=$birthday, phone=$phone, mobile=$mobile, initials=$initials, email=$email WHERE id=\".$SESSION_ID); mysql_query($updateProfile);
Annonceindlæg tema
Cloud & AI
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
14. januar 2002 - 20:14
#1
$updateProfile = sprintf(\"UPDATE insite_users SET name=$name, adresse=$adresse, postnummer=$postnummer, bynavn=$bynavn, password=$password, birthday=$birthday, phone=$phone, mobile=$mobile, initials=$initials, email=$email WHERE id=\".$SESSION_ID);
14. januar 2002 - 20:14
#2
bemærk SET UPDATE tabel SET kolonne=værdi WHERE betingelse
14. januar 2002 - 20:17
#3
og måske skal der også nogle plinger om værdierne, så det bliver: $updateProfile = sprintf(\"UPDATE insite_users SET name=\'$name\', adresse=\'$adresse\', postnummer=\'$postnummer\', bynavn=\'$bynavn\', password=\'$password\', birthday=\'$birthday\', phone=\'$phone\', mobile=\'$mobile\', initials=\'$initials\', email=\'$email\' WHERE id=\".$SESSION_ID); forudsat at alle kolonnerne i tabellen er text/varchar ... hvis nogle af kolonnerne er int eller andre tal-typer skal der ikke plinger om disse værdier
14. januar 2002 - 20:19
#4
hmm, det ser sgu ikke rigtig ud til at virke. Er det den rigtige måde at gøre det på, hvor variablerne kommer fra en HTML form? Den vil ikke opdatere min database. Her er mit script, hvis det skulle hjælpe: <? include(\"../inc/dbconnect.inc\"); if ($command == update){ $updateProfile = sprintf(\"UPDATE insite_users SET name=$name, adresse=$adresse, postnummer=$postnummer, bynavn=$bynavn, password=$password, birthday=$birthday, phone=$phone, mobile=$mobile, initials=$initials, email=$email WHERE id=\".$SESSION_ID); mysql_query($updateProfile); $feedback = \"Your profile has been updated.\"; } //include templates define(\"CLASSPATH\",\"/serv/web/sharedfiles/Classes/\"); include (CLASSPATH . \"class.FastTemplate.php\"); $tpl = new FastTemplate(\".\"); $tpl ->define(array(\"table\" => \"profile.htm\")); // Henter brugere $query = \"SELECT name, adresse, postnummer, bynavn, password, birthday, phone, mobile, initials, email FROM insite_users WHERE id=\".$SESSION_ID; $fetch = mysql_query($query) or die ($query.\"<br>\".mysql_error()); $navneliste = mysql_fetch_array($fetch); $tpl->assign(\"name\", $navneliste[\"name\"]); $tpl->assign(\"adresse\", $navneliste[\"adresse\"]); $tpl->assign(\"postnummer\", $navneliste[\"postnummer\"]); $tpl->assign(\"bynavn\", $navneliste[\"bynavn\"]); $tpl->assign(\"password\", $navneliste[\"password\"]); $tpl->assign(\"birthday\", $navneliste[\"birthday\"]); $tpl->assign(\"phone\", $navneliste[\"phone\"]); $tpl->assign(\"mobile\", $navneliste[\"mobile\"]); $tpl->assign(\"initials\", $navneliste[\"initials\"]); $tpl->assign(\"email\", $navneliste[\"email\"]); if ($command == update){ $tpl->assign(\"feedback\", $feedback); } $tpl->parse(\"GLOBAL\", \"table\"); $tpl->FastPrint(); ?>
14. januar 2002 - 20:19
#5
ahh, det er nok plingerne :-)
14. januar 2002 - 20:22
#6
Denne slettede alt data i row\'en :-( $updateProfile = sprintf(\"UPDATE insite_users SET name=\'$name\', adresse=\'$adresse\', postnummer=\'$postnummer\', bynavn=\'$bynavn\', password=\'$password\', birthday=\'$birthday\', phone=\'$phone\', mobile=\'$mobile\', initials=\'$initials\', email=\'$email\' WHERE id=\".$SESSION_ID); mysql_query($updateProfile);
14. januar 2002 - 20:24
#7
if ($command == update){ skal måske være if ($command == \"update\"){
14. januar 2002 - 20:24
#8
ok, det skal den så ikke hvis du kom ind i betingelsen
14. januar 2002 - 20:24
#9
Det tror jeg ikke, for min $feedback = \"Your profile has been updated.\"; bliver kørt godt nok.
14. januar 2002 - 20:31
#10
prøv $updateProfile = \"UPDATE insite_users SET name=\'$name\', adresse=\'$adresse\', postnummer=\'$postnummer\', bynavn=\'$bynavn\', password=\'$password\', birthday=\'$birthday\', phone=\'$phone\', mobile=\'$mobile\', initials=\'$initials\', email=\'$email\' WHERE id=\".$SESSION_ID; mysql_query($updateProfile);
14. januar 2002 - 20:33
#11
desuden er det altid en god ide at få en fejlmeddelelse hvis noget går galt i query\'en - det får du ved at skrive mysql_query($updateProfile) or die(mysql_error());
14. januar 2002 - 21:05
#12
den sletter stadig min row: if ($command == update){ session_start(); $updateProfile = sprintf(\"UPDATE insite_users SET name=\'$name\', adresse=\'$adresse\', postnummer=\'$postnummer\', bynavn=\'$bynavn\', password=\'$password\', birthday=\'$birthday\', phone=\'$phone\', mobile=\'$mobile\', initials=\'$initials\', email=\'$email\' WHERE id=\".$SESSION_ID); mysql_query($updateProfile) or die(mysql_error()); $feedback = \"Your profile has been updated.\"; }
14. januar 2002 - 21:07
#13
ok - har du prøvet det jeg foreslog 20:31 ?
14. januar 2002 - 21:11
#14
jep, det virker heller ikke.
14. januar 2002 - 21:13
#15
har du prøvet at udskrive din query og se hvordan den egentlig ser ud? prøv echo $updateProfile;
14. januar 2002 - 21:18
#16
ahh, nu begynder det at ligne noget: UPDATE insite_users SET name=\'\', adresse=\'\', postnummer=\'\', bynavn=\'\', password=\'\', birthday=\'\', phone=\'\', mobile=\'\', initials=\'\', email=\'\' WHERE id=1
14. januar 2002 - 21:20
#17
dvs. den virker - hvordan ser den form ud du får værdierne fra?
14. januar 2002 - 21:29
#18
<html> <head> <title>Opfyldte ønsker</title> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> <link rel=\"stylesheet\" href=\"../stylesheet.css\" type=\"text/css\"> </head> <body bgcolor=\"#FFFFFF\" text=\"#000000\"> <form name=\"form1\" method=\"post\" action=\"profile.php\"> <table width=\"400\" border=\"0\"> <tr> <td height=\"20\" class=\"Text1\" width=\"75\">Employee:</td> <td height=\"20\" class=\"Text1\" colspan=\"2\">{name}</td> <td height=\"240\" class=\"Text1\" rowspan=\"16\" valign=\"top\"><img src=\"../images/employees/{initials}.gif\"></td> </tr> <tr> <td height=\"20\" width=\"75\"> </td> <td height=\"20\" colspan=\"2\"> </td> </tr> <tr> <td height=\"20\" width=\"75\" class=\"Text1\">Address:</td> <td height=\"20\" class=\"Text1\" colspan=\"2\"> <input type=\"text\" name=\"adresse\" value=\"{adresse}\" maxlength=\"30\"> </td> </tr> <tr> <td height=\"20\" width=\"75\" class=\"Text1\">Zip</td> <td height=\"20\" class=\"Text1\" colspan=\"2\"> <input type=\"text\" name=\"postnummer\" value=\"{postnummer}\" maxlength=\"4\"> </td> </tr> <tr> <td height=\"20\" width=\"75\" class=\"Text1\">City:</td> <td height=\"20\" class=\"Text1\" colspan=\"2\"> <input type=\"text\" name=\"bynavn\" value=\"{bynavn}\"> </td> </tr> <tr> <td height=\"20\" class=\"Text1\" width=\"75\"> </td> <td height=\"20\" class=\"Text1\" colspan=\"2\"> </td> </tr> <tr> <td height=\"20\" class=\"Text1\" width=\"75\">Birthday:</td> <td height=\"20\" class=\"Text1\" colspan=\"2\"> <input type=\"text\" name=\"birthday\" value=\"{birthday}\"> </td> </tr> <tr> <td height=\"20\" class=\"Text1\" width=\"75\">Phone:</td> <td height=\"20\" class=\"Text1\" colspan=\"2\"> <input type=\"text\" name=\"phone\" value=\"{phone}\"> </td> </tr> <tr> <td height=\"20\" class=\"Text1\" width=\"75\">Mobile:</td> <td height=\"20\" class=\"Text1\" colspan=\"2\"> <input type=\"text\" name=\"mobile\" value=\"{mobile}\"> </td> </tr> <tr> <td height=\"20\" width=\"75\"> </td> <td height=\"20\" colspan=\"2\"> </td> </tr> <tr> <td height=\"20\" class=\"Text1\" width=\"75\">Mail:</td> <td height=\"20\" colspan=\"2\"> <input type=\"text\" name=\"email\" value=\"{email}\"> </td> </tr> <tr> <td height=\"20\" width=\"75\"> </td> <td height=\"20\" colspan=\"2\"> </td> </tr> <tr> <td height=\"20\" width=\"75\" class=\"Text1\">Password:</td> <td height=\"20\" colspan=\"2\"> <input type=\"text\" name=\"password\" value=\"{password}\"> </td> </tr> <tr> <td height=\"20\" width=\"75\"> </td> <td height=\"20\" colspan=\"2\"> </td> </tr> <tr> <td height=\"20\" width=\"75\"> </td> <td height=\"20\" valign=\"top\"><a href=\"employees_list.php\">Back</a></td> <td height=\"20\" valign=\"top\"><a href=\"profile.php?command=update\">Update</a></td> </tr> <tr> <td height=\"20\" width=\"75\"> </td> <td height=\"20\" valign=\"top\" colspan=\"2\"> <div align=\"left\"><span class=\"Text1\">{feedback}</span></div> </td> </tr> </table> </form> <p> </p> <p> </p> </body> </html>
14. januar 2002 - 21:37
#19
<td height=\"20\" valign=\"top\"><a href=\"profile.php?command=update\">Update</a></td> denne linie submitter ikke formen prøv istedet <td height=\"20\" valign=\"top\"><a href=\"#\" onclick=\"document.form1.submit()\">Update</a></td> nu har du så ikke command med videre ... lav evt et hidden felt med name=command og value=1
14. januar 2002 - 21:37
#20
hov value=update, selvfølgelig
14. januar 2002 - 21:44
#21
Kan man ikke lave det uden en onClick?
14. januar 2002 - 21:49
#22
så skal du lave en submitbutton - et link sender dig jo bare videre til en anden side, det submitter ikke
14. januar 2002 - 21:59
#23
Hvordan fører jeg denne: <td height=\"20\" valign=\"top\"><a href=\"#\" onclick=\"document.form1.submit()\">Update</a></td> videre til profile.php
14. januar 2002 - 22:05
#24
det gør den via submit() action=\"profile.php\" som du har i dit formtag angiver at formen skal submittes til profile.php
14. januar 2002 - 22:12
#25
1000 tak!
14. januar 2002 - 22:15
#26
selv tak :-)
Vi tilbyder markedets bedste kurser inden for webudvikling