Jump to content

Recommended Posts

Posted

Just looking for information on how to get a PHP page to run. I am getting an error:

Parse error: syntax error, unexpected $end in /home/username/public_html/holly/test.php on line 17

 

 

edit: please don't post your cPanel username -th

Posted

Like they said, post Line 17 and we can probably help you out. Don't forget to put your ; at the end of every line. Gets me every time.

Posted

I found that error, now have this error:

Warning: mysql_connect(): Access denied for user 'laurel'@'server369.tchmachines.com' (using password: NO) in /home/username/public_html/holly/test2.php on line 19

Unable to connect to database! Please try again later.

 

Here is part of the script:

//Connect To Database

$hostname="server369.tchmachines.com";

$username="laurel";

$password="";

$dbname="vendorlist";

$usertable="VENDORINFO";

$yourfield = "vendor_nm";

 

mysql_connect($hostname,$username, $password) OR DIE ("Unable to connect

to database! Please try again later.");

mysql_select_db($dbname);

Posted

hostname should be "localhost"

 

user should be "cpanelname_laurel"

 

dbname should be "cpanelname_vendorlist"

 

password is just the password.

 

And be sure you added the user to the database.

Posted

I'm sure you can tell, this is my first time trying this... I made the changes that you suggested, but still getting error:

Warning: mysql_connect(): Access denied for user 'cpanelname_lktodd'@'localhost' (using password: YES) in /home/cpanelname/public_html/holly/test2.php on line 22

Unable to connect to database! Please try again later.

 

Here's the full script. I created two tables: VENDORINFO and VENDOR_LEVEL. I did add lktodd to the database. Is there a better tool to see this type of info? I'm a hardcore SQL person and feel like I'm blindfolded...

 

<?php

//Connect To Database

 

$hostname="localhost";

$username="cpanelname_lktodd";

$password="********";

$dbname="cpanelname_vendorlist";

$usertable="VENDORINFO";

$yourfield = "vendor_nm";

 

 

mysql_connect($hostname,$username, $password) OR DIE ("Unable to connect

to database! Please try again later.");

mysql_select_db($dbname);

 

$query = "SELECT * FROM $usertable";

$result = mysql_query($query);

if($result) {

while($row = mysql_fetch_array($result)){

$name = $row["$vendor_nm"];

echo "Name: ".$name;

}

}

?>

Posted

Another thought:

I installed Apache, PHP, MySQL on my PC last weekend. When I say localhost, is it going there to to TCH?

 

 

 

 

 

<?php

//Connect To Database

 

$hostname="localhost";

$username="cpanelname_lktodd";

$password="*********";

$dbname="cpanelname_vendorlist";

$usertable="VENDORINFO";

$yourfield = "vendor_nm";

mysql_connect($hostname,$username, $password) OR DIE ("Unable to connect

to database! Please try again later.");

mysql_select_db($dbname);

 

$query = "SELECT * FROM $usertable";

$result = mysql_query($query);

if($result) {

while($row = mysql_fetch_array($result)){

$name = $row["$vendor_nm"];

echo "Name: ".$name;

}

}

?>

Posted

I understand you are seeking help but posting your passwords with links for your site is just asking for trouble.

 

Are you testing this from your own PC?

Posted

Yes, working from my own PC. I think one of my postings was dropped somehow... maybe because of the passwords? This is just a test website. I guess I have to "encrypt" everything when I send it.

 

did you get the other message?

 

I understand you are seeking help but posting your passwords with links for your site is just asking for trouble.

 

Are you testing this from your own PC?

Posted

I have hidden both messages. Ok set local host back to the server name. And in your cPanel under MySQL Databases scroll down to the access hosts section and add your PC's IP number.

Posted

That didn't seem to work either. In the meantime, I stopped MySQL and Apache on my PC.

 

Getting the same error - can you think of something else?

 

I have hidden both messages. Ok set local host back to the server name. And in your cPanel under MySQL Databases scroll down to the access hosts section and add your PC's IP number.
Posted

Where is the database? On your PC or the TCH server?

 

I'm getting a little confused by what you are tryng to do. If you are working in your own environment, some of the information we are giving you isn't going to work. Like prefacing the username and dbname with your cpanelname_

Posted

I went into cPanel and created a MySQL database there. Then I wrote the PHP script in Dreamweaver and uploaded it to the directory I showed you on the server.

 

My brother was trying to "help" me last weekend and suggested I install all the stuff locally. Just confused me more.

Posted

If the database and script are on the server and you are running on the server the config variables would be.

 

hostname "localhost"

dbname "your-cpanel-name_data-base-name"

user "your-cpanel-name_user-name"

password "what-ever-you-set"

 

That's it, should work. If not, I'm afraid I am at a loss what else to try.

Posted

I deleted the user from the database and re-added it and I'm not getting the error. Not getting any data, but I can deal with that. Thanks for your help!

 

Laurel

 

 

If the database and script are on the server and you are running on the server the config variables would be.

 

hostname "localhost"

dbname "your-cpanel-name_data-base-name"

user "your-cpanel-name_user-name"

password "what-ever-you-set"

 

That's it, should work. If not, I'm afraid I am at a loss what else to try.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...