Solved

A Test Page For PHP Immidiately

Posted on 2003-10-27
15
167 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
ID: 9630951
Try the php.net tutorial for a start.

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

Greetz
0
 

Expert Comment

by:mrjoe
ID: 9630955
0
 
LVL 1

Author Comment

by:ncwhiz
ID: 9631438
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 13

Expert Comment

by:lozloz
ID: 9631555
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
ID: 9631568
so like this ...
<?php
include (connect.php)
?>

Like that?
0
 
LVL 13

Expert Comment

by:lozloz
ID: 9631587
<?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
ID: 9631600
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
 
LVL 13

Expert Comment

by:lozloz
ID: 9631612
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
ID: 9631620
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
ID: 9631630
One more comment, HOW CAN YOU MAKE SURE that you have a working connection?
0
 
LVL 1

Expert Comment

by:lamdor
ID: 9632351
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
ID: 9632353
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
ID: 9632402
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
ID: 9633436
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
ID: 9633503
Thanks, good thinking about starting some new questions, and good luck with php!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

776 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