We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
  • Pages:
  • 1
PHP N00b questions
Topic Started: Apr 25 2005, 10:16 PM (832 Views)
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Ok I am trying to learn PHP, I am getting the PHP/MySql Bible Wednesday, but until then ready to put up with n00b questions?

Questions:
1) Can you use html and PHP together?
Crappy EX: <a href=" ... more html
<script="Php" ... php coding

2) Do you have to install MySql software to run it, or if your host supports it do you just use it?

3) What is the extension for MySql?

4) Is there a good site with really really I'll say it again really easy tutorials for really basic things?

EDIT: Forgot to close a tag.
Offline Profile Quote Post Goto Top
 
Sani
Member Avatar
Member
[ *  *  *  *  * ]
1. You can intersperse php within html by using
Code:
 
<?php your php code here ?>


2. If your host supports MySQL, and most good (paid) hosts do, you can just use it. No need for any software to install.

3. MySQL is a database, hence it doesnt have an extension.

4. Probably http://codewalkers.com , http://www.hudzilla.org/php

:)
Offline Profile Quote Post Goto Top
 
FearKiller
Member Avatar
www.drewscripts.com
[ *  *  *  *  * ]
1. You can jump in and out of PHP anytime you want within a document.
Example:
Code:
 
<php

$a = 1;

if ($a == 1)
{
?>
<span class="red">The variable A is equal to 1</span>
<?php
}

else
{
?>
<span class="blue">The variable A does not equal 1</span>
<?php
}
?>

and <script="Php"> is not a PHP start tag.

2. You don't have to install MySQL to run PHP at all. Although if you want your PHP scripts to work with databases, then MySQL would be your best choice.

3. .sql I guess... not sure about that though, but MySQL is just a database language. The coding in the .sql file, assuming that is the right extension, would contain the querys to create the database and would only need to be ran once.

4. http://www.php.net
http://www.hudzilla.org/phpbook/
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Thanks, new questions

1) If Mysql is a filesystem how do you use it? Is it incorparated in your php file
2) Do you need any html tags to jump, or can you do
Quote:
 
<?php
echo "Bla";
?>
<a href="...">S</a>
Offline Profile Quote Post Goto Top
 
Sani
Member Avatar
Member
[ *  *  *  *  * ]
1. You can use MySQL by first connecting to the database,
Code:
 
$conn = mysql_connect("db_host","db_username","db_password") or die(mysql_error());
mysql_select_db("db_dbname", $conn) or die(mysql_error());

Then, to get the info..
Code:
 
$query = mysql_query("SELECT data FROM table");
while ($fetch = mysql_fetch_array($query)){ echo "".$fetch['data'].""; }


Ugly, I know.. :P

2. You dont need any html tags to use PHP, although the page has to have an extension of .php..
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Sani
April 25, 2005 06:55 PM
1. You can use MySQL by first connecting to the database,
Code:
 
$conn = mysql_connect("db_host","db_username","db_password") or die(mysql_error());
mysql_select_db("db_dbname", $conn) or die(mysql_error());

Then, to get the info..
Code:
 
$query = mysql_query("SELECT data FROM table");
while ($fetch = mysql_fetch_array($query)){ echo "".$fetch['data'].""; }


Ugly, I know.. :P

Can you give me an example that I can through in a word document, save it, and have it do something basic? I learn by people giving me the infromation and then I edit it seeing what happens.
Offline Profile Quote Post Goto Top
 
Sani
Member Avatar
Member
[ *  *  *  *  * ]
Hmm.. Okay..
1) Save this file as run.php, making sure to change
Code:
 
<?php
//change $db_host,$db_user,$db_pass to reflect your hosts MySQL info.
$conn = mysql_connect($db_host,$db_user,$db_pass) or die(mysql_error());
//change $db_database to reflect the database info.
mysql_select_db($db_database, $conn) or die(mysql_error());


echo 'Inserting Tables and Populating Them...<br />';
mysql_query("DROP TABLE IF EXISTS sd_banned;");
mysql_query("
CREATE TABLE sd_banned (
 id float NOT NULL auto_increment,
 ip varchar(255) NOT NULL default '',
 KEY id (id)
) TYPE=MyISAM;") or die(mysql_error());
mysql_query("INSERT INTO sd_banned VALUES ('', '$s');") or die(mysql_error());
echo "Data Insertion Complete!"; ?>


2) Save this as ban.php
Code:
 

<?php
$s=$_SERVER["REMOTE_ADDR"];
//draws IP address of visitor
$ip=mysql_query("SELECT * from sd_banned where ip='$s'");
while($check=mysql_fetch_array($ip))
   {
$IPBANNED=$check[ip];
   }
//above lines check to see if user Ip is in banned IPs
if ($IPBANNED)
   {
die("You have been banned");
   }?>


Its a simple banning script, set to ban your IP.. :P to remove the ban, save this file as killban.php
Code:
 

<?php
$s=$_SERVER["REMOTE_ADDR"];
mysql_query("DELETE FROM sd_banned WHERE ip='$s'") or die(mysql_error());
?>

And run it.. Hopefully it would show you how to insert and delete data from the database.. :)
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
Don't run before you walk. Don't even try MySQL until you can pass POST data around, store data in variables, things like that.
Offline Profile Quote Post Goto Top
 
dbzlotrfan
Member
[ *  *  *  *  *  *  * ]
Das Ein
April 25, 2005 10:00 PM
Quote:
 
Can you give me an example that I can through in a word document, save it, and have it do something basic? I learn by people giving me the infromation and then I edit it seeing what happens.

if you want a good thing to make PHP I use Crimson editor and it's very handy. It color codes the statements, functions, and classess, like 'function build_trees" is red, If statements are blue, etc. also besides that there's a number of other good features:
tells the number line (weather line 1 or 234534)
what char your on like (char 4 or 27454)
you can format the color of the text (I think)
you can color the background the color you want.
Edit multiple documents
- switch between documents using file selection tab.
- Ctrl+Tab brings the last accessed document to topmost.
- support window splitter to see different parts of a document.

Syntax highlighting
- configurable via custom syntax files.
- preconfigured for more than 100 computer languages.

Multi-level undo / redo
- all editing actions are recorded from the opening of a file.
- any document always can be undone to it's initial contents.
- unlimited undo and redo buffers.

Project management
- manage group of related files into one project.
- remote files also can be included in a project.

Directory tree view window
- click to open documents.
- filter to display only selected file class.

Find & Replace
- replace specified text one by one, or as a whole.
- support regular expression.

Column mode editing
- copy and paste rectangular selections.
- switch between column mode and line mode. (Alt+C)

Natural word wrapping
- word wrapping does not affect syntax highlighting.
- configurable wrapping indentation. (easer to understand the syntax)

Spell checker
- around 100000 words were added in the dictionary.
- users can register new words in their own dictionary. (InstallDir/user.dic)

User tools and macros
- execute external programs with proper arguments.
- compile, execute and test your code.
- ease your fingers with key stroke recording. (record & replay)

Edit remote files directly using built-in FTP client
- open, edit, and save documents in remote FTP servers.
- save account information (encoded) for automatic logon.

Print & Print preview
- configurable page header and footer.
- print with line numbers.
- print with syntax highlighting. (used in color printer)
- true type font selection for printer.

Other useful features
support Unicode & UTF-8 encoding, drag & drop text editing,
single instance / multiple instances, ability to detect changed files,
bookmark & go to, highlight active line, highlight matching pairs,
multi-byte support with integrated IME (for eastern languages),
auto indent, wheel mouse support, copy & paste, line numbers,
configurable line spacing, option to save files in Unix format,


That's from the offical website (I think).
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Seth
April 25, 2005 07:24 PM
Don't run before you walk. Don't even try MySQL until you can pass POST data around, store data in variables, things like that.

Where do you suggest I go to learn this infromation? I thought Mysql was part of PHP so it didn't matter when you learnt it.
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Sorry for the double post, but I found http://www.w3schools.com/php/ which is very helpful. So far I can make long load times, check it out http://dastest.madpage.com/loop.php

EDIT: I can tell you if you're older or younger, or the same age as me http://dastest.madpage.com/forumsw007.html
Offline Profile Quote Post Goto Top
 
Sani
Member Avatar
Member
[ *  *  *  *  * ]
Quote:
 
j00 older than me


??

Glad you got it to work.. :P
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Quote:
 
<?php
$name = $_POST["UserName"]
setcookie("UserName", $name, time()+36000);
?>

<html>
<body>

<p>
Loading...
</p>
<a href="http://dastest.madpage.com/loggedin.php">Procede</a>
</body>
</html>


What is wrong with that?
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
What error do you get?

Not sure about cookies so couldn't tell you if that code is right, but the
Quote:
 
$name = $_POST["UserName"]
should be
Quote:
 
$name = $_POST["UserName"];

(I know its stupid, always forget them myself :unsure: )
Offline Profile Quote Post Goto Top
 
Gornakle
Member
[ *  *  *  *  * ]
Just an FYI: <script language="php">...</script> are valid start/closing tags (check out the manual for a complete list).
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Technology Chat · Next Topic »
Add Reply
  • Pages:
  • 1