|
-
Senior Member
Basic Questions
I am considering learning to program in PHP and mySQL and i was wondering if some body could answer my questions.
What is PHP?
What is mySQL?
Can i create .txt files?
Can i edit .txt files?
Where can i download the latest Apache server? (A link directly to the file would be nice)
When a webpage has PHP instead of HTML, what does that mean?
Can i create a web page in PHP?
What are the best tutorials for learning them together?
Quite a newbie list of questions but we all gota start some were, also if there is anything else that i should know dont forget to put it in your post.
Cheers
92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!
-
Wait- what now?
If you know your actionscript youll be soo shocked at how easy php is. Php is good because it can dynamically make webpages without you having to edit multiple pages.
For example a complex list of pages (one for each animation) could simply be replaced with one page.
You can make a whole website with php and most hosts will know that if there is no index.html to goto a index.php,
Php is completly secure as no-one can view the server side code, only the HTML which is specified by the creator.
for example in dreamweaver if you create a php page then:
<?php
echo("<b>Hello!</b>");
?>
will be the same as
<b>Hello!</b>
in Html.
Php is also good with Mysql, downloading things like settings, passwords and usernames are great for your websites or even flash games security!
Ive been learning php for about 1 week and i am nearly done making a working mySQL/php guestbook!
Php uses these thing that AS also uses:
For loops
if(statement == 1){
$statement = 0
}
else
{
$statement = 1
}
this would do the same thing in AS as it would in php!
Im not sure about your 4th and 3rd question but you can save php files using text editors like notepad.
www.tutorialized.com is great for php and mysql,
"I'd only told them the truth. Was that so selfish? Our integrity sells for so little, but it is all we really have. It is the very last inch of us, but within that inch, we are free."
-
Senior Member
Sorry this doesnt realy relate to flash...
I have a script which i managed to find on the net, i have a web host that supports up to php5 with read/write compatable. What my scipt does is creates a text box and a submit button, what ever i have writen in the text box when i hit submit gets writtin to another php file.
Unfortuanly the tutorial doesn say anything about how to use it, do i have to add somthing to a html page? I tryed opening the php file with firefox from my HDD but it doesnt work. Can some one help me on this?
If i didnt explain my self properly - I want to know how to make my php work on a webpage.
92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!
-
Wait- what now?
Can you post the tutorial link?
"I'd only told them the truth. Was that so selfish? Our integrity sells for so little, but it is all we really have. It is the very last inch of us, but within that inch, we are free."
-
Bearded (M|G)od
you cant run the php file from your local computer unless you have php and a server installed on it. so upload it to your remote server and give it a try.
-
Senior Member
you cant run the php file from your local computer unless you have php and a server installed on it. so upload it to your remote server and give it a try.
Oh ok, and my host will display the php files as a html page? If i wanted to add this script to another html page do i add in the php to the html file where ever i want it? Or do i specify with html where the location of the php file is and to load it?
Ill go give your advice a shot.
92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!
-
Bearded (M|G)od
say your file is called 'page1.php'. upload it to your server to the root directory. then browse to www.yoursite.com/page1.php it should work. thats all you have to do.
-
Hi,
if you have a snippet of php code that you want to add to your html files, just do so - and rename the html file to php
Musicman
-
Senior Member
Oh awsome, so it doesnt matter as long as my php code in in its php tags? And people cant see my php code can they?
92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!
-
Wait- what now?
nope, no one can see your code, they cant even use save page as to view it
"I'd only told them the truth. Was that so selfish? Our integrity sells for so little, but it is all we really have. It is the very last inch of us, but within that inch, we are free."
-
Bearded (M|G)od
nope...noone can see your php code unless they have access to the server via ftp and can actually download the .php file like you can
-
Senior Member
Cheers for those replys. I have spent the last day or so learning php and tryed making a new reader thing. Could some on point out my problem in my following code, i will document it.
This is my add news.php code, it does add a heading, the text, date, and who submitted it to a text file called news.txt (This does work)
PHP Code:
<?
//addnews.php
//Check to see if the submit button has been pressed
if($HTTP_POST_VARS['submit']) {
//Check to see if the password is pass
if($HTTP_POST_VARS['password'] == 'pass') {
//Check to see if the name box has somthing in it
if(!$HTTP_POST_VARS['name']) {
echo "You must enter a name";
exit;
}
//Check to see if the news box has somthing in it
if(!$HTTP_POST_VARS['news']) {
echo "You must enter some news";
exit;
}
//Check to see if the name box contains a pipe symbol
if(strstr($HTTP_POST_VARS['name'],"|")) {
echo "Name cannot contain the pipe symbol - |";
exit;
}
//Check to see if the news box contains a pipe symbol
if(strstr($HTTP_POST_VARS['news'],"|")) {
echo "News cannot contain the pipe symbol - |";
exit;
}
//Open up the text file, if its not there it will try to make it
$fp = fopen('news.txt','a');
//Check to see if it can be opened
if(!$fp) {
echo "Error opening file!";
exit;
}
//Adds the date and the name
$line = date("m.d.y") . "|" . $HTTP_POST_VARS['name'];
//Adds the news
$line .= "|" . $HTTP_POST_VARS['news'];
//Adds the subject
$line = "|" . $HTTP_POST_VARS['subject'];
//I dont know what the next to lines do...
$line = str_replace("\r\n","<BR>",$line);
$line .= "\r\n";
fwrite($fp, $line);
if(!fclose($fp)) {
echo "Error closing file!";
exit;
}
} else {
echo "Bad Password";
}
}
?>
<FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="newsentry">
Heading:<BR>
<INPUT TYPE="text" SIZE="30" NAME="subject"><BR>
Your name:<BR>
<INPUT TYPE="text" SIZE="30" NAME="name"><BR>
The News:<BR>
<TEXTAREA NAME="news" COLS="40" ROWS="5"></TEXTAREA><BR><BR>
News Password:<BR>
<INPUT TYPE="password" SIZE="30" NAME="password"><BR>
<INPUT TYPE="submit" NAME="submit" VALUE="Post it!"><BR>
</FORM>
This next file displays what i have in that text file.
PHP Code:
<?php
//DISPLAYING NEWS///////////////////////////////////////////////////////////
//set data as news.txt
$data = file('news.txt');
//set data to its self but backwards
$data = array_reverse($data);
//From what i understand it goes threw all the data in my txt file and seperates each lot of data between "|" and adds them to a place in an array
foreach($data as $element) {
$element = trim($element);
$pieces = explode("|", $element);
//Displays each array which has stuff in it.
echo $pieces[2] . "<BR>" . "<b>Posted by " . $pieces[1] . " on " . $pieces[0] . "</b><BR><BR>";
}
?>
This is working code it displays everything but the subject, i have tryed to get it to display my subject before the actual news text. I think that it should have been added to $pieces[3] but i tryed to add it but it doesnt work.
Any ideas why?
92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|