Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8551113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:07:21+00:00 2026-06-11T14:07:21+00:00

I am new for PHP5 OOP concept. Please give some example source code for

  • 0

I am new for PHP5 OOP concept.
Please give some example source code for “How to insert data using oops concept?”.I want to use pure php5 concept for this even in the connection.php page also.
I want to improve my knowledge. please any one help me….

I know below the basic concept

insert_db.php

                $sql="INSERT INTO Persons (FirstName, LastName, Age)
            VALUES
            ('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";

            if (!mysql_query($sql,$con))
              {
              die('Error: ' . mysql_error());
              }
            echo "1 record added";

            mysql_close($con)

connectio.php

          <?php
            // connect database  code
             $dbhost ='localhost';
            $dbuser = 'tomking';
            $dbpass = 'dsfds';
            $dbname = 'mydb';
            //connectivity of database
            $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error Connecting to mysql');
            mysql_select_db($dbname);
          ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:07:22+00:00Added an answer on June 11, 2026 at 2:07 pm

    Use Mysqli or PDO for using sql queries instead of directly pass variables to query.

    This will cause sql injection when you directly pass variable to query

    If you want to pass variable to sql query , you have to use filters for this

    filtering-escaping-post-data-from-injection-attacks

    PDO Documentation

    MySQLi Documentation

    And this is all pure PHP5 concept.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently started work on a new project using PHP5 and want to use
new on ruby and using windows xp and rails 3, i want to send
I have been trying to make OOP PHP5 code. But I think my attempts
I've written some object-orientated PHP5 code, but it won't parse and I'm not wholly
Hi I'm new to php mysql development. I'm using wamp server on windows. php5.3.4,
I'm using PHP5 to create XML files. I have code like this: $doc =
Very new to PHP5 and have some problems still. I figured out how to
I'm new to php and I have created a simple site using php5. my
I'm trying to replicate some C# code in PHP5 and am having some difficulties.
New to Regex. I want to validate to this format: Any character allowed, except

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.