Results 1 to 10 of 10

Thread: php input.

  1. #1
    Join Date
    May 2006

    Arrow php input.

    Ok. I am a php noobie. I have good knowledge of html but i know i need some php for this. Any help is very appreciated. thanks

    ok i want a page that has a simple form on it. There are two form inputs "Name" and "Picture Location." Upon the user pressing submit i am guessing that this information must be put into a database? I then need the code that will retrieve information from the database. I want the "Name" and "Picture Location" to be retrieved and put into this format. (hyperlink with frame target and name)

    <A HREF="Picture Location retrieved from database eg. www.bob.com/pic.bmp" TARGET="C">Name retrieved from database</a><br>
    it wants to go into a page like this hopefully where the hyperlinks target url and text to display will be collected from the database. This is the code left hand panel on a page with 3 frames.

    <TITLE>Fa1.uK^ Pictures </TITLE>
    <b><u>Welcome to Pictures Page</u></b><br>
    <b>Clan Pictures</b><br>
    <A HREF="http://www.forwardasone.clanservers.com/images/1.JPG" TARGET="C">13th Match</a><br>
    <A HREF="http://www.forwardasone.clanservers.com/images/2.JPG" TARGET="C">13th Match</a><br>
    <A HREF="http://www.forwardasone.clanservers.com/images/3.JPG" TARGET="C">13th Match</a><br>
    <b>Members Pictures</b><br>
    Coming Soon......
    the actual page is http://www.forwardasone.clanservers....ures/home.html

    email :> mathew.tew@gmail.com

    Last edited by cH3wY; 05-21-2006 at 10:52 AM.

  2. #2
    Join Date
    Apr 2006
    Silicon Valley
    Okay, to do that you need to know how to first desgin a database, second how to connect to it with PHP, and third how to read and write data to it with PHP.

    Let's start with simply designing the database. You're going to want a table of images with a field of name (varchar 255) and location (varchar 255) and id (int 11 unsigned auto_increment) which is a fairly simple design.

    You then can connect to the database with mysql_pconnect() in php, and mysql_select_db(). If you can get that far, we can talk you through querying the database to add and display records.

  3. #3
    Join Date
    May 2006
    ok thanks i will have a play with that and then PM you thanks


  4. #4
    Join Date
    May 2006
    ok right i have been playing with the code and reading tutorials to try and understand stuff and i have come up with this code.

    i have used the "//" to make notes. I dont think that the timestamp is correct when i am creating a table

    //head and title
    <title>PHP Pictures Test Page</title>
    //creating and checking database 
    if ( $connid = mysql_connect ( 'localhost' 'username' 'password' ) )
      {  print '<p> Connection Established. </p>';
          if ( @mysql_query ( 'CREATE DATABASE Pictures' ) )
            {  print '<p> Database Created. Yey! <p>';
                if ( @mysql_select_db ( 'Pictures' ) )
                  { print '<p> Databse selected. Yey again! </p>';
                  {  die ( ' <p> Falied to Select... :'( ' , mysql_error ( ) , ' </p>' )
            {  die ( ' <p> Couldnt Create noooooo........ ' , mysql_error ( ) , ' </p>' )
      {  die ( ' <p> Connection failed ' , mysql_error ( ) , ' </p>' )
    //creating table
        contact_id   INT   IDENTITY (1, 1)   NOT NULL , 
        Picture Name   VARCHAR   (10)   NOT NULL ,          //field name Picture Name its a CHAR with 10 charactors top and cant be left empty right?
        URL   VARCHAR   (60)   NOT NULL ,                      //field name URL its a CHAR with 60 charactors top and cant be left empty right?
        UserName VARCHAR   (10)   NOT NULL                 //field name Picture Name its a CHAR with 10 charactors top and cant be left empty right?
        Date and Time DATETIME   (0)   NOT NULL     //Date and Time is field name and i want it too be automatic TIMESTAMP
    if this right i am going to crack open some beer cause i am proud of that my first database

    I dont understand what i should put in( $connid = mysql_connect ( 'localhost' 'username' 'password' ) ) should it be database name or IP? user name and password confuses me as it is defined by my previous question but if its database name then what do i set these as because i havnt password protected the database i have created in this code. I assume this is why when uploaded i get this error... www.forwardasone.clanservers.com/phpdata.php

    email :> mathew.tew@gmail.com

    Last edited by cH3wY; 05-21-2006 at 10:52 AM.

  5. #5
    Join Date
    Apr 2006
    Silicon Valley
    Don't try to create your database/tables with PHP yourself. Instead, use a tool like phpmyadmin to do it graphically.

  6. #6
    Join Date
    May 2006
    ok then. I have made the database and tables i want using Access. how do i call for them now?

  7. #7
    Join Date
    Apr 2006
    Silicon Valley
    Assuming it's a MySQL database, you need to use mysql_pconnect(server, username, password); then mysql_select_db(database_name); to establish a connection from PHP. Then you can execute a series of queries to read and write data.

    To write data to the database, do something like mysql_query("INSERT INTO table_name SET column1='something', column2='something else'"); and to alter existing rows use something like mysql_query("UPDATE table_name SET column1='something', column2='something else' WHERE id='some id'");

    To read data from the database, store the results of a query in a variable. If you want to pull one specific row, do something like $results = mysql_query("SELECT * FROM some_table WHERE id='some id' LIMIT 1"); then $row = mysql_fetch_object($results); In order to access your data, do something like echo $row->column1; or echo $row->column2; etc.

    To read data when you're expecting multiple results from a query, do something like $results = mysql_query("SELECT * FROM some_table ORDER BY something"); then you place your rows through a loop such as:

    while ($row = mysql_fetch_object($results)) {
    echo $row->column1; etc
    Last edited by Kethinov; 05-22-2006 at 05:24 PM.

  8. #8
    Join Date
    Aug 2004
    Quote Originally Posted by Kethinov
    Assuming it's a MySQL database, you need to use mysql_pconnect(server, username, password); ...
    Use mysql_connect() instead of mysql_pconnect() unless you understand the difference and know that you need to use mysql_pconnect() for your script. (And the odds are that you do not.)

    Also, it might be a good time to study this fairly short tutorial on using MySQL with PHP: http://www.zend.com/php/beginners/php101-8.php
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  9. #9
    Join Date
    Aug 2005
    The Garden State
    from the guide, these are the differences.

    Quote Originally Posted by php.net
    First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.

    Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect()).
    So basically, any connections that come in are typically pooled into one connection. So you'd have to design a checking system to determine that the response is actually yours otherwise you have to throw it out.

    Since connections aren't too costly, this shouldn't be a big deal.
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

  10. #10
    Join Date
    May 2006
    thanks alot guys. I will read the tutorial now thanks NoDog. I will post back later if i have any problems.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.43910 seconds
  • Memory Usage 2,946KB
  • Queries Executed 13 (?)
More Information
Template Usage (34):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (3)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (10)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates