Okay, here I have put together two functions. One creates a table, the other creates an entry, except neither are doing the original intention. I get no errors, and it 'seems' to work fine. The two functions are held in a PHP file, I will display all my code in the best manner I can:
sqlfunctions.php > This is where the functions are held:
<?php
function create_table($tablename, $values){
$VString = join(', ', $values);
$query = 'CREATE TABLE ' . $tablename . '(' . $VString . ')';
$result = mysql_query($query);
print 'Created table $tablename';
}
function insert($tablename, $parameters, $values){
$PString = join(', ', $parameters);
$VString = join(', ', $values);
$query = 'INSERT INTO $tablename ($PString) VALUES ($VString)';
mysql_query($query);
}
?>
Install_Login.php > This script was supposed to create a table for login use using the function above:
<?php
include 'Php/sqlfunctions.php';
include 'Php/connect.php';
$name = "newlogin";
$Values[0] = "id int(6) NOT NULL auto_increment";
$Values[1] = "user varchar(15) NOT NULL";
$Values[2] = "password varchar(15) NOT NULL";
$Values[3] = "PRIMARY KEY (id)";
$Values[4] = "UNIQUE id (id)";
$Values[5] = "KEY id_2 (id)";
create_table($name, $Values[]);
mysql_close($conn);
?>
Create_User.php > This script was supposed to create a user in the table using the function in the function script above:
<?php
include 'Php/connect.php';
include 'Php/sqlfunctions.php';
$pars[0] = "id";
$pars[1] = "user";
$pars[2] = "password";
$values[0] = "";
$values[1] = "Josh";
$values[2] = "josh7234";
$name = "login";
insert($name, $pars[], $values[]);
mysql_close($conn);
?>
So nothing is working. Would someone mind helping me get all this fixed, as with no errors I am clueless to what is wrong.