Hi
I hope somone can help me. my update form wil not work and i don''t know what's wrong.
i got everything work only this not please help
Here is the code

<html><head><title>Terminkalender Change form</title>
<style type="text/css">
td {font-family: tahoma, arial, verdana; font-size: 10pt }
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

</head>
<body>

<?
$id=$_POST;
$db="wordpress";
$link = mysql_connect('localhost', 'root', '12345');
if (! $link)
die("Couldn't connect to MySQL");

mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());

$query=" SELECT * FROM terminkalender WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_num_rows($result);

$i=0;
while ($i < $num) {
$datum_wann=mysql_result($result,$i,"datum_wann");
$treffpunkt_zeit=mysql_result($result,$i,"treffpunkt_zeit");
$auftritt_zeit=mysql_result($result,$i,"auftritt_zeit");
$treffpunkt_wo=mysql_result($result,$i,"treffpunkt_wo");
$was=mysql_result($result,$i,"was");
$wer_geht_mit=mysql_result($result,$i,"wer_geht_mit");
$wer_tanzt=mysql_result($result,$i,"wer_tanzt");
$kleidung=mysql_result($result,$i,"kleidung");
?>
<table width="600" cellpadding="10" cellspacing="0" border="2">
<tr align="center" valign="top">
<td align="center" colspan="1" rowspan="1" bgcolor="#64b1ff">
<h3>Edit and Submit</h3>
<form action="terminkalender_change_record.php" method="post">
<input type="hidden" name="id" value="<? echo "$id" ?>"><br>
Datum wann:<input type="text" name="datum_wann" value="<? echo "$datum_wann"?>"><br>
Treffpunkt zeit: <input type="text" name="treffpunkt_zeit" value="<? echo "$treffpunkt_zeit"?>"><br>
Auftritt zeit: <input type="text" name="auftritt_zeit" value="<? echo "$auftritt_zeit"?>"><br>
Treffpunkt wo:<input type="text" name="treffpunkt_wo" value="<? echo "$treffpunkt_wo"?>"><br>
Was: <input type="text" name="was" value="<? echo "$was"?>"><br>
Wer geht mit: <input type="text" name="wer_geht_mit" value="<? echo "$wer_geht_mit"?>"><br>
Wer tanzt: <input type="text" name="wer_tanzt" value="<? echo "$wer_tanzt"?>"><br>
Kleidung:<input type="text" name="kleidung" value="<? echo "$kleidung"?>"><br>
<input type="Submit" value="Update">
</form>
</td></tr></table>
<?
++$i;
}
?>
</body>
</html>


Thanks

Member Avatar for diafol
<?
++$i;
}
?>

should be

<?php
$i++;
}
?>

Try to avoid php short tags if possible.

hi thanks for the quick response but it''s the same. it still not working

i have always <? echo as answer in the input boxes
and on the right site outsite the inputbox i have this ">

so the valeus from the data table are not mentioned

Member Avatar for diafol

Try this:

<html>
<head>
<title>Terminkalender Change form</title>
<style type="text/css">
td {font-family: tahoma, arial, verdana; font-size: 10pt }
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
//THIS ASSUMES TEHRE WILL ALWAYS BE A POST
$id=$_POST['id'];
$db="wordpress";
$link = mysql_connect('localhost', 'root', '12345');
if (! $link)
die("Couldn't connect to MySQL");

mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());

$query="SELECT * FROM terminkalender WHERE id='$id'";
$result=mysql_query($query);
//THIS ASSUMES THERE WILL ALWAYS BE A RESULT
$data = mysql_fetch_array($result);
extract($data);
?>
<table width="600" cellpadding="10" cellspacing="0" border="2">
<tr align="center" valign="top">
<td align="center" colspan="1" rowspan="1" bgcolor="#64b1ff">
<h3>Edit and Submit</h3>
<form action="terminkalender_change_record.php" method="post">
<input type="hidden" name="id" value="<?php echo $id;?>"><br>
Datum wann:<input type="text" name="datum_wann" value="<?php echo $datum_wann;?>" /><br />
Treffpunkt zeit: <input type="text" name="treffpunkt_zeit" value="<?php echo $treffpunkt_zeit;?>"><br />
Auftritt zeit: <input type="text" name="auftritt_zeit" value="<?php echo $auftritt_zeit;?>"><br />
Treffpunkt wo:<input type="text" name="treffpunkt_wo" value="<?php echo $treffpunkt_wo;?>"><br />
Was: <input type="text" name="was" value="<?php echo $was;?>"><br />
Wer geht mit: <input type="text" name="wer_geht_mit" value="<?php echo $wer_geht_mit;?>"><br />
Wer tanzt: <input type="text" name="wer_tanzt" value="<?php echo $wer_tanzt;?>"><br />
Kleidung:<input type="text" name="kleidung" value="<?php echo $kleidung;?>"><br />
<input type="Submit" value="Update">
</form>
</td></tr></table>
</body>
</html>

It assumes only one record for a particular ID. You should also sanitize your form input ($_POST) before putting it to work in an SQL statement.

yes thanks that works but now my change_record form dosn't work maybe you can fix it for me i realy do not know what''s wrong if i test all offline with the code that i had first everyting is working good.
but when i upload all to my server the update form did not work and i do not know wy.

here is the code:


<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Terminkalender Change Record</title></head>
<body>

<?
$id=$_POST;
$datum_wann=$_POST;
$treffpunkt_zeit=$_POST;
$auftritt_zeit=$_POST;
$treffpunkt_wo=$_POST;
$was=$_POST;
$wer_geht_mit=$_POST;
$wer_tanzt=$_POST;
$kleidung=$_POST;
$db="wordpress";
$link = mysql_connect('localhost', 'root', '12345');
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
mysql_query(" UPDATE terminkalender SET datum_wann='$datum_wann' , treffpunkt_zeit='$treffpunkt_zeit' , auftritt_zeit='$auftritt_zeit' , treffpunkt_wo='$treffpunkt_wo', was='$was', wer_geht_mit='$wer_geht_mit', wer_tanzt='$wer_tanzt', kleidung='$kleidung' WHERE id='$id'");

mysql_close($link);
echo "Record Updated";
?>


<form method="POST" action="terminkalender_dbase_interface.php">
<input type="submit" value="DBase Interface">
</form>
</body>
</html>

I will look tomorrow night i go to bed now Thanhs in advice John

Member Avatar for diafol
<form method="POST" action="terminkalender_dbase_interface.php">
<input type="submit" value="DBase Interface">
</form>

The change record form was in the other piece of code,not the one you've just posted. If it doesn't work, it's because the form processing code (which you've posted) doesn't work.
There's no content to the form you've included. What is this supposed to do?

ANyway. Is this your problem after you upload the script:

$link = mysql_connect('localhost', 'root', '12345');

It could be that you access your remote DB like this from your website. Do you have your local website access a local DB and then your live site access a remote DB?

sorry for the late response just back from work.

as jou said it''s not the change form i post as last

i would say give a try at http://www.johndohmen.uni.cc/narrengilde/terminkalender/terminkalender_dbase_interface.php


jou can insert, delete and display the records, but i cannot update becauase update record dosn't work.

and it's not the

$link = mysql_connect('localhost', 'root', '12345');

because i change the root and the password to the correct one before i upload al.

Thanks in advice (i hope my english is good enough).

Later i want to put all to this http://www.johndohmen.uni.cc/narrengilde/Terminkalender.html and thats all html code that wy i am making it to php mysql.
John

Member Avatar for diafol

OK now I see

The problem is on terminkalender_change_record.php

I believe I've mentioned this:

> Try to avoid php short tags if possible.

You use this notation:

<?
...
?>

Try this:

<?php
...
?>

It may look trivial, but many servers don't support 'short tags'.
I looked at the source code for:

http://www.johndohmen.uni.cc/narrengilde/terminkalender/terminkalender_change_record.php

and got:

<html><head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>Terminkalender Change Record</title></head> 
<body> 
 
<?
$id=$_POST['id'];
$datum_wann=$_POST['datum_wann'];
$treffpunkt_zeit=$_POST['treffpunkt_zeit'];
$auftritt_zeit=$_POST['auftritt_zeit'];
$treffpunkt_wo=$_POST['treffpunkt_wo'];
$was=$_POST['was'];
$wer_geht_mit=$_POST['wer_geht_mit'];
$wer_tanzt=$_POST['wer_tanzt'];
$kleidung=$_POST['kleidung'];
$db="wordpress";
$link = mysql_connect('localhost', '@@@', '@@@@@');
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
mysql_query(" UPDATE terminkalender SET datum_wann='$datum_wann' , treffpunkt_zeit='$treffpunkt_zeit' , auftritt_zeit='$auftritt_zeit' , treffpunkt_wo='$treffpunkt_wo', was='$was', wer_geht_mit='$wer_geht_mit', wer_tanzt='$wer_tanzt', kleidung='$kleidung' WHERE id='$id'");
 
mysql_close($link);
echo "Record Updated";
?> 
 
 
<form method="POST" action="terminkalender_dbase_interface.php"> 
<input type="submit" value="DBase Interface"> 
</form> 
</body> 
</html>

PHP should never be shown by html. Could be a disaster - imagine if you included your MySQL user/password details!! So - USE <?php to start.

sorry i did not see it now it's working i started with <? and now i have changed in <?php

Wel Thanks a lot for your help Please wil you delete the code That you just post.

Again thanks a lot for your help.

Member Avatar for diafol

> Please wil you delete the code That you just post.

OK, I have written over the mysql details! Sorry, I didn't see that when I posted. I was being serious when I posted my comment. Ha ha ha. That could have ended in tears! :)

Anyway, just to be safe, it may be worth changing your details as they didn't look difficult to crack!

oke than i wil change the detail wel again thanks.
and goodnight

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.