•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 455,979 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,786 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 554 | Replies: 5 | Solved
![]() |
Hi, I am very new to PHP, teaching myself at the moment. I am using online tutorials to teach myself, so I am at their mercy of what information they provide. I have found some decent scripts, but they don't show me how to link them together.
I am trying to teach myself how to make a database using PHP and MySQL. I have a server that is hosting the website I am going to try to use this on. The server claims that it supports PHP and MySQL. I using some very basic script that I found on some tutorials in order to start using it, to get a better understanding of how it works. I don't know if this makes any difference, but I am currently using Dreamweaver MX 2004 to write my code in, and to upload to the server. My first script that I tried to upload was a 'create database' script. I uploaded it to the server and then tried to open the file, and I received this error message:
'Parse error: parse error in /var/www/html/db/create_befit_database.php on line 20'
I haven't been able to find what a parse error means. I will attempt to include the script that I used, but this is my first time, so forgive me if I mess it up. I obviously took out the actual data from the host/username/password for security reasons, but it is there in the script that I uploaded into the server. Line 20 appears to me to be the closing html tag. This seems to be such a basic script that it is frustrating that I am already getting an error. I did notice that when I was inputing the connect information, dreamweaver had a pop up suggesting how to finish the code I started writing, and it was a little different then the code the tutorials had used. The tutorials had used quotes around the host/username/password names, but dreamweaver seemed to suggest using brackets, and they suggested inputing the ftp folder name. Sorry if this is just rambling, but I'm trying to include as much details as possible. Thanks in advance for any input in this. Here is my attempt at including the script.
I am trying to teach myself how to make a database using PHP and MySQL. I have a server that is hosting the website I am going to try to use this on. The server claims that it supports PHP and MySQL. I using some very basic script that I found on some tutorials in order to start using it, to get a better understanding of how it works. I don't know if this makes any difference, but I am currently using Dreamweaver MX 2004 to write my code in, and to upload to the server. My first script that I tried to upload was a 'create database' script. I uploaded it to the server and then tried to open the file, and I received this error message:
'Parse error: parse error in /var/www/html/db/create_befit_database.php on line 20'
I haven't been able to find what a parse error means. I will attempt to include the script that I used, but this is my first time, so forgive me if I mess it up. I obviously took out the actual data from the host/username/password for security reasons, but it is there in the script that I uploaded into the server. Line 20 appears to me to be the closing html tag. This seems to be such a basic script that it is frustrating that I am already getting an error. I did notice that when I was inputing the connect information, dreamweaver had a pop up suggesting how to finish the code I started writing, and it was a little different then the code the tutorials had used. The tutorials had used quotes around the host/username/password names, but dreamweaver seemed to suggest using brackets, and they suggested inputing the ftp folder name. Sorry if this is just rambling, but I'm trying to include as much details as possible. Thanks in advance for any input in this. Here is my attempt at including the script.
<html>
<body>
<?php
$con = mysql_connect("Host", "username", "password"
);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}// Create database
if (mysql_query("CREATE DATABASE testhouses_db",$con))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
?>
</body>
</html>
You should contact the host and find out if you have any sort of db admin tool. My host has phpMyAdmin. This allows you to interact directly with the db instead of writing php scripts, uploading them to the ftp, then running them once with no way (except for writing another script to query the db and display the results) of seeing if the data was entered the way you wanted it to be. If you don't have an admin tool you should be able to configure mysqlcc (open source tool by SourceForge.net) to directly interact with the db.
As for the parse error, you never closed the loop at the end.
should be:
As for the parse error, you never closed the loop at the end.
php Syntax (Toggle Plain Text)
echo "Error creating database: " . mysql_error(); ?>
php Syntax (Toggle Plain Text)
echo "Error creating database: " . mysql_error(); } ?>
Buddylee, Thanks for catching that open loop at the end. I just copied and pasted it off one of the tutorials, so I missed that entirely. I will check and see if that works now.
As far as my host having a db admin tool, I will check into it. But I do want to try to learn all the ins and outs, so if there is also a way to write a script to query the db and display the results, I want to know how to do that too. However, I know it will be a lot easier to just use an admin tool.
As far as my host having a db admin tool, I will check into it. But I do want to try to learn all the ins and outs, so if there is also a way to write a script to query the db and display the results, I want to know how to do that too. However, I know it will be a lot easier to just use an admin tool.
Ah yes. Now I remember seeing this. This was part of the introduction email they sent me a very long time ago. At the time I had no idea what MySQL even was, so I guess it didn't even register in my head. Good call Buddylee!
================
MYSQL DATABASE:
================
- Login to your site's Control Panel, click "MySQL Password" to create your database password for the first time.
- Now you can access your database admin screen by going to "Database Manager", use the following:
Username: xxxxxxx
Password: type the password you created in the previous step (even though you use the same ID to login to both the Control Panel and MySQL, the passwords don't have to match).
- Your database will contain no tables or fields which must be created by you. Knowledge of database functions is recommended.
================
MYSQL DATABASE:
================
- Login to your site's Control Panel, click "MySQL Password" to create your database password for the first time.
- Now you can access your database admin screen by going to "Database Manager", use the following:
Username: xxxxxxx
Password: type the password you created in the previous step (even though you use the same ID to login to both the Control Panel and MySQL, the passwords don't have to match).
- Your database will contain no tables or fields which must be created by you. Knowledge of database functions is recommended.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the PHP Forum
- Previous Thread: while if and substring
- Next Thread: converting from cgi perl


Linear Mode