Wizard4U Posted May 23, 2008 Share Posted May 23, 2008 Hello everyone, I'm from Croatia: Problem: Before I've changed it was : <? include('konekcija.php'); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Izmjena</title> </head> <body> <p><a href="index.php">Početna</a></p> <p><u><a href="ispis.php">Ispis</a></u></p> <p><u><a href="izmjena.php">Izmjena</a></u></p> <p> </p> <p> </p> <?php if(isset($_GET['id'])){ $id=$_GET['id']; } else{ echo "Niste odabrali kojeg kontakta želite izmijeniti!"; } $rezultat=mysql_query("SELECT * FROM kontakti WHERE id='$id'"); echo '<form action="" method="post">'; while($red=mysql_fetch_array($rezultat)){ echo 'Ime: <input type="text" name="ime" value="'.$red['Ime'].'" /><br /> Telefonski broj: <input type="text" name="tel" value="'.$red['Tel'].'" /><br /> Broj mobitela: <input type="text" name="mobitel" value="'.$red['Mobitel'].'" /><br /> Broja fax-a: <input type="text" name="fax" value="'.$red['Fax'].'" /><br /> Email adresa: <input type="text" name="email" value="'.$red['Email'].'" /><br /> Web adresa: <input type="text" name="web" value="'.$red['Web'].'" /><br /> Poruka: <input type="text" name="poruka" value="'.$red['Poruka'].'" /><br />'; } echo '<input type="submit" name="submit" value="Izmijeni!" /> </form>'; ?> </body> </html> <?php if(isset($_POST['submit'])){ $id=$_GET['id']; $Ime=$_POST['ime']; $Tel=$_POST['tel']; $Mobitel=$_POST['mobitel']; $Fax=$_POST['fax']; $Email=$_POST['email']; $Web=$_POST['web']; $Poruka=$_POST['poruka']; mysql_query("UPDATE kontakti SET Ime='$Ime' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Tel='$Tel' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Mobitel='$Mobitel' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Fax='$Fax' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Email='$Email' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Web='$Web' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Poruka='$Poruka' WHERE id='$id'"); echo '<script type="text/javascript">window.location="ispis.php"</script>'; } ?> And now is: <? include('konekcija.php'); include ('FCKeditor/fckeditor.php'); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Izmjena</title> </head> <body> <p><a href="index.php">Početna</a></p> <p><u><a href="ispis.php">Ispis</a></u></p> <p><u><a href="izmjena.php">Izmjena</a></u></p> <p> </p> <p> </p> <?php if(isset($_GET['id'])){ $id=$_GET['id']; } else{ echo "Niste odabrali kojeg kontakta želite izmijeniti!"; } $rezultat=mysql_query("SELECT * FROM kontakti WHERE id='$id'"); echo '<form action="" method="post">'; while($red=mysql_fetch_array($rezultat)){ $ime=$red['Ime']; $tel=$red['Tel']; $mob=$red['Mobitel']; $fax=$red['Fax']; $email=$red['Email']; $web=$red['Web']; $poruka=$red['Poruka']; ?> <form action="" method="post"> <input type="hidden" name="id" value="<?php echo $id;?>"> <table border="0" width="700"> <tr> <td> Ime: </td> <td> <input type="text" name="naslov" value="<?php echo $ime;?>"/> </td> </tr> <tr> <td> Telefonski broj: </td> <td> <input type="text" name="naslov" value="<?php echo $tel;?>"/> </td> </tr> <tr> <td> Mobitel: </td> <td> <input type="text" name="naslov" value="<?php echo $mob;?>"/> </td> </tr> <tr> <td> Fax: </td> <td> <input type="text" name="datum_objave" value="<?php echo $fax;?>"/> </td> </tr> <tr> <td> E-mail: </td> <td> <input type="text" name="naslov" value="<?php echo $email;?>"/> </td> </tr> <tr> <td> Web stranica: </td> <td> <input type="text" name="naslov" value="<?php echo $web;?>"/> </td> </tr> <tr> <td> Poruka: </td> <td> <?php $editor=new FCKeditor('$poruka'); $editor->BasePath='FCKeditor/'; $editor->ToolbarSet='Default'; $editor->Value=$poruka; $editor->Height='200'; $editor->Create(); ?> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="submit" value="Izmijeni!" /> </td> </tr> </tr> </table> </form> <? } ?> </body> </html> <?php if(isset($_POST['submit'])){ $id=$_GET['id']; $Ime=$_POST['ime']; $Tel=$_POST['tel']; $Mobitel=$_POST['mobitel']; $Fax=$_POST['fax']; $Email=$_POST['email']; $Web=$_POST['web']; $Poruka=$_POST['poruka']; mysql_query("UPDATE kontakti SET Ime='$Ime' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Tel='$Tel' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Mobitel='$Mobitel' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Fax='$Fax' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Email='$Email' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Web='$Web' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Poruka='$Poruka' WHERE id='$id'"); echo '<script type="text/javascript">window.location="ispis.php"</script>'; } ?> I've changed because I wanted: Not all HTML to be in PHP, and everything is OK but mow UPDATE doesn't work. Please HELP ME Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/ Share on other sites More sharing options...
Haggis Posted May 23, 2008 Share Posted May 23, 2008 why not just update it all at once instead of having all those queries? Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/#findComment-548119 Share on other sites More sharing options...
vurentjie Posted May 23, 2008 Share Posted May 23, 2008 I am not sure if this helps, tried to look at the differences, noticed <input type="text" name="naslov" value="<?php echo $ime;?>"/> could be changed to.... <?php echo "<input type='text' name='naslov' value='".$ime."' />"; ?> similar to original, I think it might be your quotes "" '', check those also instead of multiple updates run mysql_query("UPDATE kontakti SET Ime='$Ime',Tel='$Tel',Mobitel='$Mobitel',Fax='$Fax' WHERE id='$id'"); Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/#findComment-548126 Share on other sites More sharing options...
Wizard4U Posted May 23, 2008 Author Share Posted May 23, 2008 It doesn't work, can you PLEASE edit my code to be allright: <? include('konekcija.php'); include ('FCKeditor/fckeditor.php'); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Izmjena</title> </head> <body> <p><a href="index.php">Početna</a></p> <p><u><a href="ispis.php">Ispis</a></u></p> <p><u><a href="izmjena.php">Izmjena</a></u></p> <p> </p> <p> </p> <?php if(isset($_GET['id'])){ $id=$_GET['id']; } else{ echo "Niste odabrali kojeg kontakta želite izmijeniti!"; } $rezultat=mysql_query("SELECT * FROM kontakti WHERE id='$id'"); echo '<form action="" method="post">'; while($red=mysql_fetch_array($rezultat)){ $ime=$red['Ime']; $tel=$red['Tel']; $mob=$red['Mobitel']; $fax=$red['Fax']; $email=$red['Email']; $web=$red['Web']; $poruka=$red['Poruka']; ?> <form action="" method="post"> <input type="hidden" name="id" value="<?php echo $id;?>"> <table border="0" width="700"> <tr> <td> Ime: </td> <td> <input type="text" name="naslov" value="<?php echo $ime;?>"/> </td> </tr> <tr> <td> Telefonski broj: </td> <td> <input type="text" name="naslov" value="<?php echo $tel;?>"/> </td> </tr> <tr> <td> Mobitel: </td> <td> <input type="text" name="naslov" value="<?php echo $mob;?>"/> </td> </tr> <tr> <td> Fax: </td> <td> <input type="text" name="datum_objave" value="<?php echo $fax;?>"/> </td> </tr> <tr> <td> E-mail: </td> <td> <input type="text" name="naslov" value="<?php echo $email;?>"/> </td> </tr> <tr> <td> Web stranica: </td> <td> <input type="text" name="naslov" value="<?php echo $web;?>"/> </td> </tr> <tr> <td> Poruka: </td> <td> <?php $editor=new FCKeditor('$poruka'); $editor->BasePath='FCKeditor/'; $editor->ToolbarSet='Default'; $editor->Value=$poruka; $editor->Height='200'; $editor->Create(); ?> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="submit" value="Izmijeni!" /> </td> </tr> </tr> </table> </form> <? } ?> </body> </html> <?php if(isset($_POST['submit'])){ $id=$_GET['id']; $Ime=$_POST['ime']; $Tel=$_POST['tel']; $Mobitel=$_POST['mobitel']; $Fax=$_POST['fax']; $Email=$_POST['email']; $Web=$_POST['web']; $Poruka=$_POST['poruka']; mysql_query("UPDATE kontakti SET Ime='$Ime' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Tel='$Tel' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Mobitel='$Mobitel' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Fax='$Fax' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Email='$Email' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Web='$Web' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Poruka='$Poruka' WHERE id='$id'"); echo '<script type="text/javascript">window.location="ispis.php"</script>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/#findComment-548151 Share on other sites More sharing options...
jonsjava Posted May 23, 2008 Share Posted May 23, 2008 your input names are being reused. you need to use different input names. Input names become the $_POST names. Fixed code (I hope): <? include('konekcija.php'); include ('FCKeditor/fckeditor.php'); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Izmjena</title> </head> <body> <p><a href="index.php">Početna</a></p> <p><u><a href="ispis.php">Ispis</a></u></p> <p><u><a href="izmjena.php">Izmjena</a></u></p> <p> </p> <p> </p> <?php if(isset($_GET['id'])){ $id=$_GET['id']; } else{ echo "Niste odabrali kojeg kontakta želite izmijeniti!"; } $rezultat=mysql_query("SELECT * FROM kontakti WHERE id='$id'"); echo '<form action="" method="post">'; while($red=mysql_fetch_array($rezultat)){ $ime=$red['Ime']; $tel=$red['Tel']; $mob=$red['Mobitel']; $fax=$red['Fax']; $email=$red['Email']; $web=$red['Web']; $poruka=$red['Poruka']; ?> <form action="" method="post"> <input type="hidden" name="id" value="<?php echo $id;?>"> <table border="0" width="700"> <tr> <td> Ime: </td> <td> <input type="text" name="ime" value="<?php echo $ime;?>"/> </td> </tr> <tr> <td> Telefonski broj: </td> <td> <input type="text" name="tel" value="<?php echo $tel;?>"/> </td> </tr> <tr> <td> Mobitel: </td> <td> <input type="text" name="mob" value="<?php echo $mob;?>"/> </td> </tr> <tr> <td> Fax: </td> <td> <input type="text" name="fax" value="<?php echo $fax;?>"/> </td> </tr> <tr> <td> E-mail: </td> <td> <input type="text" name="email" value="<?php echo $email;?>"/> </td> </tr> <tr> <td> Web stranica: </td> <td> <input type="text" name="web" value="<?php echo $web;?>"/> </td> </tr> <tr> <td> Poruka: </td> <td> <?php $editor=new FCKeditor('$poruka'); $editor->BasePath='FCKeditor/'; $editor->ToolbarSet='Default'; $editor->Value=$poruka; $editor->Height='200'; $editor->Create(); ?> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="submit" value="Izmijeni!" /> </td> </tr> </tr> </table> </form> <? } ?> </body> </html> <?php if(isset($_POST['submit'])){ $id=$_GET['id']; $Ime=$_POST['ime']; $Tel=$_POST['tel']; $Mobitel=$_POST['mobitel']; $Fax=$_POST['fax']; $Email=$_POST['email']; $Web=$_POST['web']; $Poruka=$_POST['poruka']; $sql = "UPDATE `kontakti` SET `Ime`='$Ime', `Tel`='$Tel', Mobitel='$Mobitel', Fax='$Fax', Email='$Email', Web='$Web', Poruka='$Poruka' WHERE id='$id' LIMIT 1;"; mysql_query($sql); /* mysql_query("UPDATE kontakti SET Ime='$Ime' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Tel='$Tel' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Mobitel='$Mobitel' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Fax='$Fax' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Email='$Email' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Web='$Web' WHERE id='$id'"); mysql_query("UPDATE kontakti SET Poruka='$Poruka' WHERE id='$id'"); */ echo '<script type="text/javascript">window.location="ispis.php"</script>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/#findComment-548158 Share on other sites More sharing options...
phpzone Posted May 23, 2008 Share Posted May 23, 2008 There are no php errors in the code, but you should make the query die if there is an error, perhaps you have something wrong in your query, and you could write it as one query like this: mysql_query("UPDATE kontakti SET Ime='$Ime', Tel='$Tel', Mobitel='$Mobitel', Fax='$Fax', Email='$Email', Web='$Web', Poruka='$Poruka' WHERE id='$id'"); Note, before posting to the database you should use mysql_real_escape_string() on your variables too. Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/#findComment-548159 Share on other sites More sharing options...
Wizard4U Posted May 23, 2008 Author Share Posted May 23, 2008 You done this very fast, but somewhere isn't OK because it's not working 100 % ok. I've come here on this forum because I heard that you are the almost the best (or th best), and I need help with that code. Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/#findComment-548187 Share on other sites More sharing options...
.josh Posted May 23, 2008 Share Posted May 23, 2008 Mr. Wizard4U, can you please be so kind as to give us an update as to what you have tried to do, as far as fixing your code (other than shoving it at us and asking for a magic wand to be waved)? Because at this point in time, based on your most recent comment, I would suggest seeking a freelancer (please go to freelance forum). We aren't here to do your work for you. Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/#findComment-548194 Share on other sites More sharing options...
Wizard4U Posted May 23, 2008 Author Share Posted May 23, 2008 Understand, sorry : Problem is with "Poruka", in textarea show, but when I UPDATE, it doesn't UPDATE "Poruka". You see that I edit with FCKeditor, but with that is everythnig ok because I INSERT in MYSQL with that editor and is OK. Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/#findComment-548203 Share on other sites More sharing options...
sasa Posted May 23, 2008 Share Posted May 23, 2008 change line $editor=new FCKeditor('$poruka'); to $editor=new FCKeditor('poruka'); Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/#findComment-548211 Share on other sites More sharing options...
jonsjava Posted May 23, 2008 Share Posted May 23, 2008 doh!. just realized. you need to sanitize the fckeditor output. Because we are good, and you came to us, you must also be good, so I will let you figure out the code: $message_clean1 = str_replace("\'", "'", $_POST['Poruka']); $message_clean2 = str_replace('"', "'", $message_clean1); $message_clean3 = str_replace("\v", "", $message_clean2); $message_clean4 = str_replace("\'", "'", $message_clean3); $Poruka = $message_clean4; Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/#findComment-548212 Share on other sites More sharing options...
jonsjava Posted May 23, 2008 Share Posted May 23, 2008 Mr. Wizard4U, can you please be so kind as to give us an update as to what you have tried to do, as far as fixing your code (other than shoving it at us and asking for a magic wand to be waved)? Because at this point in time, based on your most recent comment, I would suggest seeking a freelancer (please go to freelance forum). We aren't here to do your work for you. Also, I agree. From now on, if you want my help, you'll get it after I get my retainer fee. Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/#findComment-548214 Share on other sites More sharing options...
Wizard4U Posted May 23, 2008 Author Share Posted May 23, 2008 Mr. Wizard4U, can you please be so kind as to give us an update as to what you have tried to do, as far as fixing your code (other than shoving it at us and asking for a magic wand to be waved)? Because at this point in time, based on your most recent comment, I would suggest seeking a freelancer (please go to freelance forum). We aren't here to do your work for you. Also, I agree. From now on, if you want my help, you'll get it after I get my retainer fee. Sory but I don't understand this "you'll get it after I get my retainer fee." , can you please explain detailed please?! Quote Link to comment https://forums.phpfreaks.com/topic/106943-solved-ive-changed-the-php-code-and-now-it-doesnt-work/#findComment-548339 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.