Go Premium for a chance to win a PS4. Enter to Win







PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi Experts,

I had this question after viewing How Do I "Install the Google Client Library".

I guess I closed the above too early, but after downloading from https://github.com/google/google-api-php-client by clicking Clone or Download, then Extracting the .zip, I noticed that all files and folders don't get downloaded (I tried twice),  such as examples/, styles/, tests/, and most files under the root directory when compared to the following screenshot of what is actually downloaded.

GitHub Download
Why aren't all files and folders getting downloaded?

Secondly, and most importantly, after extracting the download into my project director, and running the following code,

<!DOCTYPE html>

require_once 'google-api/src/Google/autoload.php';

define('APPLICATION_NAME', 'Google Calendar API PHP Quickstart');
define('CREDENTIALS_PATH', '~/.credentials/calendar-php-quickstart.json');
define('CLIENT_SECRET_PATH', __DIR__ . '/client_secret.json');
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/calendar-php-quickstart.json
define('SCOPES', implode(' ', array(

if (php_sapi_name() != 'cli') {
  throw new Exception('This application must be run on the command line.');

 * Returns an authorized API client.
 * @return Google_Client the authorized 

Open in new window

Independent Software Vendors: We Want Your Opinion
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

I am new to MVC and I have through some tutorials created a mini MVC framework using only php, no dependencies. The problem I have is that not all my pages are going to be just one word. A simple example would be 'contact-us'

I named my page in the views folder, 'contact_us.php' and I create this method in the controller:

public function contact_Us() {

 $data = [

     'title' => 'Contact us'


 $this->view('pages/contact_us', $data);

If I navigate to 'example.com/pages/contact_us' then it works I see the content I should. But I don't want it to be contact_us, I want it to be contact-us

I am not sure if this needs to be done in the existing .htaccess file or if it is done on the core.php file. If anyone wants to see more code please let me know. I just didn't want to post everything here and waste space unnecessarily.
I have email stored in mysql in a table in html code.

salutation : Mr
firstname : f-name
lastname : l-name
company : co name
position : 
address : 
address1 : 
town/city : 
county : 
country : uk
postcode : 
telephone : +44 1234567890
email : a@b.com
message : I had a very annoying chat with you.
support type : Technical
product : 
productserialnumber : 
date of purchase : 
where purchase : 
where found : 
main application : 
adwordsdata : 

Open in new window

I am trying to parse the html code and bring back the values of each, and then populate a table in our CRM.

I am not a php developer or coder,  My php skills are basic, but here is my attempt.  At current it just fills the name with values.
//Connection Credentials
class email_utils
	function create_lead( &$bean, $event )
	//Database Connection Info
	$servername = "server";
	$username = "user";
	$password = "pass";
	$dbname = "db";
	$description_html = $bean->emailDescriptionHTML;
	$conn = new mysqli($servername, $username, $password, $dbname);
	$sql = "SELECT description_html FROM emails_text WHERE email_id= TRIM(BOTH FROM '" . $bean->id . "')";
	$result = $conn->query($sql);
		$row = $result->fetch_assoc();
		$file1 = str_replace('correct email address','',$row["description_html"]);
		$file2 = str_replace('The following','',$file1);
		$file3 = str_replace('salutation, address, address1, postcode, town/city, county, country, telephone, message, support type','',$file2);
		$file4 = str_replace('<br 

Open in new window

Hello Experts,
Good Day!

I am using gethostbyaddr() method to get client machine's host name.

echo gethostbyaddr($_SERVER['REMOTE_ADDR']);

The above code returns IP address only not the host name.

Ex: gethostbyaddr(;
*Return Value* :

Expected Result : The Host Name. Like "HOS-S000051"

What may be the causes for this issue?

Please Suggest.

Thank You

The danish language have three special characters, Æ, Ø, Å - æ, ø, å
These characters are also written as Æ = AE, Ø=OE, Å=AA, æ=ae, ø=oe, å=aa

For example is the name of one city in Denmark be spelled like this: Aalborg and like this: Ålborg.

My question is if ii is possible to create a SQL search in a way that when searching for Ålborg it will return Ålborg as well as Aalborg.

In this searchstring it returns nothing when searching Aalborg because in the database only the spelling Ålborg is used.
      $query = $mysqli->prepare("SELECT * FROM ft WHERE Aar = ? AND AmtHerredSognGade LIKE '%".$sogn."%'");
    $query->bind_param("s", $start);

Open in new window

Hi Experts

Could you point what is the major differences and what must be concerned when changing PHP use from Windows to Linux (Debian f.e.) ?

Thanks in advance!
I followed the steps here https://hub.docker.com/r/nanoserver/mysql/  to install mySQL and PHP, however, I need the ability to access the MySQL instance via port 3306 via MySQL WorkBench..  To do this I would imagine I need to allow remote access via the mysql command ...  But.. when I type 'mysql -u root -p' via the folder that mysql is running in (connected to session via Enter-PSSession <type-here-containerID> -RunAsAdministrator it just hangs and nothing happens.  Any ideas?
I had this question after viewing given xml, please extract a portion of xml line in output one per line.

Thanks. I have a related question where xml is externalFile.xml and has xml start tags
I have a pagination that load more when I click on the load more button, which I got from the below URL http://makitweb.com/load-more-results-with-jqueryajax-and-php/

Whenever I add RAND() it always duplicates the value.



$rowperpage = 10;

$allcount_query = "SELECT count(*) as allcount FROM users order by id";
$allcount_result = mysql_query($allcount_query);
$allcount_fetch = mysql_fetch_array($allcount_result);
 $allcount = $allcount_fetch['allcount'];

$query = "select * from users order by RAND(" . date("Ymd") . ") asc limit 0,$rowperpage ";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){

<div><h1><?php echo $row['id']; ?></div>


<h1 class="load-more">Load More</h1>
<input type="hidden" id="row" value="0">
<input type="hidden" id="all" value="<?php echo $allcount; ?>">

Open in new window


$row = $_POST['row'];
$rowperpage = 10;

$query = 'SELECT * FROM users ORDER BY id limit '.$row.','.$rowperpage;
$result = mysql_query($query);

$html = '';
while($row = mysql_fetch_array($result)){

$html .= '<div><h1>'.$id.'</h1></div>';


Open in new window

hello, here's what i'd like to do:

go to my web page viewer.html
select the dropdown list and choose a video file.
the video then plays on my page viewer.html

a few times a month i FTP videos up to my directory which is www.mysite.com/storage/videos/

my page looks like this so far. please note i'm a complete novice.  i'm hoping someone can finish this off for me. thanks

<h1>hello world</h1>
<p>this is the text</p>


var elm=document.getElementById('txtfiletoread');
  var a=this.value.split('\\'); 
  a=a[a.length - 1];

var myVideo=document.getElementById("video1"); 
var videoList=['part_1.mp4','part_2.mp4','part_3.mp4','part_A.mp3','movie_bbb.ogg'];
var index = videoList.indexOf(window.currentVideoName);
//Next button
function nextButton(){
index = index + 1;
index = 0;
myVideo.src = 'C:/'+videoList[index];
function playPause()

<div style="text-align:center"> 
  <button onclick="playPause()">Play/Pause</button> 
  <button onclick="nextButton()">Next</button>
  <video id="video1" width="420">
    <source src="C:/sample.mp4" type="video/mp4">
    <source  type="video/mp3">
    <source type="video/ogg">
    Your browser does not support HTML5 video.



Open in new window

my hosting package is apache/php

thank you
Free Tool: ZipGrep
LVL 11
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Hi All,
I am building an API in PHP which will take an email address and then turn it into a hash and then store that in a database.

However, the email address is called by other peoples servers using an API. Whats the best way too securely transfer the email address?

Sufficient to have the api use SSL?

and a relation table shown in picture


can i get mutual friend ?

i have
Following Query =
 "SELECT `user_id` FROM " . T_USERS . " WHERE `user_id` IN (SELECT `following_id` FROM " . T_FOLLOWERS . " WHERE `follower_id` = {$user_id} AND `following_id` <> {$user_id} AND `active` = '1') AND `active` = '1' ";

Open in new window

Follower Query =
" SELECT `user_id` FROM " . T_USERS . " WHERE `user_id` IN (SELECT `follower_id` FROM " . T_FOLLOWERS . " WHERE `follower_id` <> {$user_id} AND `following_id` = {$user_id} AND `active` = '1') AND `active` = '1'";

Open in new window

perfectly working

I have data in three columns in the database that represents three levels.
Column 'Amt' is the top level
Column 'Herred' is the middle level
Column 'Sogn' it the bottom level

I have made this page: http://kroweb.dk/gfdev/dropdown/ where I have the three levels represented in three select boxes.

What I need is this:
The 'Amt' box should reflect a dropdown box with the content of the column 'Amt' in the database
The 'Herred' box should reflect a dropdown box with the content of the column 'Herred' within the chosen 'Amt'
The 'Sogn' box should reflect a dropdown box with the content of the column 'Sogn' within the chosen 'Amt' and 'Herred'.

I have this HTML (commented where I believe something more is needed :) :
                    <!-- Søge felter -->
        <div class="container" style="width:100%;padding-top:10px;background-color:#f6f6f6;">

            <!-- HEADER START -->
            <div class="row" id="header">
                <form method="POST" style="margin-left:30px;"> 

                        <select id="amt" name="amt">
                        <option value=""></option>
                        <option value="Content of column 'Amt'">Content of column 'Amt'</option> <!-- something else needed -->

                        <select id="herred" name="herred">

Open in new window

I'm interested in creating a Joomla extension for sending out user account activation emails. I need to know about the activation token.

The activation token appears to be hex code. The token generated when I registered my test account was 1c99b9e50f765fe8e25e2d6f8d328e78

Where does this code come from? Is it saved anywhere to the database, and/or is it created based upon info submitted by the user - or something else?

I need to know this so that I can generate it myself.

Thanks for any help!

my Sql

Following Query = "SELECT `user_id` FROM " . T_USERS . " WHERE `user_id` IN (SELECT `following_id` FROM " . T_FOLLOWERS . " WHERE `follower_id` = {$user_id} AND `following_id` <> {$user_id} AND `active` = '1') AND `active` = '1' ";

Follower Query = " SELECT `user_id` FROM " . T_USERS . " WHERE `user_id` IN (SELECT `follower_id` FROM " . T_FOLLOWERS . " WHERE `follower_id` <> {$user_id} AND `following_id` = {$user_id} AND `active` = '1') AND `active` = '1'";

But i can not get Mutual Friends
I am used to using procedural php and jQuery/ajax. Here is a simple example of how I would usually use them together.

Let's say I have a page that just has an input field.

<input type="text" name="name" id="name">

Open in new window

Then to keep it simple, I have some jQuery at the bottom of the page:

// code here to trigger the ajax call on button click/form submit etc.
		var form = $( "#loginForm" ).serialize();	
				url: 'functions/some-file.php',
				type: 'POST',
				dataType: 'json',
				data: form,
				beforeSend: function() {
					$( "#login" ).hide();
					$( ".spinner" ).html("<img src='img/spinner.gif'>");
                     // .done and .fail go here

Open in new window

The some-file.php file would look something like:


if($_POST) {

	$response = array();
	$message = "";

if(empty($_POST['name'])) {
		$message .= "Name required";

if($message) {
		$response['success'] = false;
		$response['message'] = $message;
	} else {

                // add data to database
                $response['success'] = true;
		$response['message'] = "Success";
	echo json_encode($response);

Open in new window

This works fine. I have a basic MVC framework that I built from scratch using only php based on a course I did (no templating engines or anything, just plain php) and don't know how to do the above in MVC.

At this point I have the view and the controller. I am not onto the model yet. At this point I have a form with email and password fields and I am just trying to do the validation. Here I am just checking if the email field is empty or not to keep it simple.

In my controller I just have:

public function login() {
		if($_POST) {
			$data = [
				'email' => trim($_POST['email']),
				'email_err' => '' 
			if(empty($_POST['email'])) {
				$data['email_err'] = 'Email required';
			if(empty($data['email_err'])) {
				//call login model

			} else {
				$this->view('users/login', $data);
		} else {
			$data = [
				'email' => '',
				'email_err' => ''
			$this->view('users/login', $data);

Open in new window

And my view:

<form action="<?php echo URLROOT;?>/users/login" method="post">
	<input class="form-email" type="email" placeholder="Email Address" name="email" autocomplete="off">
	<input class="form-password" type="password" placeholder="Password" name="password">
	<input class="login-btn btn-filled" id="login" type="submit" value="Login">
	<div class="spinner"></div>
	<input type="hidden" name="form_token" id="form_token" value="<?php //echo make_form_token(); ?>">
	<input type="text" name="some-field" style="display:none;">
<div class="alert alert-danger">

Open in new window

So, the question is, how on earth do I make the ajax call using the controller and send the data to the model?
Hello Experts,

We have a web system running from a Windows 2012 R2 server.  The server has 128GB RAM and 2 x 16 core xeon processors.

I am a network administrator but my in depth knowledge of fine configuration of IIS is limited.

We use PHP 5.6 and have about 300 customers logging into the system and updating records.  At least once a week, the website goes down and is only brought back online after a command prompt 'iisreset' action is performed.  The developers are currently testing the system with PHP 7.1 before we switch over from 5.6.  The errors in the Event Viewer do not correspond to the website crash

My question is, are there more settings i need to change in IIS to make the website run better, application pool failover, etc

Any guidance is appreciated

Kind Regards

Hello Julian,

The php script that you gave me earlier was working perfectly till yesterday morning. But suddenly, The form is not being submitted and I am getting the following error after submitting the form. I asked my hosting provider and he said that they have not made any changes or up gradation. This is the error:

Could not execute: /usr/sbin/sendmail -t -i

Could you please tell me what could be the problem.

I have an API consisting of two files that takes a url from a user, processed it, and sends an array to another file to return XML data back to the user. My problem is that I do not know how to get the return data (if I were the user) and parse it. Using a browser, the XML will display fine. I am hoping there are PHP functions that will send the url and retrieve the result for parsing.
Here is an example of the url sent by the user:

Open in new window

Those query vars are then processed, sent to another server, and an array of results is returned. I then create a query string from those results place that string into another query and send that to another file that returns the XML.
The query string looks like this:
XMLProcess.php?Q=Element1^Value|Element2^Value|ElementThree^Value ... etc.

Open in new window

That file looks like this
   $dom = new DOMDocument("1.0", 'utf-8');
   header ("Content-Type:text/xml");
   $QArray = explode('|',$_REQUEST[Q]);
   foreach($QArray as $value)
      $x = explode('^',$value);
      $XMLItems[$x[0]] = $x[1];
   $root = $dom->createElement("Requests");
   foreach($XMLItems as $key => $value)
         $key = $dom->createElement($key);
         $variable = $dom->createTextNode($value);
   echo $dom->saveXML();

Open in new window

As I say, this will display well-formatted xml in a browser, but is there a way to receive and parse this xml data with PHP?
Am I creating extra problems by having a secondary processing file (XMLProcess.php), rather than just including this XML creation code in the xmlapi.php file?

I'm trying to avoid using something like CURL or SOAP, if possible.
Free Tool: Port Scanner
LVL 11
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

I had this question after viewing Populate PDF with Data from MySql Database Using Php.

I need to find a solution where you're able to use a PDF form to input data (into the PDF form) and write it directly to a MYSQL DB. It may sound simple but I'm not able to find a solution out there. The closest is something like HelloSign but that's overkill for our simple requirement.
I have my php files on an IIS 8 server.
I put a session_start on the top of the page.

My code was working fine. I moved it to a new folder. It worked for 5 minutes, and then I got this error:

Warning: session_start(): open(C:\Windows\temp\sess_69voc1ru64hq9ipmqm8llpdqn4, O_RDWR) failed: Invalid argument (22) in \\19******de.php on line 3
Warning: Unknown: open(C:\Windows\temp\sess_69voc1ru64hq9ipmqm8llpdqn4, O_RDWR) failed: Invalid argument (22) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\Windows\temp) in Unknown on line 0

Open in new window

I set up a new folder, tried it there and it worked, and then 5 minutes later it started erroring again.

what can I do to make it work?
i want to convert opencart tpl files into twig file.
any one give me better solution
I have xampp downloaded, but I still can't view any of the php files on dreamweaver.  I configured it so it would run, but still having no luck.  Any suggestions?? Thanks
I have a standard HTML form with a jQuery onclick function which does several processes, depending on the submit. All functions are working fine, but the simplest section of this jQuery code just does a normal submit. However, this form data on this submit goes to a PDF creation file and needs to be URLencoded. I cannot figure out how to do this without listing every field in a very long form. I've searched the Web but not found an answer. Seems there should be a simple way to url encode this submit. Here is the current submit function:
    $(document).on('click', '.ClickCheck', function(e)
        var Form = $('#TheForm');
        $(Form).attr('action', './PDFResultPage.php');

Open in new window

Hello experts,
I have the following situation,

I have a pc windows10 and I have a Macbook pro

I have installed Google drive on the pc and installed wamp and synced 2 folders in the www folder of wamp located in C:

As I'm taking my laptop from a room to another I installed Google drive on this laptop but the folder i chose to sync from pc couldn't be downloaded into my laptop

I'm not sure how to setup this properly as mamp path is different and wamp path is also a different location and my google drive is only showing files not folders...

any idea?






PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.