answersLogoWhite

0

PHP Programming

Questions about the PHP programming language; How and when to use it, implementing techniques, debugging and handling errors, and general questions about PHP itself. For questions about software made with PHP, that do not deal with the manipulating, reading, or learning about the actual code, see the Computer Software category.

845 Questions

Can I Access RSS Feed of any blog site using PHP script?

Using content fetchers such as cURL or the file_get_contents function, you can fetch and retrieve the contents of the RSS feed. Then you can parse the data using XML parsers to generate usable data that can be processed by your script.

In short, it is possible to access any published RSS feed using PHP.

What is the difference between a numericial array and an associative array?

A numericial array is an array with keys made up of only integers. An associative array is an array with keys made up of anything that is not an integer. In some languages, it is possible to mix integer keys and non-integer keys into a mixed array.

What causes the critical error on Windows 10?

Windows 10 does not cause a critical error. In PHP, any syntax, mathematical, or system error can cause an error to occur.

How do you convert an Excel database to a Mysql database?

1. For every sheet you have in Excel, create a matching table in MySQL database

2. Export excel data to a CSV file

3. Load the CSV files into MySQL database using one of the following:

3.1 mysqlimport - Loads tables from text files in various formats

3.2 LOAD DATA INFILE command

3.3 Create the tables with CSV storage engine, replace the CSV file in the database directory

How do you create an online order processing system using PHP and MySQL?

There are several steps to creating an online order processing system.

First, you need to determine what exactly you want the system to do. I'm guessing that you want to be able to input products and send the order to a credit card processor.

In order to do this, you'll need to create a database. Inside that database, you will need to create one table that lists products and prices, another for user authentication, and a third to list individual orders and the customers who placed them.

After the database is organized, create the PHP code that interfaces between the user's browser and the back-end database. I would highly recommend reading PHP.net's MySQL function list, available as a Related Link below this text.

Finally, you will need to create code that will interface with your credit card processor. This could be as simple as a custom PayPal link, or could involve interfacing directly with a credit card acceptor.

What php command to be used to redirect visitotors to customized thank you page after submitting the form?

You should write this line of code before any text is sent to the browser. Remember, even the HTML tag counts. So you can type:

<?php

if (isset($_POST['submit']))

header("location:http://www.mywebsite.com/thankyou.php");

?>

Remember that if statements and other PHP statements that don't actually send output would work, but any output sent to the browser won't. Be careful of that!

How do you retrieve an entire MySQL table using PHP?

Hi,

For example if you want to get data from a table called employee

<?php

$con = mysql_connect("localhost","root","");

if(!$con) die('Could not connect: ' . mysql_error());

else

{

$select_db=mysql_select_db("for_testing",$con);

if(!$select_db){

echo 'No such database';

die;

}

$result=mysql_query('Select * from employee',$con);

$row = mysql_fetch_array($result,$con)

echo $row['name'];

}

?>

What server can use PHP and Oracle?

Oracle is a database server and is independent from the web server. This means that any server capable of running natively or through CGI/FastCGI php can also use Oracle.

What are the advantages and disadvantages of PHP with mysql?

Ultimately PHP is a programming language and MySQL is a database language. Using PHP with MySQL is a nice combination with built-in support and the simplicity of it all. However, there aren't a lot of disadvantages of using PHP with a database, it just allows for better data organization and whatnot.

There are definitely advantages and disadvantages to using a database other than MySQL (such as MongoDB or PostgreSQL).

How do you retrieve data stored in the database into the dropdown using PHP?

<select name="select1">

<option value="">Please Select...</option>

<?php

$fetchQuery = mysql_query("SELECT * FROM `table`");

while($showOutput = mysql_fetch_object($fetchQuery)){

echo "<option value="{$showOutput->value1}">{$showOutput->value2}</option>";

}

?>

</select>

Using the while function is very useful. If you wish to limit the amount of outputted lines, use LIMIT 10 at the end of the mysql query.

Lewis.

How many PHP-based websites are there?

Nearly all websites have some sort of PHP backend, although a large number use other scripts as well -- Perl, Python, ASP, CGI.

How do you persist data in PHP forms specially drop down box?

When getting any Information in PHP from a form use $_POST (unless your method is GET in which case $_GET)

This is how you do it (I'm using ( and ) instead of < and >)


(?php


$my_drop_down = $_POST['drop_down_name']; #Then $my_drop_down equals what ever's in value= eg My Value 1, My Value 2,My Value 3
?)


(select name="drop_down_name")
(option value="My Value 1" selected)My Option 1(/option)
(option value="My Value 2")My Option 2(/option)
(option value="My Value 3")My Option 3(/option)
(/select)


(I've also added a few php help links)

How do you select data associated with a logged in user from your sql davabase using php?

Assuming you have the same table for the user-details and login. Also that you have got the login part working

<?php

// connection string statement

// select database statement

// check if user is present in db

$user = 'user_name'; // put the value of username obtained from login

$select = mysql_query("SELECT * FROM table_name WHERE user='$user'");

// if statement will check for single user before showing data

if(($fetch = mysql_fetch_array($select))&&($select>0)&&($select<2))

{

// only print the columns you want to show

echo $fetch['col_1']; // where col_1 is the name of column

echo $fetch['col_2'];

}

?>

What is the best open source PHP MySQL user management system?

There are many different user management systems available, many of which come bundled as part of other content management systems I'd suggest looking into something like Wordpress or Joomla to see how it can all work for you. Or check out a tutorial like http://www.roughguidetophp.com/creating-a-simple-comments-and-login-system-using-mysql-and-php/ to see how you can build something like that yourself

What new features are in PHP 5.5?

A full list can be found in the php docs.

Biggest new features are generators and the finallykeyword.

Difference between apache and PHP?

Apache is a web server. PHP is a scripting language.

Difference between mysql fetch row and mysql fetch array in PHP?

Both return a row in a MySQL database and in most applications can be used interchangeably. The difference is that mysql_fetch_array has an extra argument called $result_type that allows the returned array to be associative (string keys) or numeric (the keys are 0..n). A mysql_fetch_array call with the numeric parameter is equivalent to mysql_fetch_row.

How can you increase the execution time of php script?

You can use the set_time_limit function to increase the execution time of a php script. Example: set_time_limit(120); // Sets the time limit to 2 minutes

What is use the source code in php language?

Your Question is difficult to make out But I think your asking "What is the source code in php language?" ... right?

If so then Let me first explain how PHP works. PHP is server side scripting wich means all the the source code resides on the server and is never reviled to the user. Most of the time the PHP scirpt will tell the user somthing but the user can never see the original context of the php script its self.

A very simply scipt in php looks like this:

<?php echo 'Hello World!'; ?>

This will show a page that simply says:

Hello World!

and nothing else. Below is a very simple secure script that requires a username and password to view the page:

[PHP Code Start]

<!--

Script Written by Wayne Hartmann

Email: drhart4000@gmail.com

Feel free to use and modify this script.

-->

<?php

if(isset($_POST['pass']))

{

$user = 'User'; //Username to access script

$pass = '5f4dcc3b5aa765d61d8327deb882cf99'; // Password to access script (Use an MD5 hash to keep your password secret:

// http://www.adamek.biz/md5-generator.php can be used to generate an MD5 hash.

if (strtolower(addslashes($_POST['user'])) <> strtolower($user)) { die('Error invalid Username or Password.<BR>')};

if (md5(addslashes($_POST['pass'])) <> $pass) {{ die('Error invalid Username or Password.<BR>')};

//Start protected content

?>

<!-- Your conent goes here! NOTE that this area is not php enabled

unless you delete the ?> tag above and < ?php tag below. -->

<?php

//End protected content

}else{

//Start Login Form

?>

<HTML>

<head>

</head>

<body>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="auth">

This script is Protected. Please authenticate to continue.&lt;?php<BR>

<table width="460" border="0">

<tr>

<td width="77" height="24">Username:</td>

<td width="373"><input type="text" name="user" id="user2"></td>

</tr>

<tr>

<td>Password:</td>

<td><input type="password" name="pass" id="pass"></td>

</tr>

<tr>

<td>&nbsp;</td>

<td>

<input type="submit" name="button" id="button" value="Run Script">

</td>

</tr>

</table>

</form>

</body>

</HTML>

<?php

//End Login form

}; ?>

[PHP Code END]

Why is using a MySQL database more efficient than hard coding in PHP?

The Most Important Advantages of Using PHP and MySQL in Web Development 

 1. Maintenance is simple and quick.

  1. Superior performance, scalability, and dependability.

  2. Compatible with IIS, Apache, and other operating systems.

  3. It operates on Linux, Windows, or Unix and is platform agnostic.

To learn more about data science please visit- Learnbay.co

How do you handle database in php?

Please refer link. The presentation gives complete understanding of how to deal with database (Mysql) with php.

Does android supports PHP?

It supports websites made on php but not coding in php. There are workarounds for coding in PHP using Android.

When foreign key is used?

A foreign key is when a value of one table, which is a primary key of another table.

Manufacturer_table

- id

- name

Models_table

- id

- manufacturer_id

- name

Models_table.manufacturer_id should be defined is a foreign key to the Manufacturer_table.id column