Jump to content

Whats wrong here?


alexander007

Recommended Posts

I have this...

 

<?php
include"include/config.php";
$tbl_name="clientes"; 

$nombre=$_POST['nombre'];
$telefono=$_POST['telefono'];
$email=$_POST['email'];
$usuario=$_POST['usuario'];
$referido=$_POST['referido'];

if($nombre==NULL|$telefono==NULL|$email==NULL|$usuario==NULL) {
     echo "<h3><center>Favor de llenar todos los campos.</center></h3>";
} else {
mysql_query("INSERT INTO `$tbl_name` VALUES (NULL, '$nombre', '$telefono', '$email', '$usuario', NULL)");	
mysql_query("UPDATE `$tbl_name` SET referidos=referidos+1 WHERE usuario='$referido'");
}
mkdir("/home/content/m/a/u/maunalava/html/dev-netteampr/travel/".$usuario, 0777)
?>

 

I dont know why is not inserting the values on the table...

Link to comment
https://forums.phpfreaks.com/topic/72715-whats-wrong-here/
Share on other sites

mysql_query("INSERT INTO `$tbl_name` VALUES (NULL, '$nombre', '$telefono', '$email', '$usuario', NULL)");

 

Insert Into is the structure of

Insert Into `Table` Fields() Values()

 

so try addressing the fields.  Also you need to be consistent about quoting I prefer to do queries like this as its easier to see errors

<?php
$q = "INSERT INTO `".$tbl_name."`Fields(field1, field2, field3, field4, field5) VALUES (NULL, '".$nombre."', '".$telefono."', '".$email."', '".$usuario."', NULL)";
$r =  mysql_query($q) or die(mysql_error());
?>

Note how I have the values quoted and then I escape and put in the variable the '".$var."' that seems to never fail for me

 

Link to comment
https://forums.phpfreaks.com/topic/72715-whats-wrong-here/#findComment-366754
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.