Solved

A Test Page For PHP Immidiately

Posted on 2003-10-27
15
164 Views
Last Modified: 2006-11-17
Here's the situation, I have a server (which I shall leave named x) which has phpMyAdmin on it. I need help getting a test page from one of you or on the Internet that has some basic PHP functions that I can use, like making a new table in a database, and pulling that information. I need this page because I'm a beginner and need a page like this that can help me learn some of the working characteristics of this language. I also am looking for a GOOD guide on PHP, have NOT found ANY yet. What can you do for me?

Nicolae Crisan,
crisann@mxtech.net
MxTechnical Computer Soltuions,
www.mxtech.net
0
Comment
Question by:ncwhiz
  • 6
  • 3
  • 3
  • +2
15 Comments
 

Accepted Solution

by:
mrjoe earned 85 total points
Comment Utility
Try the php.net tutorial for a start.

http://www.php.net/manual/en/tutorial.php

Greetz
0
 

Expert Comment

by:mrjoe
Comment Utility
0
 
LVL 1

Author Comment

by:ncwhiz
Comment Utility
great stuff! Answered many questions! BUT one thing, when connecting to a database, where do you put the code for connecting to that database? Do you put it in a separte file, or just with your html? example "connect.php"? What i do? Here's an example of code they site gave me.

$username="username";
$password="password";
$database="your_database";

Such and such...

I have some code, but what do I do now? stick it into my php file example (index.php) or do i have to put it into a seperate file and then pull that file first and do a redirect? What's the score here? How do I do this, so i can be able to enter information into my database as quickly as possible.

Thanks For All The Previous Help,
NcWhiz
0
 
LVL 13

Expert Comment

by:lozloz
Comment Utility
you can do all in the connecting in a seperate file then include the file on each php page by using the include function, e.g. include("connect.php");

my usually looks something like this:

<?
$db_user = "user";
$db_pass = "pass";
$db = "db";
$host = "localhost";
$link = mysql_connect($host,$db_user,$db_pass) or die("Database connection broken");
mysql_select_db($db,$link) or die("Database connection unavailable - " . mysql_error());
?>

you can put all your php code into index.php and it will be parsed by the engine and converted into html for the user to see. inserting data based on user inputs will need some forms which can then be parsed by php and and inserted into mysql
0
 
LVL 1

Author Comment

by:ncwhiz
Comment Utility
so like this ...
<?php
include (connect.php)
?>

Like that?
0
 
LVL 13

Expert Comment

by:lozloz
Comment Utility
<?php
include("connect.php");
?>

you need the semi colon and the quotes, and the file needs to be in the same directory as the script you're running, if not you need the change string in the include function to have the path info as well. useful tip: if you want to read up about a function go to www.php.net/functionname where functionname is the function you want more info about.. so www.php.net/include for this one
0
 
LVL 1

Author Comment

by:ncwhiz
Comment Utility
and one more thought, where's the close (); part on this code? shouldn't that be there in there somewhere? I don't want to kill my hosts server!
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 13

Expert Comment

by:lozloz
Comment Utility
the function is called mysql_close();

quoting from the manual:

Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution. See also freeing resources.

i never use it
0
 
LVL 1

Author Comment

by:ncwhiz
Comment Utility
Ahhh!! Cool, this is cool! I'm getting it!! Cha-Ching!! Thanks a ton!... I'll post back for more ques.
0
 
LVL 1

Author Comment

by:ncwhiz
Comment Utility
One more comment, HOW CAN YOU MAKE SURE that you have a working connection?
0
 
LVL 1

Expert Comment

by:lamdor
Comment Utility
Hey ncwhiz,

 What was your question (A Test Page For PHP Immidiately?)
and where you have lead it? (One more comment, HOW CAN YOU MAKE SURE that you have a working connection?)..

 see its not fair..

 ask more questions..don't lead one question into multiple..
 I think if u open new question then you will get good answers..

okay..

with regards
lamdor.
0
 
LVL 7

Expert Comment

by:kohashi
Comment Utility
from lozloz:

?
$db_user = "user";
$db_pass = "pass";
$db = "db";
$host = "localhost";
$link = mysql_connect($host,$db_user,$db_pass) or die("Database connection broken"); *RIGHT HERE TELLS YOU THAT YOU HAVE A WORKING CONNECTION OR DO NOT.  "or die" tells it to quit, it will show an error.*
mysql_select_db($db,$link) or die("Database connection unavailable - " . mysql_error());
?>

hope that helps,
-kohashi
0
 
LVL 7

Expert Comment

by:kohashi
Comment Utility
http://directory.google.com/Top/Computers/Programming/Languages/PHP/Tutorials/

A list of PHP tutorials :)

hope that also helps,
-kohashi
0
 
LVL 1

Author Comment

by:ncwhiz
Comment Utility
Okay, I gave the points to marjoe, because this user had the best answer to this question, however, lolz helped me the most in the detials, So I'll start some new questions, so Lolz can get some points as well. Sorry about that.
0
 

Expert Comment

by:mrjoe
Comment Utility
Thanks, good thinking about starting some new questions, and good luck with php!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now