I installed easysoft odbc derby driver in windows 7 and try to connect to derby database
after I configure on ODBC Data Source Administrator DSN and connection succeed.
then i tried on php script
//commz is the DSN name ind ODBC data source admin
$connection = odbc_connect("commz",$user, $password);
if ($result = odbc_exec($connection, "SELECT * FROM ADDRESSBOOK"))
print "Command executed successfully<BR><BR>";
else
print "Error while executing command<BR><BR>";
// Print results
while(odbc_fetch_row($result))
print odbc_result($result, 1) . " " . odbc_result($result, 2) . " " . odbc_result($result, 3) . " " . odbc_result($result, 4) . " " . odbc_result($result, 5) . "<BR>";
odbc_close($connection);
print "<BR>Connection closed.";
after i run this script this msg appear
Connected to datasource
Warning: odbc_exec(): SQL error: [Easysoft][ODBC-Derby
Driver][DRDA]General error: unexpected command (dss not returned), SQL
state HY000 in SQLExecDirect in C:\xampp\htdocs\test\index.php on line
36 Error while executing command
Warning: odbc_fetch_row() expects parameter 1 to be resource, boolean
given in C:\xampp\htdocs\test\index.php on line 45
Connection closed.
any advise regarding to this?
Thanks!
Best thing to do, is send a driver log of the operation to support#easysoft.com and we will take a look at whats going on. I will post whatever we find back here.
To get the log, add to your DSN in odbc.ini file:
Logging = Yes
LogFile = /tmp/drb.log
Related
I am new to PHP. I want to use the database stored in pgSQL from my PHP file. Please tell how to integrate pgSQL and PHP, so that I can use pgSQL in PHP using pg_connect(). My php.info() is showing MySQL, pgSQL, SQLite enabled under PDO support. But when I use pg_connect() it says:
Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: role "postgres" does not exist in /Users/username/Sites/index.php on line 3
Warning: pg_last_error(): No PostgreSQL link opened yet in /Users/username/Sites/index.php on line 4
Warning: pg_last_error(): supplied resource is not a valid PostgreSQL link resource in /Users/username/Sites/index.php on line 4
Could not connect:
I have used this tutorial to run PHP on Mac. But I couldn't find a tutorial clearly showing how to integrate PHP and pgSQL.
https://www.dyclassroom.com/howto-mac/how-to-install-apache-mysql-php-on-macos-mojave-10-14
<?php
// Connecting, selecting database
$dbconn = pg_connect("host=localhost dbname=ipl user=postgres password=password")
or die('Could not connect: ' . pg_last_error());
// Performing SQL query
$query = 'SELECT * FROM player';
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
// Printing results in HTML
echo "<table>\n";
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
pg_free_result($result);
// Closing connection
pg_close($dbconn);
?>
I got the problem. My username is not postgres but my name. I must have set it while installing Postgres. Therefore it is saying no role as 'postgres' exist.
I am running on Host Gator and using a mySQL backend, with phpMyAdmin as a GUI.
I am coding in PHP.
I have had no issues performing standard prepare statements, but all of a sudden, with my first delete statement, there seems to be an error. I cannot spot or debug it. The following code is where the error occurs.
//Error occurs right here
if(!($sql = $con->prepare("DELETE FROM quoteItems WHERE quoteID=?")))
{ echo "FAIL - Prepare failed: (" . $con->errno . ") " . $con->error;}
if(!$sql->bind_param('i', $quoteID))
{echo "FAIL - Binding parameters failed: (" . $sql->errno . ") " . $sql->error;}
if(!$sql->execute())
{echo "FAIL - Execute failed: (" . $sql->errno . ") " . $sql->error;}
The output of var_dump($quoteID); gives string "44" in my current situation.
The error message that is produced is FAIL - Prepare failed:(0) Fatal Error: Call to a member function bind_param() on a non-object
This question was correctly solved by #Sean in the comments under the OP.
Is $con a valid mysqli object? Do you have DELETE rights for this db
user?
The user did not have DELETE rights - giving the user this right solved the issue. The $con object was a valid object.
I am trying to connect my remote Oracle 11g database on Windows 2003 using PHP from XAMPP on my 32 bit Windows operating system. I have gone through many tutorials, blog, and videos. I tried https://www.youtube.com/watch?v=hMhkD43yUzI by 1niko2niko
What I did,
Installed XAMPP 1.7.4 32 bit on my C:\xampp
;extension=php_oci8.dll => extension=php_oci8.dll
(removed semicolon) fron php.ini located inside C:\xampp\php
downloaded Oracle Instant Client 11.2.0.4.0 from http://www.oracle.com/technetwork/topics/winsoft-085727.html and extracted to C:\instantclient_11_2
My Computer => Right Click => Properties => Advanced => Environment Variables => System Vairables => Edit => Path => C:\instantclient_11_2\ => Ok => OK => Ok
PHP connection string I found on internet:
<?php
$conn = oci_connect('user','pass','111.111.111.111/sid');
// Prepare the statement
$stid = oci_parse($conn, 'SELECT * FROM names');
if (!$stid) {
$e = oci_error($conn);
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
// Perform the logic of the query
$r = oci_execute($stid);
if (!$r) {
$e = oci_error($stid);
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
// Fetch the results of the query
print "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
print "<tr>\n";
foreach ($row as $item) {
print " <td>" . ($item !== null ? htmlentities($item,ENT_QUOTES) : " ") . "</td>\n";
}
print "</tr>\n";
}
print "</table>\n";
?>
I tried this process under Win XP, Win 7 using virtual box.
Restarted my computer and shows the following result
Warning: oci_connect() [function.oci-connect]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client libraries in C:\xampp\htdocs\oracle\index.php on line 3
Warning: oci_parse() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\oracle\index.php on line 6
Warning: oci_error() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\oracle\index.php on line 8
Fatal error: in C:\xampp\htdocs\oracle\index.php on line 9
I'm struggling to connect to my MS SQL Express 2008 edition from my PHP files, but it seems virtually impossible.
I've found several guides/notes on teh intarweb solving the issues, but none of these have helped me any further.
I've taken a script from another site and entered my database information, but I still get errors:
<?php
$myServer = "localhost";
$myUser = "demo_basic";
$myPass = "1234";
$myDB = "demo_basic";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT nitid, nisname ";
$query .= "FROM navitems";
//execute the SQL query and return records
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
//display the results
while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["nitid"] . $row["nisname"] . "</li>";
}
//close the connection
mssql_close($dbhandle);
?>
I get this error:
Warning: mssql_connect()
[function.mssql-connect]: Unable to
connect to server: localhost in
C:\inetpub\vhosts\dexterholding.dk\httpdocs_rip\sql.php
on line 8 Couldn't connect to SQL
Server on localhost
You can see for yourself at: http://www.dehold.net/_rip/sql.php
Any ideas?
I'm running Windows Server 2008 with PLESK and PHP5 as FastCGI.
I found this guide which actually made it work for me:
http://samsami2u.wordpress.com/2008/06/30/how-to-connect-mssql-with-php/
With MSSQL, your server name will look like this: machinenameoraddress\serverinstancename
and example would be 192.168.14.201\MSSQLEXPRESS or TESTMACHINE\MYTESTDBSERVER.
It could be that the user account does not have permission to access SQL Server.
Although looking at your code you are using SQL auth and not Windows authentication, presumably this account is set up in SQL Server and it is configured to allow SQL Auth?
So a friend of mine and I are using both xampp on ubuntu, if that helps, to connect between each other's website, We both created the same php file to connect, so we use de IP of the other, but then it says an error
Warning: mysql_connect() [function.mysql-connect]: Host 'coke-laptop.local' is not allowed to connect to this MySQL server in /opt/lampp/htdocs/connection.php on line 2
Could not connect: Host 'coke-laptop.local' is not allowed to connect to this MySQL server
We have this code on the connection.php file:
<?php
$link = mysql_connect('10.100.161.37','root','');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
//echo 'Connected successfully';
$db_selected = mysql_select_db('Prueba', $link);
if (!$db_selected) {
die ('Can\'t use Prueba : ' . mysql_error());
}
// This could be supplied by a user, for example
$firstname = 'fred';
$lastname = 'fox';
// Formulate Query
// This is the best way to perform an SQL query
// For more examples, see mysql_real_escape_string()
$query = sprintf("SELECT * FROM Agencia");
// Perform Query
$result = mysql_query($query);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
// Use result
// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.
while ($row = mysql_fetch_assoc($result)) {
echo $row['ID'] . " ";
echo $row['Nombre'] . "\n\r";
}
// Free the resources associated with the result set
// This is done automatically at the end of the script
mysql_free_result($result);
mysql_close($link);
?>
If we use the IP just like that, we can enter each others xampp normal welcome page.
Check you have enabled remote access to the MySQL server. Open the my.cnf file (probably found inside xampp/etc/), go to the [mysqld] section and add the following (using your own ip address instead of the example)
bind-address=192.168.1.100
If there is a line that says skip-networking, comment that out so it looks like this:
# skip-networking
then restart the MySQL server
It looks like your MySQL database isn't allowing you to connect remotely with the credentials you provided. You will need to configure a remote user to connect. Try looking into MySQL Grants.
For Example:
GRANT SELECT, INSERT ON database.* TO 'someuser'#'somehost';