Guys, PHP+MySQL question

Discussion and feedback on Construct 2

Post » Fri Sep 30, 2016 4:31 pm

Guys, i have a big problem. i need to create separate table for each user i my database by sending user name via C2 project (meaning ajax POST), please, no question what for, just need this.
So, can enyone explain me whre i have mistake?
And here is the code:

<?php
$host = "xxx.mysql.com";
$login = "u33678";
$pass = "123456";
$dbname = "u33678";
$user = $_POST['user'];

@header('Access-Control-Allow-Origin: *');
@header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
@header("Content-Type: text/html; charset=UTF-8");
$link = mysql_connect ($host, $login, $pass);
mysql_select_db ($dbname , $link) or die("FUUUCK");
mysql_query ("CREATE TABLE .$user. (id int not null auto_increment,pole1 varchar(10) not null,PRIMARY KEY(id))");
?>
The whole life is in the movement.Stopped - fell asleep to hell...
B
14
S
3
G
1
Posts: 122
Reputation: 1,694

Post » Fri Sep 30, 2016 6:03 pm

try:
$user = $_GET['user'];

also.. remove dots from $user - mysql_query ("CREATE TABLE .$user. (
mysql_query ("CREATE TABLE $user (

this should work..
Code: Select all
<?php
$host = "xxx.mysql.com";
$login = "u33678";
$pass = "123456";
$dbname = "u33678";
$user = $_GET['user'];

@header('Access-Control-Allow-Origin: *');
@header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
@header("Content-Type: text/html; charset=UTF-8");
$link = mysql_connect ($host, $login, $pass);
mysql_select_db ($dbname , $link) or die("FUUUCK");
mysql_query ("CREATE TABLE  $user (id int not null auto_increment,pole1 varchar(10) not null,PRIMARY KEY(id))");
?>
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Fri Sep 30, 2016 6:26 pm

no, was trying this. MySQL create table $user. name "$user" and that's all =(
and i needed, that name of table will be variable and user will chose it's name by himself =(
The whole life is in the movement.Stopped - fell asleep to hell...
B
14
S
3
G
1
Posts: 122
Reputation: 1,694

Post » Fri Sep 30, 2016 6:27 pm

i need to create for each user his own table with name, that user will post via ajax =/
The whole life is in the movement.Stopped - fell asleep to hell...
B
14
S
3
G
1
Posts: 122
Reputation: 1,694

Post » Fri Sep 30, 2016 6:44 pm

exactly...

if ajax POST then php GET variable..

Image
Image
and you create new table
Image
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Fri Sep 30, 2016 7:19 pm

[email protected] O_o
How you do that? It's works!!! =)
GREAT!!!
Explain please, how you do that??
The whole life is in the movement.Stopped - fell asleep to hell...
B
14
S
3
G
1
Posts: 122
Reputation: 1,694

Post » Fri Sep 30, 2016 7:24 pm

my mistake was to send DATA -> textbox.text and URL ->just address of php script.
and you add URL ->"xxxxxxx.?user="URLEncode(Textbox.text)
can you teach me?
The whole life is in the movement.Stopped - fell asleep to hell...
B
14
S
3
G
1
Posts: 122
Reputation: 1,694


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests