answersLogoWhite

0

Here is a simple script that you can do to run a MySQL query after you have set a database up.

<?php

// Database Settings

$db['hostname'] = "localhost";

$db['username'] = "<db username>";

$db['password'] = "<db password>";

$db['database'] = "<db name>";

// Connect to MySQL

$connect = mysql_connect($db['hostname'], $db['username'], $db['password']);

// Select Database

mysql_select_db($db['database'], $connect);

// Do MySQL Query

mysql_query("INSERT INTO table_name SET field_name = '1234567890'");

// Close MySQL

mysql_close($connect);

?>

Obviously you will need to use your own MySQL settings and database details, but this gives you a general overview of how you can do it.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

What is an insert query in PHP and MySQL?

In a database table, the INSERT INTO statement is used to insert new rows. Let's create a SQL query with acceptable values using the INSERT INTO statement, and then run it by passing it to the PHP mysqli query() function to insert data into the table. To learn more about data science please visit- Learnbay.co


Why you need wamp server to run php file on web browser?

PHP Web Development and Running PHP application requires a lots of efforts and tools. For running PHP file on web browser we required a compiler which can convert php files to HTML files. And a web server like Wamp helps a php file to convert it to PHP. Basic Component of WAMP Server are : Wnodows : Which is our OS. Apache : Web server for responding with web pages. MySql : Databases Query and PHP


How do you run a MySQL query involving many fields in PHP?

A mysql query can be run with the mysql_query(); function. Unfortunately, php allows you to run a maximum of one query each time. A possibility is to write all your queries to an array();, and then have them applied in a foreach(); loop.


Can you run PHP and MySQL on Linux?

Yes.


How do you run php file?

Either you could download latest version of php, mysql &amp; apache server or better you just need to install xampp. Versions of it are available for all OS


Can you open php file in your PC?

Since a PHP file basically is a text file, yes. But beware - opening and running a PHP file are not the same. If you want to run a PHP file, you will need a webserver with PHP module enabled.


How to solve what if your php installation appears to be missing the mysql extension which is required by wordpress?

Ideal thing to do would be to delete all your installation &amp; install a single WAMP/LAMP server. It combines all the features necessary to run php including windows/linux, apache, mysql &amp; php


How do you run sql on terminal in linux os?

mysql -u user -p -e 'SQL Query' database


Is PHP runable in Linux?

PHP can run on any major operating system just like java as long as you have an interpreter. Try installing a LAMP (Linux, Apache, MySQL, PHP) server &amp; you should be able to run php on your pc/server. There are some IDE's which would allow php development on linux os


How do you run a PHP file?

you need to be running a lamp / wamp server on your machine... point the browser to the file and it wll run. you can also use command line to run php scrips when you have lamp/wamp installed


What happen if you close mysql connection before query?

If you close a MySQL connection before executing a query, any attempt to run the query will result in an error. The connection must be open for the database client to communicate with the MySQL server and process requests. Closing the connection prematurely means that resources associated with that connection are released, making it impossible to execute any further queries until a new connection is established.


How run php program in wanp server in window?

Once you install wamp server. Any file with php extenstion like xyz.php you put in www folder will be executed as PHP file.

Trending Questions
How physical address is generated? What do you do if a DVD-CD-RW will read CDs but not DVDs? When a partition is formatted with a file system and assigned a drive letter it is called a volume true or false? You are trying to integrate Excel 2007 files with SharePoint 2003 through ODBC connection but you are getting the error that This document contains no visible tables Kindly help you to reslove this is? If a photo has a logo on the bottom does that mean it's copyrighted? How can TCP handle urgent data? Is a KB higher than MB? What line of longitude is west of the prime meridian and halfway between the prime meridian and the 180 degree line of longitude? What is the best matlab version for an engineer? What abilities does the NTFS write permission grant? What are the advantages of malicious software? How do you convert ppt to IEEE format? Describe your personal qualities that suit the requirements of this position as a data encoder? When recording data on a multiple-disk storage system should we fill a complete disk surface before starting on another surface or should we first fill an entire cylinder before starting on another cy? What default port provides connections to computers over a TCP IP network? What is a gallery in Microsoft office? Where is the on and off internet on the computer? Should data kept in the cloud be treated the same way legally as items that are kept in one's home? What answer of if operating system denied access to the specific files? Which general staff position of the incident command system manages costs related to the incident and provides accounting procurement time recording and cost analyzes?