We help IT Professionals succeed at work.

PHP

121K

Solutions

33K

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.

Experts,
My recent task was to stand up a PHP Server with MySQL for a Word Press Site.  Interesting as I have never done it before.
I followed instructions and was able to get MySQL installed with a username and password that worked.
I was able to install PHP 7.4.1 and can get to phpinfo.php.

I was trying to add the SQLSRV extension. (and also pdo_sqlsrv).

I am unable to find out how to run commands like get-extensions.  I found the powershell.

Server 2008 running IIS7.
Extension directory is c:\php

any help appreaciated.  I am waiting for the developer to wake up in mountain time.

Thanks
bob
0
Good morning all !
I hope you are well !

I am trying to integrate a push notification system on my site but I cannot find any tutorial to guide me.
You know, the system that displays an alert on the computer...
notif.png
Thank you for your help and take care of yourself
0
Hi Experts

From a PHP Script, after certain conditions are met, how can I re-direct the user to a page on the main window from an iFrame?

For example, page1.php has an iFrame to page2.php. From page2.php how can I redirect the user to page3.php, but not in the iFrame, but instead of page 1.php

I amt trying the following, but not working.
if ($result['status'] == 'ERR'){
            $js_error = $result['msg'];
            require_once $supp_directory . 'view_supp-details.php';
        } else {
            header('Window-target: _top');
            header('Location: http://www.iwscc.ca/self-registration_thanks/');
   
        }
        

Open in new window

I have also tried _parent
0
Hi there, I am trying to code a gated content page on our site. Hiding a video.
On Page load, a popup modal form will appear asking for your email address.
-- If you enter email and click submit, you will be directed to /video-gate-test/?access=yes and the popup will not appear again.
-- If you close the modal, then you can view the page, but not allowed to play the video.

what i have done, is added an image to the /video-gate-test/ page (.img-overlay) and hid the video (.embed-container). Clicking that then it will make the popup appear again.

What i want to happen is, if the form is submitted and directed to /video-gate-test/?access=yes then, hide .img-overlay and show .embed-container

I created 2 functions
jQuery(document).ready(function($) {
	if (window.location.href.indexOf('/video-gate-test/?access=yes')) {
		//Hide the element.
		jQuery('.embed-container').show();
		jQuery('.overlay-img').hide();
		
	  }
	});


jQuery(document).ready(function($) {
	if (window.location.href.indexOf('/video-gate-test/')) {
		//Hide the element.
		jQuery('.overlay-img').show();
		jQuery('.embed-container').hide();
	  }
	});

Open in new window


if on /video-gate-test/ it correctly hides the video, and shows the overlay. but it also does the same on /video-gate-test/?access=yes'

Can you guys help with my function,  
if url = /video-gate-test/  | show .overlay-img , hide .embed-container
If url = /video-gate-test/?access=yes  show | .embed-container , hide .overlay-img
0
I obtained the Authorize.net php script sample code for processing a direct bank account debit transaction (sometimes called an eCheck). I put in some real values and ran it. It works great. The EXACT code, except for the Bank Routing Number which I replaced for security purposes, is attached as debit_bank_account.php.

When run with the real routing number, it produces this:

Transaction Response code : 1 Debit Bank Account APPROVED : Debit Bank Account AUTH CODE : Debit Bank Account TRANS ID : 62290257462 Code : 1 Description : This transaction has been approved.

In the real world, there is a form for the customer to fill out. I adapted the sample to accommodate the process flow of the real world application, that code is attached as process_debit_payment.php.

It produced a blank screen, so I put in the echos. Running with the echos produces this:

entered process_debit_payment
start of real work
amount = 1
got to before transaction

Note that the last echo does not show, implying to me that something went wrong in the $controller->execute line.

The only think I can think of is that because of the context of the working version being all the work is in a php function & the "real life" version is not, that somehow makes it invalid.

I can put the "real" version as a function & pass the $_POST values as arguments.

Any suggestions appreciated.

Thank you
debit_bank_acct.php
process_debit_payment.php
0
IIS 10 has been installed and I am able to print 'Hello World' with helloworld.htm.
I have PHP 7.1.6 downloaded and zip files are extracted.
How is the best way to begin installing the code ?
Start from the beginning and make it simple !

Michael
0
Here's my code:

@component('mail::message')

<strong>{{ $data['name'] }}</strong> has requested information about the <strong>{{ $data['event_name'] }}</strong> happening on <strong>{{ $data['event_date'] }}</strong> in <strong>{{ $data['event_location'] }}</strong>.
<br><br>
Here's their data:
<br>
<strong>name:</strong> {{ $data['name'] }}<br>
<strong>email:</strong> {{ $data['email'] }}<br>
<strong>address:</strong> {{ $data['address_1'] }}<br>
<strong>city, state zip:</strong> {{ $data['city'] }}, {{ $data['state'] }} {{ $data['postal_code'] }}</strong><br>
<strong>country:</strong> {{ $data['country'] }}<br>
<strong>occupation:</strong> {{ $data['occupation'] }}<br>
<strong>phone:</strong> {{ $data['phone'] }}<br>

@endcomponent

Open in new window


...and here's the resulting email as it appears in my inbox:

screenshot
I want to include a header as well as some other HTML features like a graphics, a header and footer etc. I also want to get rid of what appears to be the default header and footer.

How?
0
I have the Windows 10 OS which has IIS 7.5 Express installed.
How can I determine if the PHP Manager has been installed ?
I am legally blind, so make your instruction simple and clear.

Michael
0
Hi Experts,

I am trying to write a generic update function, which is below, but I am getting the following error.

PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:\inetpub\wwwroot\iwscc.ca\selfregistration.iwscc.ca\utilities\database.php:98

Open in new window


my function is as follows, which is pretty simple.
    public static function update_table($table, $id_key, $id_value, $source, $exclusions = array()){
        
        $query = "UPDATE '$table' SET ";
        $key_found = FALSE;
        
        foreach ($source as $key => $value) {
            
            $key_found = FALSE;
            foreach ($exclusions as $key_exclude):
                
                if ($key == $key_exclude) $key_found = TRUE;
                
            endforeach;
            
            if (!$key_found){
                $query .= " $key = :$key,\n";
            }
            
            
        }
        
        $query = trim_last_char($query) . "\n";
        
        $query .= " WHERE $id_key = :$id_key ";
        
        print_variable($query);
        //die();
        
        $db = self::getDB();
        
        $statement = $db->prepare($query);        
          
        $statement->bindValue(':$id_key', $id_value);
        
        foreach ($source as $key => &$value) {
            
            $key_found = FALSE;
            foreach ($exclusions as $key_exclude):
      

Open in new window

0
I want to add the ability to a customer web site to accept direct bank account payments; currently, we accept credit cards.

We use Authorize.net. All server side programming in php.

I found the attached code from Authorize.net, I think I see how it functions, but it's terribly over simplistic & obviously depends upon being encased in some
environment, for example, these lines at the top:

require 'vendor/autoload.php';
  require_once 'constants/SampleCodeConstants.php';
  use net\authorize\api\contract\v1 as AnetAPI;
  use net\authorize\api\controller as AnetController;

Does someone have Authorize.net experience & can help me link to the necessary includes, etc?

Thank you.
0
Here's the way my event is looking:

event
When I enter this info into the database, I'm using TinyMCE with the HTML characters going into the database as regular text.

How can I get my <a href...etc. to display as a link and not as text?
0
Here it is:

screenshot of email form
...and here's the code:

@extends('layouts.satellite')
@section('content')

<!-- Section: intro -->
<section id="intro" class="intro">
	<div class="satellite-content">
		<div class="container">
			<div class="row">
				<div class="col-xs-12 satellite_row">
					<h5>NOMAS<sup>&reg;</sup> International Events</h5>
					To request more info about the <b>{{ $event_stuff->name }}</b>, that's happening on {{ \Carbon\Carbon::parse($event_stuff->start_date)->format('m/d/Y')}}, fill out the form below.
					<br><br>
				<form method="Post" action="{{ route('adminStorePage') }}">
					<div class="form-group">
						<input type="hidden" value="{{csrf_token()}}" name="_token">
						<div class="row">
							<div class="col-xs-12">
								<label for="name">Name</label>
								<input type="text" class="form-control" name="name" id="name" value="{{ old('name') }}">
							</div>
						</div>
						<div class="row">
							<div class="col-xs-12">
								<label for="name">email</label>
								<input type="text" class="form-control" email="email" id="email" value="{{ old('email') }}">
							</div>
						</div>
						<div class="row">
							<div class="col-xs-12">
								<label for="name">Occupation</label>
								<input type="text" class="form-control" occupation="occupation" id="occupation" value="{{ old('occupation') }}">
							</div>
						</div>
						<div class="row">
							<div class="col-xs-12" style="text-align:center;"><input 

Open in new window

0
Hi Experts

Could you clear what this Laravel code does?

  public function index(){
  
  
    $trimestres = Trimestre::all();
    
//----------  
    $trimestres->map(function($value, $index){
        $lastMonth = $value->mesestrimestres->last();
        $lastMonthDate = Carbon::createFromDate($lastMonth->ano, $lastMonth->mes, 1);
        $value->showTrimestre = $lastMonthDate->lte(Carbon::now());
    });
//-------------    

  return view('admin.trimestres.index', compact('trimestres'));
}

Open in new window


The tables used are:
img001

I have to convert this code to this new structure:
img002

Could you suggest what must to be done?

Thanks in advance!
0
Good day Experts,

Need help with turn server and web rpc.. we are getting "ICE failed, add a TURN server and see about:webrtc for more details" and we trying to get our video chat application to work properly.  At moment it only works if i am on the same ISP with a user..if users are on different isps..the voice and video does not work.  We are running tests using this kink https://www.teledoctor.co.zm/livesmart/client.html

When it works we are on same service provider, but voice video stops on different..we are not experts on this and need help to get work across service providers for our application.  Is there a site where one can test a TURN/STUN server setup?

Kind regards
0
First time posting. I have a dropdown with select options listed A through Z...

<select style="width:375px; text-align: left" id="alpha" onchange="fetch_select(this.value);">
<option value="" disabled selected>First Letter</option>
<option value="#">"0-9"</option>
<option value="A">"A"</option>
<option value="B">"B"</option>

<select id="operator" name='operator'>
			<option value="0">- Select Operator -</option>
		</select>
<select id="wnames">
	   <option value="0">- Select Well Name -</option>
	</select>

Open in new window


I also have two dependent dropdowns  that will return their values after the selection of the letter. Onchange of "apha", I need the value to pass to php via ajax, execute two sql queries simultaneously (not cascading), and return the data in json in the two dropdowns, "operator" and "wnames". I don't know how to execute the two sql statements with the one ajax variable and return the two sets of rows.       
Here is my ajax:
//Ajax to fetch operators once alpha chosen
		 function fetch_select(val){
        //var alpha = $(this).val();

        $.ajax({
			type: 'post',
            url: 'alphaScript53.php',
			dataType: 'json',
            data: {op_option:val},
            success:function(response){

                var op_len = response.length;

                $("#operator").empty();
                for( var i = 0; i<op_len; i++){
                    //var id = response[i]['Rig_ID'];
                    var op_name = response[i]['Operator'];
     

Open in new window

0
How do I add a "sign-up" form for my website? I would want a form for the user to fill-in, then the information goes to a database, I suppose. THEN a Thank You notice. I believe this has to be done in javascript.
0
I have set the $type variable at the beginning of PHP code but it doesn't restore correct in my php. Any idea ?

  <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="Student" "($type=='Student')?'checked':''">


echo
<<<HTML
<form method="POST" action="{$_SERVER['PHP_SELF']}">
<div class="container">
<br/>
<b>Please fill in the following details:</b>
<br/><br/>
Ticket Type: <br/>
<div class="form-check form-check-inline">
  <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="Regular" ($type=='Regular')?'checked':''>
  <label class="form-check-label" for="inlineRadio1">Regular</label>
</div>
<div class="form-check form-check-inline">
  <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="Student" "($type=='Student')?'checked':''">
  <label class="form-check-label" for="inlineRadio2">Student</label>
</div>
<div class="form-check form-check-inline">
  <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="Retire" "($type=='Retire')?'checked':''">
  <label class="form-check-label" for="inlineRadio3">Retire</label>
</div>
<br/><br/>
<input class="form-control col-lg-6" type="int " id="id" name="id" placeholder="Student ID" value="$id" required="" ><br/>

<input class="form-control col-lg-6" type="text" placeholder="First Name" name="fname" value="$fname" required="" ><br/>

<input …
0
Hi,

This is related to https://www.experts-exchange.com/questions/29173852/phpmailer-mailbox-unavailable.html

I’m testing sending out automated emails from http://selfregistration.iwscc.ca/email_test/index.php but not all are going through. For example, when I send to aleks@iwscc.ca I get “..mailbox unavailable or not local…”.

Please ignore “email sent” in this instance, because I quickly wrote the script without any error testing. However, it is sending to the following

aleks@aces-project.com (hosted by Microsoft, also mailbox is not local, but working)

apdcompany@gmail.ca (hosted by Google, not local and working)

One thing that I found strange when receiving the credentials for aleks@iwscc.ca as user is that said that if I want to encrypt emails, I need to purchase SSL. I know usually the SSL is for the server side, not client side. I am thinking that maybe that the iwscc.ca is some type of a budget server, but I cannot see how this relates to my script, which is at another server, and it should come down to sending a regular email. Manually, you are  able to email aleks@iwscc.ca.

What could it be?
0
Hello,

Please follow this link and see my category slideshow

http://paula.darkstarmedia.net/category/dance/

I have edited the archive.php page in wordpress to display the most recent  posts featured images in a slideshow, in the category page you are on.

The images are working perfectly, the problem is I am trying to display the title below the image, but as you can see it is grabbing 2 random titles and overlapping them, on top of that the 2 aren't connected to the image.

This is my code

<?php
$category = get_the_category(); 



if( ($category[0]->cat_ID  == 7 && is_category() ) || 
  ($category[0]->cat_ID  == 4  && is_category() ) || 
  ($category[0]->cat_ID  == 1101 &&  is_category() )|| 
	 ($category[0]->cat_ID  == 5  && is_category() ) || 
  ($category[0]->cat_ID  == 3 &&  is_category() )   ) {

?>
<div id="myCarousel" class="carousel slide" data-ride="carousel" >

<!-- Wrapper for slides -->

<div class="carousel-inner">

<?php
$write_active = "active"; 
$args = array(  'posts_per_page' => 5, 'orderby' => 'post_date', 'cat'=> $category[0]->cat_ID  );
$loop = new WP_Query( $args );

while ( $loop->have_posts() ) : $loop->the_post();

echo '<div class="carousel-item '.$write_active.'  " >';
$write_active = ""; 
	
	if (has_post_thumbnail()):
           the_post_thumbnail('default-thumbnail');
      else:
     		echo '<img src="'.$default_thumbnail.'" alt="'.the_title().'" />';
	 endif; 
echo '</div>';


echo '<div class="carousel-caption">';
	echo 

Open in new window

0
Hi Experts,

How can I resize an image dynamically based on their original width or height, without distorting them?

Let me elaborate...

The images are logos that are uploaded by users, so their dimensions are unknown. Some squares, some vertical rectangles, others horizontal. In other words there are 3 possible shapes.

I'm only in the planning phase for this, but i'll have a container (div) for these images, with a fixed size, let's say 190 x 60px.

So based on the 3 shapes and on the known 190 x 60 container, I'd want to end up with the following if the shape is

  • Square
  • , then the display size would be
  • 60 x 60

  • Horizontal
  • , then the display size would be
  • 190 x calc

  • Vertical
  • , then the display size would be
  • calc x 60

In each scenario, the img would remain its original size if it is less than 190x60 I think

Now, I know calc would be proportional. For example, for vertical, calc (or width) would be 60/[orig_height]x[orig_width]

So, my first question is how to obtain the original dimensions of a given image file?

Secondly, what is the easiest way to do this, considering that I'm using PHP/jQuery/SCSS? I'm leaning towards doing it all on the  PHP side.

Thank you.
0
Hi all, I know some of you have used Clickatell to send SMS.

I'm trying to send a £ in the URL, but e.g. £40 is received as A£40

I'm doing the urlencode before adding to the URI:


$text_message = html("FROM FOBG, DO NOT REPLY. ".$newfirstname.", as at ".$todays_date.", you owe the club £".$txtAmount.". You have until ".$due_date." to pay.");
echo $text_message;

$text = urlencode($text_message);
echo $text;

Open in new window


I have tried &pound;  htmlentities etc but no luck so far.
0
Here's my Controller code:

 public function index()
    {
		$events = Calendar::all()->sortBy('start_date', 'desc');
		return view('admin/listCalendar', compact('events'));
    }

Open in new window


When I remove the "sortBy" dynamic, all is well. When I include the "sortBy," I get this:

asort() expects parameter 2 to be int, string given

My datatype in my database is "date," so what do I need to change so I can sort my rows by date?

I'm running Laravel 6.
0
Hi Experts,

I have a primary domain with WordPress, that is mainly content. Now I am building a custom PHP application in a subdomain, and I need to show a form from the subdomain in the primary one, with all includes, etc.

Is it possible to have a iFrame in WP (or anywhere for that matter), so it does not have scroll bars, but actually have a natural flow, sort of  overflow visible?

Any help will be appreciated.
0
Hi Experts

Could you point the better strategy to deploy a Laravel project at host ?

My hosting provider offers cPanel.

(I intend to do that to my own site)

Another option could be FTP - but I guess to transfer a complete Laravel project (with vendor folder) would be cumbesome to be done that way.

Thanks in advance.
0
Hi Experts      
            
Could you explain the meaning of this piece of Laravel code?

It was adapted from a legacy code due changes on table's structure.

      

		
$mes_atual = (int) date('m');	


        $compras = Compra::
                 leftjoin('periodos', 'periodos.id', 'compras.periodo_id')
                ->leftjoin('meses', 'periodos.mes', 'meses.mes')
                ->where('periodos.id', \DB::raw($mes_atual))
                ->groupBy('meses.id')
                ->select(DB::raw('(sum(grupo_a) + sum(grupo_b) + sum(grupo_c)  + sum(grupo_d) + sum(grupo_e) + sum(grupo_f) + sum(grupo_g)) as compraMensal'), 'meses.id')
                ->get();


        $totalDeMesesComCompra = $compras->count();

// What these parameters represents here?

$totalDeMesesComMetaBatida = $compras->reduce(function($quantidade, $item) use ($metasMensais){
  
  // This variable must to be redeclared here - otherwise it couldn't be found.... (?!)
  $mes_atual = (int) date('m');	

  $metaMes = $metasMensais
	  ->where('periodo_id', \DB::raw($mes_atual))
		->first();
		
	// The result of above query:
	// {"metaMensal":"139747.6600","periodo_id":2}
		
		
  if(empty($metaMes)){
	return $quantidade;
  }

  //   It results (1) if (true):  $metaMes->metaMensal >= $item->compraMensal 


  return $quantidade + ($metaMes->metaMensal >= $item->compraMensal);
}, 0);

Open in new window

           
            
            
		
$totalDeMesesComMetaBatida = $compras->reduce(function($quantidade, $item) use ($metasMensais){

  $metaMes = $metasMensais
			->where('mes', $item->mesreferencia)
			->where('ano', $item->anoreferencia)->first();
  
  
  if(empty($metaMes)){
	return $quantidade;
  }

  return $quantidade + ($metaMes->metaMensal >= $item->compraMensal);
}, 0);

Open in new window


Thanks in advance!
0

PHP

121K

Solutions

33K

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.