Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/76812-select-database/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/76812-select-database/#findComment-388901
Share on other sites

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. ??? ???

Link to comment
https://forums.phpfreaks.com/topic/76812-select-database/#findComment-388915
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.