help me please guys
I've searched and tried all the articles here
but still can not get results from INFORMATION_SCHEMA
I want to get a relationship between tables using KEY_COLUMN_USAGE but still not showing anything, just displaying a blank page
I do not understand what went wrong:
I've used the code I used to use, as below
$server = "localhost";
$user= "root";
$pass= "";
$db= "my_DB";
$conn = mysql_connect($server, $user, $pass) or die ("can't connect server" .mysql_error());
$openconn= mysql_select_db($db) or die ("can't open DB " .mysql_error());
$sql="using_select_command_here";
$query = mysql_query($sql) or die ("error:" .mysql_error());
while ($data = mysql_fetch_array($query)) {
print_r($data);
}
from all sources are here like :
How to find tables all relation in MySQL
How to know relations between tables
the result still showing blank page:
I do not understand if there are other factors?
I am using php version 5.3.1
and mysql version 5.1.41
from xampp for windows ver1.7.3
Related
I have a database hosted on my computer using MySQL Workbench. I have a website hosted on my computer using IIS. I have created a database fennypvp and a table accounts with columns id, username and password. I have added multiple entries into the table from MySQL Workbench. Now I am simply trying to get these entries from the website with PHP. For now I'd simply like to be able to print the entries and from there I will work on validating credentials etc. I have look up quite a bit and nothing has worked for me. Here is what I've got so far:
<?php
$host="127.0.0.1";
$port=3306;
$socket="";
$user="root";
$password="";
$dbname="fennypvp";
$con = new mysqli($host, $user, $password, $dbname, $port, $socket)
or die ('Could not connect to the database server' . mysqli_connect_error());
$query = "select * from accounts";
if ($stmt = $con->prepare($query)) {
$stmt->execute();
$stmt->bind_result($field1, $field2);
while ($stmt->fetch()) {
printf("%s, %s\n", $field1, $field2);
}
$stmt->close();
}
$con->close();
?>
The above is code generated by MySQL Workbench although the page sql.php is blank. Any ideas?
Here is the database and table information:
I need to write a script which will take the values from two columns and use them to update the column in a view that I created in another database. In the first database I have sku and qty as well as in the view.
here is my code:
$server = 'localhost';
$user = 'invodata';
$pass = 'Abcd1234!1';
$dbname = 'tboinvodata';
$con = mysql_connect($server, $user, $pass) or die("Can't connect");
mysql_select_db("tboinvodata") or die(mysql_error());
$result = mysql_query("SELECT item, onhand FROM immaster"); <- this is getting the values from the columns in the first data base
$server = 'localhost';<-setting up my second connection to other database
$user = 'tbo';
$pass = 'Abcd1234!1';
$dbname = 'i187358_mage1';
$con = mysql_connect($server, $user, $pass) or die("Can't connect");
mysql_select_db("i187358_mage1") or die(mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {<-this gets the array from other database
UPDATE qtyview SET qty = $row["onhand"] WHERE sku = item;<- this should update the necessary columns "sku" is used in my view and "item" is used in the first data base I use this so the proper rows in the other columns get updated.
}
?>
really not sure what I am doing wrong I am pretty new to this though.
You can make multiple calls to mysql_connect() and use them like this.
First connect to two your MYSQL USER
$con1 = mysql_connect($server, $user, $pass);
$con2 = mysql_connect($server, $user, $pass, true);
Then establish a connect with different DATABASE
mysql_select_db('firstdatabase', $con1);
mysql_select_db('seconddatabase', $con2);
Then query from firstdatabase like this
mysql_query('select * from views', $con1);
And query from seconddatabase
mysql_query('select * from views', $con2);
This code is not tested by me...but i think it will work good for you.. :)
I'm not sure what's wrong with the following code. I'm trying to connect to MSSQL with PHP to run a query. The code can connect to the server and database, but fails on query execution. This code is virtually identical to the way I retrieve data from MySQL. What is the mistake I'm making here?
Thanks.
$link = mssql_connect ($server, $user, $password)
or die ( "<h1>ERROR: Can't connect to MSSQL.</h1>");
$db_selected = mssql_select_db ($db, $link)
or die ("<h1>ERROR: Can't read MSSQL database.</h1>");
$sql = 'SELECT * FROM [uStore].[dbo].[Store]';
$result = mssql_query ($sql)
or die ("<h1>ERROR: Can't execute MSSQL query.</h1>");
echo 'ok';
mssql_free_result ($link);
Hey guys im trying to connect to an oracle database with php. I tried it like i do it with mysql.
How to do it like this:
$host="localhost";
$user="username";
$pass="password";
$db="database";
$link = mysql_connect($host, $user, $pass) or die ("Keine Verbindung zu der Datenbank moeglich.");
mysql_select_db($db, $link);
$sql = "SQL query goes here";
$result = mysql_query($sql);
How can i do exact this with an oracle database. I have the following connection details
sid, ip, port, username, password.
Simple script:
$DB = '//1.2.3.4:1521/XE';
$DB_USER = 'user';
$DB_PASS = 'pass';
$DB_CHAR = 'AL32UTF8';
$conn = oci_connect($DB_USER, $DB_PASS, $DB, $DB_CHAR);
$statement = oci_parse($conn, 'select 1 from dual');
oci_execute($statement);
$row = oci_fetch_array($statement, OCI_ASSOC+OCI_RETURN_NULLS);
To connect with an Oracle database, you don't use the mysql extension (since that is for MySQL). You should use PDO, with the OCI/Oracle adapter.
You'll want to use PDO to connect to Oracle here is the PHP manual page on creating a connection using PDO, the example given is for MySQL but it will work fine with Oracle. You will need to ensure the PDO:Oracle extension is installed and running on your PHP configuration.
database get connected successfully....but...
here is my code
<?php
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'databasename';
mysql_connect($host, $user, $pass) or die ("Database Not Connected");
mysql_select_db($db) or die ("Database Not Fount");
?>
but the database is regularly disconnecting and connecting after 30-40 minutes....please help me, that what's going on.....
Don't forget to close your connection with mysql_close().
Too many connections will cause problems so that might explain your disconnects.
This may be the problem of confusing variables. Your connection and db-selection shouldn't be confused with queries that will run at a later time.
$conn = mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
$query = "SELECT id, username FROM users";
In this example, $conn will not be used to reference anything other than my resource. My query, ran at a later time, will be known as $query, so as to not confuse myself.
I would also suggest watching the execution times of your queries, and the number of concurrent connections opened. If you need to, be sure to close your connections:
mysql_close($conn); // note the importance of a unique variable here