Jump to content

Query empty


teknospr

Recommended Posts

Good day:

 

Im trying to insert some information in a database. The information is passing from one page to the other as evidenced by the echo I did to test this. But it is not inserting in the database and it says error, empty query. Here is the code:

 


<html>
<?php
$aid = $_GET['aid'];
$uid = $_GET['uid'];
$page='sample.php';
?>

<body bgColor="#FFFFFF">
<meta http-equiv="refresh" content="25; url=<?php echo $page."?aid=".$aid; ?>"> 
<?php
$con = mysql_connect("xxxxxxxx","xxxxxxxx","xxxxxxxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("xxxxxxxxxl", $con);


$mysql="INSERT INTO visits (name, initial, last, secondlast, plate, brand, model, color, uid, homeid, purpose, guard)
VALUES
('$_POST[nombre]', '$_POST[inicial]', '$_POST[apellido]', '$_POST[apellido2]', '$_POST[tablilla]', '$_POST[marca]', '$_POST[modelo]', '$_POST[color]', '$uid', '$_POST[hid]', '$_POST[purpose]', '$aid')";
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Visita agregada";
mysql_close($con)
?> 
</body>
</html> 

 

Any help will be appreciated. Thanks in advance

Link to comment
Share on other sites

Tek, i'm guessing that you have like a form page where users enter info then click submit then your php would insert the data into the database. Post that form page code too. Most likely looks like the data never got passed through your $_POST...

and your VALUEs in the INSERT statement are not corrected (ah looks like it have to see your variables in the form)...

And why you using both the $_GET and the $_POST superglobal variables?

waiting for all your code  ;D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.