Edit sql code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dejandj
Forum Newbie
Posts: 3
Joined: Wed Feb 02, 2011 8:57 am

Edit sql code

Post 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
Peter Kelly
Forum Contributor
Posts: 143
Joined: Fri Jan 14, 2011 5:33 pm
Location: England
Contact:

Re: Edit sql code

Post by Peter Kelly »

What is the error?! :crazy:
dejandj
Forum Newbie
Posts: 3
Joined: Wed Feb 02, 2011 8:57 am

Re: Edit sql code

Post by dejandj »

something like the server may be down for mantainance.
But it's impossible cause the server is here next to me ...
Peter Kelly
Forum Contributor
Posts: 143
Joined: Fri Jan 14, 2011 5:33 pm
Location: England
Contact:

Re: Edit sql code

Post 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.
dejandj
Forum Newbie
Posts: 3
Joined: Wed Feb 02, 2011 8:57 am

Re: Edit sql code

Post 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
Peter Kelly
Forum Contributor
Posts: 143
Joined: Fri Jan 14, 2011 5:33 pm
Location: England
Contact:

Re: Edit sql code

Post 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
Post Reply