1 Replies - 138 Views - Last Post: 23 April 2011 - 08:00 AM Rate Topic: -----

#1 davey123  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 103
  • Joined: 24-December 10

Trouble querying mysql

Posted 23 April 2011 - 07:21 AM

Hey,

Ive been having trouble querying my database. I connect just fine, I get no errors but I cant seem to insert anything from my form. I dont have a clue what Im doing wrong and if it's not the php on the page then it has to be the mysql server setup.
I know something is wrong because it doesn't even get to the echo script and posting the values.

I dont know all the information you guys need to help me out but will post it when you tell me.
Here's what I have so far:

<?php
$name = $_POST['name'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$shape = $_POST['shape'];
$colors = $_POST['colors'];
$size = $_POST['size'];
$quantity = $_POST['quantity'];
$comments = $_POST['comments'];

$dbc = mysqli_connect ('me.mysite.com','user', 'password','database') or die('Error connecting to MSQL server.');

$query = "INSERT INTO mytable (name, company, phone, email, shape, colors, size, quantity, comments)".
"VALUES ('$name', '$company','$phone'.'$email'.'$shape'.'$colors'.'$size'.'$quantity','$comments')";

$result = mysqli_query($dbc, $query) or die ('cant query the stupid server');

mysqli_close ($dbc);

echo 'Your name : ' .$name .'<br/>';
echo ' Your Company : ' .$company .'<br/>';
echo ' Your phone # : ' .$phone .'<br/>';
echo ' Your email : ' .$email .'<br/>';
echo ' Label shape : ' .$shape .'<br/>';
echo ' Label colors : ' .$colors .'<br/>';
echo ' Label size : ' .$size.'<br/>';
echo ' Label quantity : ' .$quantity .'<br/>';
?>




Is This A Good Question/Topic? 0
  • +

Replies To: Trouble querying mysql

#2 davey123  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 103
  • Joined: 24-December 10

Re: Trouble querying mysql

Posted 23 April 2011 - 08:00 AM

Figured it out, stupid me.

I put periods where there should be commas in the query values.
<?php
$name = $_POST['name'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$shape = $_POST['shape'];
$colors = $_POST['colors'];
$size = $_POST['size'];
$quantity = $_POST['quantity'];
$comments = $_POST['comments'];

$dbc = mysqli_connect ('me.com','me', 'pass','database') or die('Error connecting to MSQL server.');

$query = "INSERT INTO mylabels (name, company, phone, email, shape, colors, size, quantity, comments)".
"VALUES ('$name', '$company','$phone','$email','$shape','$colors','$size','$quantity','$comments')";

$result = mysqli_query($dbc, $query) or die ('Fuck');

mysqli_close ($dbc);

echo 'Your name : ' .$name .'<br/>';
echo ' Your Company : ' .$company .'<br/>';
echo ' Your phone # : ' .$phone .'<br/>';
echo ' Your email : ' .$email .'<br/>';
echo ' Label shape : ' .$shape .'<br/>';
echo ' Label colors : ' .$colors .'<br/>';
echo ' Label size : ' .$size.'<br/>';
echo ' Label quantity : ' .$quantity .'<br/>';
?>



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1