emediastudios Posted November 11, 2007 Share Posted November 11, 2007 My connection is enabled to my database with a include file, It works fine on my update and delete records that are done with a recordset and generated code through dreamweaver. But my insert records are exicuted through a seperate file, not a recordset and dreamweaver generated code. When i process the file online i get the error 'no database selected' , but this doesnt happen on my localhost, i include the connection file in all my process files. Here is my insert code <?php // check if successfully copied if($copied == $uploadNeed) { //Writes the information to the database mysql_query("INSERT INTO `employees` VALUES (NULL,'$name', '$rank', '$suburb', '$price', '$content', '$content2','$agentmobile', '$agentemail','$uploadFile0','$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')")or die (mysql_error()); print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">"; }?> Do i need to select the database in this file directly and not through a include file? Im stuck. Quote Link to comment https://forums.phpfreaks.com/topic/76812-select-database/ Share on other sites More sharing options...
AndyB Posted November 11, 2007 Share Posted November 11, 2007 You need to connect to the database server and select a database in every script that tries to access the database. Once a script terminates, the database connection automatically closes. The connection and database selection can be done 'inline' or with an included script (more normally). Whether these scripts execute on a local PC or a remote web server makes no difference. Quote Link to comment https://forums.phpfreaks.com/topic/76812-select-database/#findComment-388901 Share on other sites More sharing options...
emediastudios Posted November 11, 2007 Author Share Posted November 11, 2007 This is my linked connection file code <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_gcproperty = "localhost"; $database_gcproperty = "emediast_gcproperty"; $username_gcproperty = "emediast"; $password_gcproperty = "*****"; $gcproperty = mysql_pconnect($hostname_gcproperty, $username_gcproperty, $password_gcproperty) or trigger_error(mysql_error(),E_USER_ERROR); ?> It works on delete and update but not insert? They all work fine on my pc. ??? ??? Quote Link to comment https://forums.phpfreaks.com/topic/76812-select-database/#findComment-388915 Share on other sites More sharing options...
AndyB Posted November 11, 2007 Share Posted November 11, 2007 Are we to assume that the script you posted to start this thread included that? It would be helpful if you maintained a single thread for all of these 'how do I select' questions. Quote Link to comment https://forums.phpfreaks.com/topic/76812-select-database/#findComment-389024 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.