Page 1 of 1

Edit sql code

Posted: Wed Feb 02, 2011 9:05 am
by dejandj
Hi everyone,
I'm traying to make a page that allows user to edit the database data and i got this code but i can't make it workin'. Can you please have a look at it? i can't find the problem!
This should be the last page that reads the modifications and actually writes them on the DB but this page gives an error and nothing changes on DB.

Code: Select all

<?php
$id=$_POST["id"] ;
$Nome = $_POST["Nome"];
$Email = $_POST["Email"];
$NumeroCell = $_POST["NumeroCell"];
$InternoTemis = $_POST["InternoTemis"];
$Skype = $_POST["Skype"];
if($Nome=="")
	{
	print "Nome obbligatorio<br><a href=\"?page_id=321\">indietro</a>";
	}
		elseif($Email=="")
		{
		print "La mail obbligatoria<br><a href=\"?page_id=321\">indietro</a>";
		print "Numero Cell: $NumeroCell <br>";
		print "Interno Temis: $InternoTemis <br>";
		print "Skype: $Skype <br>";
		}
else
{
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '*********';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to 

mysql');

$dbname = 'wordpress';
mysql_select_db($dbname);

mysql_query("UPDATE temis_contatti SET Nome='$Nome', Email='$Email', NumeroCell='$NumeroCell',
InternoTemis='$InternoTemis', Skype='$Skype' WHERE id=$id");
mysql_close();
?>
<html>
<head>
<title>update</title>
</head>
<body>

<table width="750" align="center">
<tr>
<td>
<?php
echo "Record modificato:<br>";
echo "Nome: $Nome<br>";
echo "Email: $Email<br>";
echo "Numero Cell: $NumeroCell<br>";
echo "InternoTemis: $InternoTemis<br>";
echo "Skype: $Skype<br>";
?>
<br>
<a href="\?page_id=311">Elenco completo</a>
</td>
</tr>
</table>
</body>
</html>
<?
}
?>
Thank you all

Re: Edit sql code

Posted: Wed Feb 02, 2011 9:10 am
by Peter Kelly
What is the error?! :crazy:

Re: Edit sql code

Posted: Wed Feb 02, 2011 9:26 am
by dejandj
something like the server may be down for mantainance.
But it's impossible cause the server is here next to me ...

Re: Edit sql code

Posted: Wed Feb 02, 2011 9:34 am
by Peter Kelly
dejandj wrote:something like the server may be down for mantainance.
But it's impossible cause the server is here next to me ...
Sooo still whats the error lol. Paste the exact error you get in here otherwise its really hard to help.

Re: Edit sql code

Posted: Wed Feb 02, 2011 9:39 am
by dejandj
Sorry!
This is the error:

Server error.

The website encountered an error while retrieving http://192.168.1.100/intranet/mod.php. It may be down for maintenance or configured incorrectly.

Here are some suggestions:
Reload this web page later.
More information on this error

Re: Edit sql code

Posted: Wed Feb 02, 2011 9:50 am
by Peter Kelly
dejandj wrote:Sorry!
This is the error:

Server error.

The website encountered an error while retrieving http://192.168.1.100/intranet/mod.php. It may be down for maintenance or configured incorrectly.

Here are some suggestions:
Reload this web page later.
More information on this error
What web server are you using?, Check its online e.g all ports are open on 192.168.1.100 if you can access other pages try see if there is an error log any where if its apache it sometimes has an error log in the same directory so /intranet/ if theres a file called error_log