abhi201090 Posted June 20, 2010 Share Posted June 20, 2010 Please tell me what is wrong with this code and how to correct it? i am not able to create database with this code <?php mysql_connect('localhost','root','password'); $name="xyz"; $create="CREATE DATABASE '$name'"; mysql_query($create) or die(mysql_error()); mysql_close(); ?> [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/205346-creating-database/ Share on other sites More sharing options...
Mchl Posted June 20, 2010 Share Posted June 20, 2010 Do you get any errors? Link to comment https://forums.phpfreaks.com/topic/205346-creating-database/#findComment-1074706 Share on other sites More sharing options...
abhi201090 Posted June 21, 2010 Author Share Posted June 21, 2010 yes....i am getting mysql syntax error Link to comment https://forums.phpfreaks.com/topic/205346-creating-database/#findComment-1074828 Share on other sites More sharing options...
phpchamps Posted June 21, 2010 Share Posted June 21, 2010 change this line $create="CREATE DATABASE '$name'"; to $create="CREATE DATABASE ".$name; Link to comment https://forums.phpfreaks.com/topic/205346-creating-database/#findComment-1074830 Share on other sites More sharing options...
Mchl Posted June 21, 2010 Share Posted June 21, 2010 yes....i am getting mysql syntax error For future reference: when someone asks you about error message, give them full error message. What phpchamps proposes should work. Or even: $create="CREATE DATABASE $name"; Link to comment https://forums.phpfreaks.com/topic/205346-creating-database/#findComment-1074845 Share on other sites More sharing options...
abhi201090 Posted June 21, 2010 Author Share Posted June 21, 2010 it worked thanks Link to comment https://forums.phpfreaks.com/topic/205346-creating-database/#findComment-1075232 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.