We help IT Professionals succeed at work.

what is wrong with this command

mgtm3
mgtm3 asked
on
180 Views
Last Modified: 2010-04-21
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

Comment
Watch Question

CERTIFIED EXPERT
Expert of the Year 2008
Top Expert 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
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 );

Author

Commented:
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

Author

Commented:
o.k i did what purplepomegranite   told me and  i got "$fname" as the  name of the table and not sffesd
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

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

Author

Commented:
because he tried to solve the proplem
and i only give him 50 points
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.