Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a website. I'm using MySQL Workbench 6.3. I have MySQL installed.
How hard can it be to send and receive data from this database, from the website? I don't know php yet, but I can learn it if that's necessary.
What I want is simply to, for example, have a form on a website which sends it's information to the database. I understand about the columns in the database, and I've created a database table thing on the MySQL workbench, but I don't know how to host this database, or how to access it from my website.
Even just some good links would be helpful, as I haven't found any.
You actually can Google but you can go try to learn at the links below:
w3schools.com
php.net
And you need to learn sql too. For sql, this links can help you:
w3schools.com
tutorialspoint.com
Hope this links will make your job easier.
And a quick tutorial by me:
mysql_* commands are no longer available. Use mysqli or PDO.
Connecting To Your Database:
Using mysqli
<?php
$conn = new mysqli($servername, $username, $password);
?>
Using PDO:
<?php
$conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password);
?>
Hope everything will work fine, happy coding!
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to create a database called "loadboard". I am using PHPMyAdmin so I'm simply using the database wizard. When I enter "loadboard" into the database name field and submit it I get an error saying that the database already exists. The same error happens if I run a SQL command. When I go to my databases there is only one there and it is "information_schema". Why would MySQL think a database exists even though it doesn't? This is on a Linux server.
On a side note no matter what I try to name the database, it still belives it exists.
EDIT: I was able to get a database created using the name schrödingers_cat. It shows up, but then I tried to make one called loadboard again and I am getting the same error and it still does not show up.
Also if your going to downvote i'd appreciate some reasoning considering my problem is clearly outlined.
The user you are connecting as may not have permissions to view the existing loadboard database. Try connecting as root. You'll likely see it then.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm new to web development, and for the college thesis I'm going to create an online system that uses a database. My question is: how should one create a database?
a) Using PHP such as:
<?php
$servername = "host_name";
$username = "user_name";
$password = "password";
$dbname = "dbname";
$link = connectToMySql($servername, $username, $password) or die( " Unable to connect to server ");
$query = "CREATE DATABASE IF NOT EXISTS $dbname";
if (executeSQLQuery($query))
{
echo "Database <b>$dbname</b> created successfully <br />";
}
else
{
echo "Error in creating database: <br/><br/>". launchError();
}
?>
b) Or using phpMyAdmin (creating manually database and tables)?
Which approach is the best? Which one should be used and why (Advantages, disadvantages)?
For a thesis, it hardly matters.
For normal development, if you are the only user of your software, then it is probably easiest to maintain it in a maintenance tool like PHPMyAdmin, because you can create and update it in a very visual way.
Creating it in software is especially useful as an installation feature. Some common software, like Wordpress and MediaWiki create their own database and even have smart scripts that update the database structure when a new version has additional requirements. But building something like that is also tricky and time-consuming, so unless you want to have such an installer feature, it is probably not worth the effort.
Also note, that for proper database management, you'll want to have different users with different rights. You may want to make your software connect using database credentials that only have rights to edit data (not structure), and only connect using a more powerful user if you have to update the database structure. But that probably also doesn't apply for a thesis, unless it is specifically about access control management.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am planing to create a project in PHP which will be connected with MongoDB due to the MongoDB flexiblity. The goal is to store in the MongoDB some documents that can vary during the time and with MongoDB we can add extra data without changing the structure of the DB, which is not the case with MySQL.
My question is: Is it a good idea to use MongoDB as the unique DB, or should I use it together with MySQL. The MySQL for the data as user login info etc, and the MongoDB for documents.
I am planning to use the Symfony2 framework or the CakePHP.
Thank you in advance.
I think it's a good idea to use MongoDB as the unique DB. It's a lot easier to use one database and MongoDB can handle the user login info just fine. You may want to change some collections over to MySQL in the future though.
MongoDB is pretty new compared to MySQL so it does have some drawbacks. For one, MongoDB is not as reliable as MySQL so your bound to run into a few bugs. It will also be harder to find answers to your questions as MySQL is far more popular.
MongoDB is great, but you must make sure you have the time to get to know it. If your short on time or are making it for a client, MySQL is probably a better option.
If a single DB server can handle the job, I'd stick to MySQL. The frameworks you are going to use have this DB in mind.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I haven't found anything that matches my situation...
I am using XAMPP, which has MySQL as a backend and PHP in the front (web) end. in the Administration screen of MySQL (phpMyAdmin) I can create and run SQL requests. There is also an option of "Bookmark this SQL Query: "
Suppose i save a "Bookmark SQL Query". Is it possible for PHP to reference this Bookmark SQL Query? or do I have to create that query in PHP. It would be easier to reference the Bookmarked query, rather than make the full SQL query
Thanks.
Thanks to those who understood the question. You are smarter than those to didn't.
PHPMyAdmin is simply a PHP application that interfaces with your database. Anything you save on it stays on it.
Your PHP application is completely different from PHPMyAdmin and unless you create such a feature, you cannot use it within your application.
If you create a SQL execution interface within your application, you can also create something like that to be able to re-use the query.
Hope the explanation makes sense and the answer helps.
No, I don't think it's possible, the feature you're talking about is a feature in the client application only. You should write the query in PHP. That way you don't have to rely on an external feature/query for the application to work either.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I've decided to switch to MySQLi, because some people have told me it's more secure.. What I'm really confused about, is the new extensions. I tried just added 'i' after every mysql, but that gave me a crap load of errors. I looked up in the PHP manual why that was happening and there was a whole bunch of other functions.. I honestly can't figure out how to convert. Can you help me out?
include("dbinfo.php");
mysql_connect($c_host,$c_username,$c_password);
#mysql_select_db($c_database) or die(mysql_error());
$mycon = new mysqli($c_host, $c_username, $c_password, $c_database);
$query="SELECT * FROM users WHERE username='" .$_COOKIE['username']. "'";
$result=mysql_query($query) or die(mysql_error());
$num=mysql_numrows($result);
$username=mysql_result($result,$i,"username");
Here's what you need to do:
Read the overview so that have an understanding of the differences/advantages.
Consult the old -> new function summary on the PHP site and get your existing code up and running with the mysqli interface.
Take advantage of the improvements (such as using prepared statements) otherwise this is a futile exercise. (By default mysqli really isn't any more secure than mysql.)
One of the reasons MySQLi is more "secure" is because it offers a different interface, which is better in many ways. Instead of trying to translate your code directly, learn the new interface and use it. If that's all your code, it wouldn't be easy to rewrite from scratch, and which is more important, look up the equivalents (and alternatives) for everything you're doing in the code that you pasted.
For starters, you should use $mysqli->prepare with parameters instead of interpolating variables like you're doing.
http://www.php.net/manual/en/mysqli.prepare.php