View Single Post
Old 12-07-2007, 05:05 AM   #36 (permalink)
YBH
The Wanderer
Newcomer 
 
Join Date: Dec 2007
Posts: 22
Thanks: 4
YBH is on a distinguished road
Default

MySQL 5.0.41

Actually Sock, I think I found the problem. You might actually be laughing soon....

PHP Code:
$db = new mysqli ('localhost''user''pass''dir''address''phone''email'); 
I think thats the problem. Shouldn't that be 'localhost', 'ybh305_clients', 'my_password', 'clients'

localhost->db name->db password->which table ?

I've redone the code to mysql instead, it seems easier to my eyes to read it and understand it better.

PHP Code:
<?php
// Variables
$user $_POST['user'];
$pass $_POST['pass'];
$dir $_POST['dir'];
$address $_POST['address'];
$phone $_POST['phone'];
$email $_POST['email'];

// Connect to db
$db mysql_connect(localhostybh305_clientsmypassword) or die(mysql_error());
      
mysql_select_db(ybh305_clients$db);

//Insert info
$sql "INSERT INTO clients(user, pass, dir, address, phone, email)";
$sql .= "values('$user$pass$dir$address$phone$email')";

//Run it
$rq mysql_query($sql$db) or die(mysql_error());

//Show O.K. message
if ($rq){
    echo 
'Client has been added to your data base';
}

?>
I'm getting a MySQL error when I run it

PHP Code:
Column count doesn't match value count at row 1 
I'm not sure what that means. My rows are as follows in my table:

user
pass
dir
address
phone
email
__________________
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.

Last edited by YBH : 12-07-2007 at 07:41 AM.
YBH is offline  
Reply With Quote