Jump to content

[SOLVED] PHP/mySQL Problem!


w1ww

Recommended Posts

Hello,

 

I'm trying to add some records to a database but it's not working and I don't why..

 

Can somebody check the code, please?

 

I think the error in the query because I always get the die function error "There is a problem with our...".

 

if (isset($_POST['continue'])){

// Caso contrario processa o form

include("db.php");

// open connection 
$connection = mysql_connect($host, $user, $pass) or die ("No connection!"); 
  
// select database 
mysql_select_db($db) or die ("No database?!");  
  
// variaveis
$fname = mysql_escape_string($_POST['fname']);  
$lname = mysql_escape_string($_POST['lname']);  
$mail =  mysql_escape_string($_POST['mail']);  
$logoname = mysql_escape_string($_POST['logoname']);  
$slogan = mysql_escape_string($_POST['slogan']);  
$description = mysql_escape_string($_POST['descri']);
$website  = mysql_escape_string($_POST['website']);
$other = mysql_escape_string($_POST['other']);  
  
// create query

$query = "INSERT INTO order (name, lastName, email) VALUES ('$fname', '$lname', '$mail')"; 

$result = mysql_query($query) or die ("There is a temporary problem with our service. Please try again later.");   
  
$orderid = mysql_insert_id();
  
$query = "INSERT INTO projects (logoText, slogan, description, other, website, orderID) VALUES ('$logoname', '$slogan', '$description' ,'$other' ,'$website', '$orderid')";

$result = mysql_query($query) or die ("There is a temporary problem with our service. Please try again later."); 

// close connection 
mysql_close($connection);


    }  

 

Thanks!

Link to comment
Share on other sites

ORDER is a reserved word in MySQL.  You really shouldn't use reserved words as table names or field names.  You could replace order with `order`, i.e. add `backticks` but the better solution is to change the name of your table to something that isn't a reserved word.

 

As a general rule, use helpful error messages during development. For example, this is much more helpful:

 

$result = mysql_query($query) or die("Error ". mysql_error(). " with query ". $query);

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.