• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

A Test Page For PHP Immidiately

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
ncwhiz
Asked:
ncwhiz
  • 6
  • 3
  • 3
  • +2
1 Solution
 
mrjoeCommented:
Try the php.net tutorial for a start.

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

Greetz
0
 
mrjoeCommented:
0
 
ncwhizAuthor Commented:
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
lozlozCommented:
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
 
ncwhizAuthor Commented:
so like this ...
<?php
include (connect.php)
?>

Like that?
0
 
lozlozCommented:
<?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
 
ncwhizAuthor Commented:
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
 
lozlozCommented:
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
 
ncwhizAuthor Commented:
Ahhh!! Cool, this is cool! I'm getting it!! Cha-Ching!! Thanks a ton!... I'll post back for more ques.
0
 
ncwhizAuthor Commented:
One more comment, HOW CAN YOU MAKE SURE that you have a working connection?
0
 
lamdorCommented:
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
 
kohashiCommented:
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
 
kohashiCommented:
http://directory.google.com/Top/Computers/Programming/Languages/PHP/Tutorials/

A list of PHP tutorials :)

hope that also helps,
-kohashi
0
 
ncwhizAuthor Commented:
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
 
mrjoeCommented:
Thanks, good thinking about starting some new questions, and good luck with php!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now