SA-MP Forums Archive
MySql Problem Please Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySql Problem Please Help (/showthread.php?tid=608902)



MySql Problem Please Help - EmpImperial - 06.06.2016

Error

SQL query:

CREATE TABLE IF NOT EXISTS `accounts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`Online` int(11) NOT NULL DEFAULT '0',
`UpdateDate` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`RegiDate` datetime DEFAULT NULL,
`LastLogin` datetime DEFAULT NULL,
`Username` varchar(32) NOT NULL DEFAULT '',
`Key` varchar(256) NOT NULL DEFAULT '',
`Email` varchar(256) NOT NULL DEFAULT '',
`IP` varchar(32) NOT NULL DEFAULT '0.0.0.0',
`SecureIP` varchar(32) NOT NULL DEFAULT '0.0.0.0',
`Registered` int(11) NOT NULL DEFAULT '0',
`ConnectedTime` int(11) NOT NULL DEFAULT '0',
`Sex` int(11) NOT NULL DEFAULT '1',
`Age` int(11) NOT NULL DEFAULT '18',
`BirthDate` date NOT NULL DEFAULT '0000-00-00',
`Band` int(11) NOT NULL DEFAULT '0',
`PermBand` int(11) NOT NULL DEFAULT '0',
`Warnings` int(11) NOT NULL DEFAULT '0',
`Disabled` int(11) NOT NULL DEFAULT '0',
`Level` int(11) NOT NULL DEFAULT '1',
`AdminLevel` int(11) NOT NULL DEFAULT '0',
`SeniorModerator` int(11) N[...]

MySQL said: Documentation
#1046 - No database selected


Re: MySql Problem Please Help - oMa37 - 06.06.2016

You didn't select the database name
Use this under OnGameModeInit to connect to the database.
PHP код:
mysql_connect(host[], user[], database[], password[]) 



Re: MySql Problem Please Help - Jonesy96 - 06.06.2016

Well there you go, MySQL is telling you exactly what is wrong. You haven't select a database. You'll need to select the database you've created first.

Are you using phpmyadmin? If so, then just click on the database you wish to create the table under, and then select "Query" in the top navigation. Then run your SQL query from above.

If you're not using phpmyadmin, then you'll need to execute an SQL query to select the database first. Above your SQL query add the following:

Код:
USE DATABASE_NAME;
Obviously replace DATABASE_NAME with the actual name of your database.


EDIT: In terms of selecting the database from pawno, refer to the person's post above mine^^