PDA

View Full Version : PHP to MySQL



magjac
May 10th, 2007, 07:28 AM
I cant get this script to post to mysql, any ideas?


<?php

// change the following values with your own MYSQL server access data
$host = "xxxxxxxx";
$user = "xxxxxxxx";
$pwd = "xxxxxxxx";
$db = "xxxxxxxx";

$connection = mysql_connect($host, $user, $pwd) or die("&error1=".mysql_error());
mysql_select_db($db, $connection);

$Fname = $_POST['Fname'];
$Enamn = $_POST['Ename'];
$adress = $_POST['adress'];
$ort = $_POST['ort'];
$email = $_POST['email'];
$telefon = $_POST['telefon'];
$EAN = $_POST['EAN'];
mysql_query("INSERT INTO apris (`Fname`,`Ename`,`adress`,`email`,`ort`,`email`,`t elefon`,`EAN`) VALUES ('$Fname','$Ename','$adress','$ort','$email','$tel efon','$EAN')");
echo "ok"

?>

borrob
May 10th, 2007, 09:34 AM
use $connection as the second parameter in the sql_query();

mysql_query("INSERT INTO apris (`Fname`,`Ename`,`adress`,`email`,`ort`,`email`,`t elefon`,`EAN`)
VALUES ('$Fname','$Ename','$adress','$ort','$email','$tel efon','$EAN')");

you have the email twice in the names list
so the values list is 1 short...