PHP

118K

Solutions

32K

Contributors

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

I'm trying to upload file from the PHP script on my local machine to a remote machine using cURL. The remote machine is running CentOS and connection to it is on https port  443.
When I use the same script to upload to a server with http port 80, it's working perfectly. But HTTPS is the issue. Below is my script:

PHP Script
<?php
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, 'https://10.32.0.17/receiver.php');
        curl_setopt($curl, CURLOPT_TIMEOUT, 30);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_CAINFO, 'C:/wamp64/bin/php/php5.6.19/extras/ssl/cacert.pem');
        curl_setopt($curl, CURLOPT_POSTFIELDS, $uploadRequest);
        $response = curl_exec($curl);
        $error = curl_error($curl);
        curl_close($curl);
        echo $response;
        echo $error;
?>

Open in new window


php.ini  - This is the php.ini on my local machine
curl.cainfo = 'C:/wamp64/bin/php/php5.6.19/extras/ssl/cacert.pem'

Open in new window

openssl.cafile='C:/wamp64/bin/php/php5.6.19/extras/ssl/cacert.pem'

Open in new window


Please what could be the issue? Do I need to do anything on the remote server?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 4
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Can someone explain this code to me?

/*CALL Controllers CLASS IF EXIST*/

			if($row){ 

				$this->load->ClassValidation = false;

				$this->className = str_replace("-",'_',$row->slug);

				$this->load->controller( $this->className );

				if(method_exists( $this->load->{$this->className}, index ))

					$this->load->{$this->className}->index($data);

				else

					$this->load->view( $row->folder.'/'.$row->goto, $data ); //default

			}

			else

				$this->load->view( $row->goto ); //!$row- page not found

Open in new window


Thank you.
0
I have created a custom access right that connected a use->role->module->permission. Now there are certain attributes that I intend to retrieve from my database and use them across my angularjs+laravel application.

My front-end which is built using angularjs, I would like to call a function to retrieve the values in the following manner:

ifAccess('module','permission') //return true or false

The value should be stored as a global setting so that I do not have to make a call to the database off and on to obtain the values. I would only make a call to the database after login. How can I store and retrieve this values in the most secure manner.
0
I am trying to to provide basic information on an organization like : "Currently there are (variable) number of members".  I have no problems building tables or getting the queries to work in mysql.  I just can't transfer the variables into the php output.
0
I'm getting the error:
Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI

Not sure what this means or how to fix.  I have php 7.0 set on my cpanel settings.
0
The php artisan command was working fine.  

I just tried to create a new migration file and it failed with:
 [ErrorException]
  Invalid argument supplied for foreach()

Open in new window


Even if I run "php artisan list" it fails with the same error.  I don't know what I did.  How can I track down what is causing the issue?
0
Is there some trick to getting the translation working? "AS" in the query below fails...

Here is the Query:

SELECT c.FirstName AS first_name,
             c.LastName AS last_name,
             c.Company AS company_name,
             r.RepID AS rep_id,
             r.RepName AS rep_name,
             c.CustomerID AS om_customer_id
FROM Customers c
LEFT JOIN RepManufacturer r ON r.RepID = c.Integer5
WHERE (c.FirstName LIKE '%todd test%' OR c.LastName LIKE '%todd test%' OR c.FullName LIKE '%todd test%' OR c.Email LIKE '%todd test%' OR c.Phone LIKE '%todd test%' OR c.Company LIKE '%todd test%')

Which gives me this array result on our Unix Ubuntu web server.. so basically it just totally ignores the ‘AS’ and retains the orginal name

Array ( [0] => Array ( [FirstName] => Todd testing [LastName] => Sprind testing [Company] => OurCompany [RepID] => 658 [RepName] => Dan The Man [CustomerID] => 2171 ) [1] => Array ( [FirstName] => todd TEST [LastName] => sprind TEST [Company] => ourcompany.com [RepID] => [RepName] => [CustomerID] => 2172 ) [2] => Array ( [FirstName] => TEST Todd [LastName] => TEST Sprind [Company] => [RepID] => [RepName] => [CustomerID] => 2242 ) [3] => Array ( [FirstName] => test todd [LastName] => test spri [Company] => residential [RepID] => [RepName] => [CustomerID] => 2702 )
0
Hi,

I've been using the below code for sometime, all works well, except when there is an insert or edit query - I get a blank page.
It could be because it's trying to add/edit a field that may not exist in the database or an SQL error - but I do not get feedback on screen - the page usually just loads blank.  Should I be using different code, alter it, or something completely different?

$db_host = "ip";
$db_user = "admin";
$db_name = "database";
$db_pass = "pass";

$link = mysqli_connect($db_host, $db_user, $db_pass) or die(mysql_error());
mysqli_select_db($link,$db_name) or die(mysql_error());

Open in new window


QUERY
$sql = mysqli_query($link,"SELECT * FROM table") or die(mysql_error());
$row = mysqli_fetch_array($sql);
$total = mysqli_num_rows($sql);

Open in new window


INSERT
mysqli_query($link,"INSERT INTO table (test) VALUES ('1')");

Open in new window


UPDATE
$result = mysqli_query($link,"UPDATE table SET test='1',WHERE id = '1'") or die(mysql_error());

Open in new window


Or is it a PHP setting i need to turn on to properly show me the SQL error?

Thank you
0
I'm helping my friend to troubleshoot this.

Apparently his website is facing these errors:

Warning: include(application/views/themes/ecig/header.php): failed to open stream: No such file or directory in /home/cccccccccc/public_html/wwwwwwww.com/system/classes/loader.php on line 59

Warning: include(application/views/themes/ecig/header.php): failed to open stream: No such file or directory in /home/cccccccccc/public_html/wwwwwwww.com/system/classes/loader.php on line 59

Warning: include(): Failed opening 'application/views/themes/ecig/header.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cccccccccc/public_html/wwwwwwww.com/system/classes/loader.php on line 59

Warning: include(application/views/themes/ecig/notfound.php): failed to open stream: No such file or directory in /home/cccccccccc/public_html/wwwwwwww.com/system/classes/loader.php on line 60

Warning: include(application/views/themes/ecig/notfound.php): failed to open stream: No such file or directory in /home/cccccccccc/public_html/wwwwwwww.com/system/classes/loader.php on line 60

Warning: include(): Failed opening 'application/views/themes/ecig/notfound.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cccccccccc/public_html/wwwwwwww.com/system/classes/loader.php on line 60

Warning: include(application/views/themes/ecig/footer.php): failed to open stream: No such file or directory in 

Open in new window

0
By default you can get the list of post titles followed by the date of the post. As shown below. However as in the second list I would like a list but with breaks in the list to show when the month has changed. How is this possible.

Post 1 title
Post 1 date
Post 2 title
Post 2 date
Post 3 title
Post 3 date
Post 4 title
Post 4 date
Post 5 title
Post 5 date
Post 6 title
Post 6 date

What I want is :

July 2017
-
Post 1 title
Post 1 date
Post 2 title
Post 2 date
Post 3 title
Post 3 date

June 2017
-
Post 4 title
Post 4 date
Post 5 title
Post 5 date
Post 6 title
Post 6 date

Thanks
0
Technology Partners: We Want Your Opinion!
Technology Partners: 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!

This function along with the PHP is sending the email.  What it is not doing is hiding the form and saying "Thanks"...so it is only half working!

The Function
<script>
$(function() {
  $("#myform").on('submit', function(e) {
    e.preventDefault();
    $.ajax({
      url: 'send_mail.php',
      dataType: 'json',
      data: $("#myform").serialize()
    }).done(function(d) {
      if (d.success==true) {
        $("#myform").hide();
        $("#results").text("Thanks!").show();
      }
    });
  });
});
</script>>

Open in new window


The PHP
<?php

$webmaster_email = "ds@mediascrubber.com";
$email_address = $_REQUEST['email_address'] ;

function isInjected($str) {
	$injections = array('(\n+)',
	'(\r+)',
	'(\t+)',
	'(%0A+)',
	'(%0D+)',
	'(%08+)',
	'(%09+)'
	);
	$inject = join('|', $injections);
	$inject = '/$inject/i';
	if(preg_match($inject,$str)) {
		return true;
	}
	else {
		return false;
	}
}

if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
}

elseif ( isInjected($email_address) ) {
header( "Location: $error_page" );
}

else {
mail( "$webmaster_email", "Feedback Form Results", "From: $email_address" );
header('Content-Type: application/json');
echo json_encode($data);

}
?>

Open in new window

0
My var_dump on the array that gets passed is:
array(6) {
  ["_token"]=>
  string(40) "zQ2tv4UljUsdwd7MeA6aKQW1PMQBBEOhB1EDFrc5"
  ["airline"]=>
  array(3) {
    [0]=>
    string(1) "1"
    [1]=>
    string(1) "4"
    [2]=>
    string(1) "2"
  }
  ["flightNumber"]=>
  array(3) {
    [0]=>
    string(1) "1"
    [1]=>
    string(1) "4"
    [2]=>
    string(1) "6"
  }
  ["departing"]=>
  array(3) {
    [0]=>
    string(18) "07/24/2017 1:58 PM"
    [1]=>
    string(18) "07/29/2017 1:58 PM"
    [2]=>
    string(18) "07/26/2017 1:59 PM"
  }
  ["seatNumber"]=>
  array(3) {
    [0]=>
    string(1) "1"
    [1]=>
    string(1) "4"
    [2]=>
    string(2) "55"
  }
  ["tripID"]=>
  string(2) "22"
}

Open in new window


How would I loop these and still keep their association for inserting.  

For example all of the arrays with the "0" key are associated, same with "1", "2".
0
I have a text box on a php page residing on my apache web server which has the following:
"£300 plus other text lines"

The page is uft-8 encoded
The text "£300" is displayed correctly on my web server - ie the "£" sign comes across correctly
If I send the details of this text box via a php form, the "£300" comes out as "£300"

Can someone explain what is happening and how I can get rid of the £ and replace with £
0
I am using Javascript, HTML, Json and PHP.  The emails were sending but now they are not.  Any help is appreciated.  Thank you.

www.mediascrubber.com/videos.html


<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<script>
$(function() {
  $("#myform").on('submit', function(e) {
    e.preventDefault();
    $.ajax({
      url: '//jsbin.com/vufeyag.json',
      dataType: 'json',
      data: $("#myform").serialize()
    }).done(function(d) {
      if (d.success==true) {
        $("#myform").hide();
        $("#results").text("Thanks!").show();
      }
    });
  });
});
</script>>

Open in new window


<?php

$webmaster_email = "ds@mediascrubber.com";
$email_address = $_REQUEST['email_address'] ;

function isInjected($str) {
	$injections = array('(\n+)',
	'(\r+)',
	'(\t+)',
	'(%0A+)',
	'(%0D+)',
	'(%08+)',
	'(%09+)'
	);
	$inject = join('|', $injections);
	$inject = "/$inject/i";
	if(preg_match($inject,$str)) {
		return true;
	}
	else {
		return false;
	}
}


if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
}
elseif ( isInjected($email_address) ) {
header( "Location: $error_page" );
}
else {
mail( "$webmaster_email", "Subscruber",
 
   "From: $email_address" );
   

}
$jsonurl = "http://api.wipmania.com/json";
$json = file_get_contents($jsonurl);
var_dump(json_decode($json));
?>

Open in new window


<form id="myform" class="form-horizontal" action="send_mail.php" method="post">
				<div class="input-group">
                <input type="text" name="email_address" class="def-input" placeholder="Your Email Here">
                <span class="input-group-btn">
                <button class="btn-form btn" input type="submit">Subscribe</button>
                </span>
                
				</div>
                </form>
                <div id="results" style="display: none;"></div>

Open in new window

0
Hello

I'm busy on a project where i have read only access to an oracle database.
Got a running webserver (LAMP) with a running OCI8 connection.
I'm trying to get a select query result from the following:

TableA
ID
DOC_ID
Date
Type

TableB
ID
DOC_ID (references tableA)
FILE_NAME
FILE_ID
FILE_TYPE

TableB can contain more then one result for the same DOC_ID.

The goal is to get the data from TableA appended with the results from TableB where the DOC_ID is the same and get them into a JSON format.
Looking like

{
	"data": [{
		"ID": "123456",
		"DOC_ID": "789456",
		"Date": "2/1/2016",
		"Type": "PI",
		"FILE_NAME": [
			"File1.pdf", "File2.docx"
		],
		"FILE_TYPE": [
			"PDF", "DOCX"
		],
		"FILE_ID": [
			"453215", "654687"
		]
	}, {
		"ID": "544569",
		"DOC_ID": "001223",
		"Date": "2/8/2016",
		"Type": "PI",
		"FILE_NAME": [
			"File1.txt"
		],
		"FILE_TYPE": [
			"TXT"
		],
		"FILE_ID": [
			"453215"
		]
	}, {
		"ID": "2225599",
		"DOC_ID": "0148966",
		"Date": "2/1/2017",
		"Type": "PI",
		"FILE_NAME": [
			"File1.xml", "File2.xml", "File3.xml"
		],
		"FILE_TYPE": [
			"XML", "XML", "XML"
		],
		"FILE_ID": [
			"00147788", "00114455", "00113210"
		]
	}]
}

Open in new window


Any advise on how to best go about this is welcome.
0
Hi,
I am developing a small friend contact list for my personal website, wherein I want my friends to update their personal details, like address, city, phone number, email address etc. after login.
There are fields like address, city, phone No., email, which is editable and fields like Names are not editable.
Flow:
login.php-->mainpage.php [where all the fields are getting displayed in column-wise like:
      First Name:
      Last Name :
      Address     :
      City             :
      Phone        :
      Email         :

To edit or update the details, I create a link 'EDIT' Button and link it to a page 'edit_profile.php', where I want my friends to update their latest information. But, the code is not working - I am developing this myself with the help of Internet. May I request you to kindly look into this and correct, it would be a great learning experience for me.

[edit_profile.php] is attached below:
<?php
session_start();
$first_name = $_SESSION['first_name'];
$last_name  = $_SESSION['last_name'];
$Fri_Add1  = $_SESSION['Fri_Add1'];
$Fri_City  = $_SESSION['Fri_City'];
$Fri_Phone1  = $_SESSION['Fri_Phone1'];
$Fri_Email1  = $_SESSION['Fri_Email1'];


if(!isset($_SESSION['restrict'])){
header("Location: ../login.php");
}

include "database/friends.php";
$sqlInfo = mysql_query(" select * from `friends`");

if(isset($_POST['updateMessage'])){

include 'database/friends.php';
$updateMessage = trim($_POST['updateMessage']);
$first_name = …
0
i want to be able to hide the edit and the delete link for guest users for example.
i am using the &_section['login_user']; variable to manage users that login. i have succeeded in limiting access to some of the components on the page but don't know how to limit access to the edit and delete link.  thanks in advance for your help!!!

 <?php
while($row=mysqli_fetch_array($result)){
	?>
	<tr>
	<td><?=$row['name']?></td>
	<td><?=$row['fname']?></td>
	<td><?=$row['lname']?></td>
	<td><?=$row['address']?></td>
	<td><?=$row['phonenumber']?></td>
	<td><?=$row['sex']?></td>
	<td><?=$row['position']?></td>
	<td><a href="editstaff2.php?edite=<?php echo $row['staff_id']?>">edit</a>|<a href="ui-table-advanced3.php?delet=<?php echo $row['ngo_id']?>">delete</td>
	
	</tr>
	
	<?php
}
?>

Open in new window

0
Dear Experts,
I use php and mysql.
I have a mysql sentence which is working like this

SELECT uid, bayiadi, SUM(toplamtutar) as toplamtutar FROM siparis WHERE toplamtutar > 10000  and bayidentahsilati is Null group by uid

Open in new window


but I need to control whether the SUM of toplamtutar is bigger than 10000 not the toplamtutar itself
I wrote it like below but it gives me error. What do I do wrong?

SELECT uid, bayiadi, SUM( toplamtutar ) AS toplamtutarim
FROM siparis
WHERE bayidentahsilati IS NULL and  SUM( toplamtutar ) > 10000
GROUP BY uid

Open in new window

0
Hi experts, i want to change PHP to POWERBUILDER, any help please!
below the php script :

========encrypt===============
function mc_encrypt($data, $key)
{
/// make binary representasion of $key
$key = hex2bin($key);

/// check key length, must be 256 bit or 32 bytes
if (mb_strlen($key, "8bit") !== 32) {
throw new Exception("Needs a 256-bit key!"); }

// create initialization vector
$iv_size = openssl_cipher_iv_length("aes-256-cbc");
$iv = openssl_random_pseudo_bytes($iv_size);

/// encrypt
$encrypted = openssl_encrypt($data, "aes-256-cbc", $key, OPENSSL_RAW_DATA, $iv );

/// create signature, against padding oracle attacks
$signature = mb_substr(hash_hmac("sha256", $encrypted,  $key,   true),0,10,"8bit");

/// combine all, encode, and format
$encoded = chunk_split(base64_encode($signature.$iv.$encrypted));

return $encoded;
}

========decrypt===============
function mc_decrypt($str, $key)
{

/// make binary representation of $key
$key = hex2bin($key);

/// check key length, must be 256 bit or 32 bytes if (mb_strlen($key, "8bit") !== 32) {
throw new Exception("Needs a 256-bit key!"); }

/// calculate iv size
$iv_size = openssl_cipher_iv_length("aes-256-cbc");

/// breakdown parts
$decoded = base64_decode($str);
$signature = mb_substr($decoded,0,10,"8bit");
$iv = mb_substr($decoded,10,$iv_size,"8bit");
$encrypted = mb_substr($decoded,$iv_size+10,NULL,"8bit");

/// check signature, against padding oracle attack
0
Salesforce Made Easy to Use
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

I am using this code.  Whenever an email is sent another page pops up (thank_you.html) saying thank you.  I don't want that.  I simply want the input field that previously said "Your Email Here" to now say.  "Thank You".    How can I do this?

www.mediascrubber.com/videos.html

Its at the very bottom of the page.  Subscribe.

I assume I would do an echo "Thank You" of some sort.  But where?

<form class="form-horizontal" action="send_mail.php" method="post">
				<div class="input-group">
                <input type="text" name="email_address" class="def-input" placeholder="Your Email Here">
                <span class="input-group-btn">
                <button class="btn-form btn" input type="submit">Subscribe</button>
                </span>
                <!--input type="submit" value="Submit" /-->
				</div>
                </form>

Open in new window


<?php
/*
This first bit sets the email address that you want the form to be submitted to.
You will need to change this value to a valid email address that you can access.
*/
$webmaster_email = "ds@mediascrubber.com";

/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
//$feedback_page = "feedback_form.html";
//$error_page = "error_message.html";
$thankyou_page = "thank_you.html";

/*
This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.
*/
$email_address = 

Open in new window

0
Hello,

I have been trying without success, I need expert help, please!

$title = "Apple iPhone 3 plus – Cell phones"

I want to modify this string inserting the word "Reviews " before "-" character and REMOVE all after "-". Result should be:

$title = "Apple iPhone 3 plus Reviews"
0
What is the cause of this error fsockopen failed No route to host (113) while publishing a template to my domain? I tried using another third party template provider and i received an FTP passive Mode error. What is the cause and what is the solution. Please help.
0
This site was created a very long time ago and a second install was done in a sub-directory named memlog. It has the permalink structure of just /%postname%/.
The root install uses the permalink structure of /%year%/%monthnum%/%postname%/

We want to import the posts from the memlog install but would like a way to get the existing search engine links to those to redirect to the permalink structure of the root install without having to add 1150 redirects in the htaccess.

What I've done so far is imported the memlog posts into a dev area and added a parent category of memlog then moved all categories to use that as their parent in the hopes of trying to get a way to target "memlog" for the redirect to the root's structure. Once there's a way to get that main category and all it's subs to redirect to the date structure then I can import from the dev into the root site.

Any help would be very much appreciated.
0
i created one html5 form which is connected to phpmyadmin .The form is opening in other PC's with the help of my IP address.But why my form is not opening in other places when i'm using with ip adderss???
0
Basically i want to store and be able to download word, excel pdf et.. file in mysql database. i have succeeded in storing the files but the download aspect is giving me hell. i wrote the script to down the files, but every time the downloaded files gets damage or corrupt. This is the error when i attempt to open the downloaded microsoft office document: we are sorry we can not open the file because we found problem with it content. this file is corrupt and can not be open.


please help, i have been on this for days.

this is my downlo.php file

if(isset($_GET["dow"])){
      ob_start();
      $path = $_GET['dow'];
      $mysqli = new mysqli("localhost","root","","extenderaid");
if($mysqli-> connect_error)
      die("database connection fail".$mysql->connect_error);

$qry = mysqli_query( $mysqli,"select doc from document where doc= '$path'");
header('Connection: Keep-Alive');
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($path).'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
ob_clean();
readfile($path);

}




this is my upload file
include('section.php');
  
 $fload_error='';
  $discription_error='';
$discr='';
$submis_error='';
$submis='';
$ngo_error='';
$success='';
$target_file 

Open in new window

0

PHP

118K

Solutions

32K

Contributors

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.