Link to home
Start Free TrialLog in
Avatar of mgtm3
mgtm3Flag for Israel

asked on

what is wrong with this command

i am tring to make a new table and the table dose not get created and i dont get any error



<?php
 
include 'link.php';
$fname="sffesd";
 
$sql = 'CREATE TABLE $fname (
 `id` INT( 200 ) UNSIGNED NOT NULL AUTO_INCREMENT,
        `sname` VARCHAR( 150 ) NOT NULL,
      `sadas` VARCHAR( 150 ) NOT NULL,
        `sdst` VARCHAR( 150 ) NOT NULL,
        `info` VARCHAR( 150 ) NOT NULL,
       `link` VARCHAR( 150 ) NOT NULL,
        PRIMARY KEY ( `id` )
       )';
 
mysqli_query( $link, $sql );
 
 
 
 
 
 
 
 
 
 
 
?>

Open in new window

SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try the below.
<?php
 
include 'link.php';
$fname="sffesd";
 
$sql = 'CREATE TABLE $fname (
	id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
	sname VARCHAR(150) NOT NULL,
	sadas VARCHAR(150) NOT NULL,
	sdst VARCHAR(150) NOT NULL,
	info VARCHAR(150) NOT NULL,
	link VARCHAR(150) NOT NULL,
	)';
 
mysqli_query( $link, $sql );

Open in new window

http://uk.php.net/mysqli_query

This part is correct: mysqli_query($link, $sql );
Avatar of mgtm3

ASKER

nope dose not work
i get this error


Warning: mysqli_query() expects parameter 1 to be mysqli, string given in C:\wamp\www\movie\uploader.php on line 20
Though I did leave a spurious comma in my amendment... corrected below.
<?php
 
include 'link.php';
$fname="sffesd";
 
$sql = 'CREATE TABLE $fname (
	id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
	sname VARCHAR(150) NOT NULL,
	sadas VARCHAR(150) NOT NULL,
	sdst VARCHAR(150) NOT NULL,
	info VARCHAR(150) NOT NULL,
	link VARCHAR(150) NOT NULL)';
 
mysqli_query( $link, $sql );

Open in new window

Avatar of mgtm3

ASKER

o.k i did what purplepomegranite   told me and  i got "$fname" as the  name of the table and not sffesd
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mgtm3

ASKER

thanks
Thanks for the points, though I am left wondering why they were split between a solution and an incorrect statement...
Avatar of mgtm3

ASKER

because he tried to solve the proplem
and i only give him 50 points