|
-
Oct 2nd, 2005, 09:52 PM
#1
Thread Starter
Lively Member
Whats wrong with this?
HI! I have this code:
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Agregar Server</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form method="post" action="rec_datos.php">
Nombre:<input type="Text" name=Id_server"><br>
pagina:<input type="Text" name="pagina"><br>
IP:<input type="Text" name="ip"><br>
Puerto:<input type="Text" name="puerto"><br>
<input type="Submit" name ="enviar" value="Aceptar informacion">
</form>
</body>
</html>
And this one recives the data from the above one:
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Datos Recividos</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
include("config.php")
//process form
$sql = "insert into muservers(Id_server, exp, drop, pagina, ip, puerto).VALUES('$Id_server','$exp','$drop','$ip','$puerto',$pagina')";
$result = mysql_query($sql);
echo "Hemos recivido los datos de su servidor.\n";
?>
</body>
</html>
As you can see it is just a reg page...
Well.. the problem is that when I press the buttom to send the data, the second page gives me this error:
Parse error: parse error, unexpected T_VARIABLE in /www/2gamers.com.ar/htdocs/servers/rec_datos.php on line 12
That line is this:
PHP Code:
$sql = "insert into muservers(Id_server, exp, drop, pagina, ip, puerto).VALUES('$Id_server','$exp','$drop','$ip','$puerto',$pagina')";
Can you tell me what is wrong with this?. As you can see my english might not be so good, so please excuse me...
I hope you can help me...
Thanks!
-
Oct 2nd, 2005, 10:08 PM
#2
Lively Member
Re: Whats wrong with this?
I see a missing semi colon, missing single quote, and you have a period in your sql statement. So add in the semi colon, remove the period, and add the single quote 
Code:
include("config.php");
$sql = "insert into muservers(Id_server, exp, drop, pagina, ip, puerto).VALUES('$Id_server','$exp','$drop','$ip','$puerto','$pagina')";
Put a or die on your mysql_query() also, it'll help you with mysql errors.
PHP Code:
$result = mysql_query($sql) or die(mysql_error());
Good luck
-
Oct 2nd, 2005, 10:32 PM
#3
Thread Starter
Lively Member
Re: Whats wrong with this?
Thanks man! Now I passed that error... but now I have this one...
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'drop, pagina, IP, Puerto)VALUES('','','','','','')' at line 1
I hope you can help me with this one...
Thanks!
-
Oct 2nd, 2005, 10:39 PM
#4
Lively Member
Re: Whats wrong with this?
My bad, I missed it on first glance. Register globals is off by default, therefore, when you access form values, you can't just use the name of the form element. You access it through the $_POST superglobal. So, it would be:
PHP Code:
$_POST['Id_server'];
// instead of
$Id_server;
Good luck
-
Oct 2nd, 2005, 10:47 PM
#5
Thread Starter
Lively Member
Re: Whats wrong with this?
Thanks! But now it says
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /www/2gamers.com.ar/htdocs/servers/rec_datos.php on line 13

Here is the code
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Datos Recividos</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
include("config.php");
//process form
$sql = "INSERT INTO muservers(Id_server, exp, drop, pagina, IP, Puerto)"."VALUES ($_POST['Id_server'],$_POST['exp'],$_POST['drop'],$_POST['pagina'],$_POST['ip'],$_POST['puerto'])";
$result = mysql_query($sql) or die(mysql_error());
echo "Hemos recivido los datos de su servidor.\n";
?>
</body>
</html>
Thanks again!
Last edited by Frehley; Oct 2nd, 2005 at 10:51 PM.
-
Oct 2nd, 2005, 10:57 PM
#6
Lively Member
Re: Whats wrong with this?
Try this for your query:
PHP Code:
$sql = 'insert into muservers(Id_server, exp, drop, pagina, ip, puerto) VALUES("' . $_POST['Id_server'] . '","' . $_POST['exp'] . '", "' . $_POST['drop'] . '", "' . $_POST['ip'] . '", "' . $_POST['puerto'] . '", "' . $_POST['pagina'] . '")';
You'll want to look at mysql_real_escape_string()
To help prevent sql injection attacks.
Good luck
EDIT: You seem to be missing a few form fields as well, I only see 4 here:
PHP Code:
Nombre:<input type="Text" name=Id_server"><br>
pagina:<input type="Text" name="pagina"><br>
IP:<input type="Text" name="ip"><br>
Puerto:<input type="Text" name="puerto"><br>
But you are inserting 6?
-
Oct 2nd, 2005, 11:02 PM
#7
Thread Starter
Lively Member
Re: Whats wrong with this?
Thanks man, but forget it, i have this error:
Parse error: parse error, unexpected T_VARIABLE in /www/2gamers.com.ar/htdocs/servers/rec_datos.php on line 14
Ill keep trying
Thanks again for your help!!
-
Oct 3rd, 2005, 11:50 AM
#8
Lively Member
Re: Whats wrong with this?
We can't give up now!
Make sure you have all the form fields in your html form, then give it a shot.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|