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
https://forums.phpfreaks.com/topic/87992-solved-phpmysql-problem/
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);

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.