Jump to content

Php


lktodd
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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;

}

}

?>

Link to comment
Share on other sites

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;

}

}

?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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_

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

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

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

 Share

×
×
  • Create New...