User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Nov 2007
Posts: 40
Reputation: jay64 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
jay64's Avatar
jay64 jay64 is offline Offline
Light Poster

Help Learning PHP: getting parse error

  #1  
Nov 30th, 2007
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.

<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>

AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Posts: 40
Reputation: jay64 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
jay64's Avatar
jay64 jay64 is offline Offline
Light Poster

Re: Learning PHP: getting parse error

  #2  
Nov 30th, 2007
Update: this is the version of PHP and MySQL being used by the server:

Your site comes with PHP 4.3.2 and MySQL 3.23.


Don't know if that makes a difference or not, but I read something about PHP 4 being dead, so thought I would at least include the information.
Reply With Quote  
Join Date: Nov 2007
Location: Arkansas
Posts: 416
Reputation: buddylee17 will become famous soon enough buddylee17 will become famous soon enough 
Rep Power: 3
Solved Threads: 81
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro in Training

Re: Learning PHP: getting parse error

  #3  
Nov 30th, 2007
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.
  1. echo "Error creating database: " . mysql_error();
  2.  
  3. ?>
should be:
  1. echo "Error creating database: " . mysql_error();
  2. }
  3. ?>
Reply With Quote  
Join Date: Nov 2007
Posts: 40
Reputation: jay64 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
jay64's Avatar
jay64 jay64 is offline Offline
Light Poster

Re: Learning PHP: getting parse error

  #4  
Nov 30th, 2007
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.
Reply With Quote  
Join Date: Nov 2007
Posts: 40
Reputation: jay64 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
jay64's Avatar
jay64 jay64 is offline Offline
Light Poster

Re: Learning PHP: getting parse error

  #5  
Nov 30th, 2007
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.
Reply With Quote  
Join Date: Nov 2007
Location: Arkansas
Posts: 416
Reputation: buddylee17 will become famous soon enough buddylee17 will become famous soon enough 
Rep Power: 3
Solved Threads: 81
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro in Training

Re: Learning PHP: getting parse error

  #6  
Nov 30th, 2007
Glad to help.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:21 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC