Question: How can I connect my sql database from my dedicated server? Example:
$conn = odbc_connect('175.34.73.13','User_LoginDB','User123','testtest');
That IP is my Server IP and my database is on my server. I get this error when I use that code:
expects parameter 4 to be long, string given in register.php
My HTML and PHP skills are not at all good. Suggestions?
You have 'testtest'
as the cursor type:
resource odbc_connect ( string $dsn , string $user , string $password [, int $cursor_type ] )
Regarding this PHP documentation: parameter 4th should be cursor_type(int). First argument of this method can be a DSN-less connection string. This is how you can provide DB name.
// Replace the value of these variables with your own data
$user = 'username';
$pass = 'password';
$server = 'serverName\instanceName';
$database = 'database';
// No changes needed from now on
$connection_string = "DRIVER={SQL Server};SERVER=$server;DATABASE=$database";
$conn = odbc_connect($connection_string,$user,$pass);
You just need to define first 4 variables with your values.