Hello, how do i host a php script?

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
directory (folder) must be in public_html or a subdirectory

to save yourself headaches, use only lowercase for directory and file names. Hello.php is different from hello.php

to save yourself headaches, do not put spaces in directory or file names.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Your site begins with public_html . So any file myfile.html would be accessed by:

yourdomain.com/myfile.html

public_html does not appear the the URL
 

unfthrea

New Member
Messages
5
Reaction score
0
Points
0
alright! next wall reached, i'm trying to have a php script submit data to mysql but I can't find the localhost name for my database. any thoughts?
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Host name is localhost
DB names and DB usernames are of the format yourCPanelUsername_foo
You create DB's and usernames using MySQL Databases in cPanel. Remember to add the user to the DB with ALL PRIVILEGES box checked.
 

unfthrea

New Member
Messages
5
Reaction score
0
Points
0
Thank you, I took your advice but received this error "Warning: mysql_connect() [function.mysql-connect]: Access denied for
user 'unfthrea_surveyt'@'localhost' (using password: YES) in
/home/unfthrea/public_html/survey/insert.php on line 2
Could
not connect: Access denied for user 'unfthrea_surveyt'@'localhost' (using
password: YES)"

I chose a simple code to test things out.
<?php
$con = mysql_connect("localhost","unfthrea_surveyt","********");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("my_db", $con);

$sql="INSERT INTO Persons (FirstName, LastName, Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";

mysql_close($con);
?>

---------- Post added 04-13-2012 at 01:20 AM ---------- Previous post was 04-12-2012 at 11:31 PM ----------

I used a tutorial to make sure it wasn't anything I was doing.
http://www.freewebmasterhelp.com/tutorials/phpmysql

When I enter database, am I supposed to enter the name of the database AND the name of the table somehow?
 
Last edited by a moderator:

unfthrea

New Member
Messages
5
Reaction score
0
Points
0
DB names and DB usernames are of the format yourCPanelUsername_foo
.

Thank you for helping me. We are almost done with the problems! Just a little bit further and I can make my survey for charity reasons. This part confuses me. Are you saying that when I create the database I need to name it unfthrea_foo (unfthrea is my cpanel username). ? Because then I couldn't make more than one DB. Also, it would not let me name the user of the DB the same name as the DB itself. So I am unsure how to follow your instructions.

---------- Post added at 02:58 PM ---------- Previous post was at 02:44 PM ----------

OK I think it's working using unfthrea_foo. Does this mean I can only create one DB and DB username? Or can I make unfthrea_foo2,unfthrea_foo3, etc?

---------- Post added at 07:42 PM ---------- Previous post was at 02:58 PM ----------

Partial success! I've successfully added 2 new entries to the database. The problem I have, however, is that the ID is recorded correctly but the other info just shows up as ;;;;;;
 
Top