lktodd Posted May 5, 2006 Share Posted May 5, 2006 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 Quote Link to comment Share on other sites More sharing options...
chatbug Posted May 5, 2006 Share Posted May 5, 2006 Hmm... would be good if you can post a section of the offending code here. Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted May 5, 2006 Share Posted May 5, 2006 Maybe a little more information would be useful. You have a syntax error on line 17. Quote Link to comment Share on other sites More sharing options...
TCH-Tim Posted May 5, 2006 Share Posted May 5, 2006 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. Quote Link to comment Share on other sites More sharing options...
lktodd Posted May 5, 2006 Author Share Posted May 5, 2006 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); Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted May 5, 2006 Share Posted May 5, 2006 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. Quote Link to comment Share on other sites More sharing options...
TCH-Tim Posted May 5, 2006 Share Posted May 5, 2006 and hopefully the password field isn't really blank... Quote Link to comment Share on other sites More sharing options...
lktodd Posted May 5, 2006 Author Share Posted May 5, 2006 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; } } ?> Quote Link to comment Share on other sites More sharing options...
lktodd Posted May 5, 2006 Author Share Posted May 5, 2006 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; } } ?> Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted May 5, 2006 Share Posted May 5, 2006 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? Quote Link to comment Share on other sites More sharing options...
lktodd Posted May 5, 2006 Author Share Posted May 5, 2006 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? Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted May 5, 2006 Share Posted May 5, 2006 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. Quote Link to comment Share on other sites More sharing options...
lktodd Posted May 5, 2006 Author Share Posted May 5, 2006 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. Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted May 5, 2006 Share Posted May 5, 2006 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_ Quote Link to comment Share on other sites More sharing options...
lktodd Posted May 5, 2006 Author Share Posted May 5, 2006 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. Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted May 5, 2006 Share Posted May 5, 2006 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. Quote Link to comment Share on other sites More sharing options...
lktodd Posted May 5, 2006 Author Share Posted May 5, 2006 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. Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted May 5, 2006 Share Posted May 5, 2006 Great, glad you are past the error at least. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.