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.

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

Sign up to Post

Hi Experts,

Can you anyone see why the Currency converter stopped working for some reason at https://www.aces-project.com/index.php/live-apps/

If you place a breakpoint at line 76 on https://www.aces-project.com/wp-content/themes/aces-project/live-apps.js, then run it, you'll notice that  I set my url appropriately on  Li. 35, but within my AJAX Call neither my url is appended from Li. 44 nor any data  is sent to the php script from Li. 49-52

Any help would be greatly appreciated.
Thank you!
0
Python 3 Fundamentals
LVL 13
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Hi Experts,  

I have several web sites that are currently running PHP 5.4.45 and we need to convert to PHP 7.3+ as the older version is no longer supported.  Is there a converter/script I can run or other method?

Thanks in advance!
0
I'm able to print the label's fine but would like to have the first line 6pt Itallic, the second line 8pt bold, and the rest in 8pt.
My issue is simmaler to ..
https://www.experts-exchange.com/questions/29089661/Can-you-BOLD-part-of-text-you-want-to-show-in-a-PDF-using-FPDF-and-PDF-Label.html
But found no useful help.

 $text = sprintf(" %s            %s\n %s  %s\n %s\n %s  %s  %s", $id, $dueDate2, $firstN, $lastN, $address, $city, $state, $zip);
$pdf->Add_Label($text);

Open in new window


PDF_Label..

<?php
////////////////////////////////////////////////////////////////////////////////////////////////
// PDF_Label 
//
// Class to print labels in Avery or custom formats
//
// Copyright (C) 2003 Laurent PASSEBECQ (LPA)
// Based on code by Steve Dillon
//
//---------------------------------------------------------------------------------------------
// VERSIONS:
// 1.0: Initial release
// 1.1: + Added unit in the constructor
//      + Now Positions start at (1,1).. then the first label at top-left of a page is (1,1)
//      + Added in the description of a label:
//           font-size : defaut char size (can be changed by calling Set_Char_Size(xx);
//           paper-size: Size of the paper for this sheet (thanx to Al Canton)
//           metric    : type of unit used in this description
//                       You can define your label properties in inches by setting metric to
//                       'in' and print in millimiters by setting unit to 'mm' in 

Open in new window

0
New to PHP, using ZendExpressive  I have this as a PHP array that i did a

  $a = array($identity);
echo('<pre>');
print_r($a);

it prints out this

Array
(
    [0] => Authorized\AuthorizedUser Object
        (
            [identity:Authorized\AuthorizedUser:private] => XYZ
            [roles:Authorized\AuthorizedUser:private] => Array
                (
                    [0] => U
                )

            [details:Authorized\AuthorizedUser:private] => Array
                (
                    [id] => XYZ
                    [role] => U
                    [permissions] => Array
                        (
                            [Flag1] => Y
                            [Flag2] => Y
                            [Flag3] => Y
                            [Flag4] => Y
                            [username] => Smith, John
                        )
                )
        )
)


I want to get [permmisions][Username]

the value in roles

basically any element

How do I get it
0
Hi,

I have the following json_decode data :

Array
(
    [metadata] => Array
        (
            [result] => 1
            [version] => 1
            [command] => listzones
            [reason] => OK
        )

    [data] => Array
        (
            [zone] => Array
                (
                    [0] => Array
                        (
                            [zonefile] => mybrand.asia.db
                            [domain] => mybrand.asia
                        )

                    [1] => Array
                        (
                            [domain] => mybrand.my
                            [zonefile] => mybrand.my.db
                        )

                )

        )

)

Open in new window


May i know how to manipulate the data ?

Eg:

1. How to get "mybrand.asia" or "mybrand.my.db" output ?

2. How to loop each data in foreach ?


Appreciates anyone assistant on this.

Thank you.
0
Email form is hanging and stopped sending....
I have a jquey script that handles the form hiding it after the email is sent.  This is not working, it just keeps saying sending....the emails did send at one point and that stopped as well.16-Contact-Us.htmlcontact.php
0
Setting up an email form.  It is not sending.

<?php
if(!isset($_POST['submit']))
{
	//This page should not be accessed directly. Need to submit the form.
	echo "error; you need to submit the form!";
}
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$website = $_POST['website'];
$message = $_POST['message'];

//Validate first
if(empty($name)||empty($visitor_email)) 
{
    echo "Name and email are mandatory!";
    exit;
}

if(IsInjected($visitor_email))
{
    echo "Bad email value!";
    exit;
}

$email_from = 'smg@schuremediagroup.com';//<== update the email address
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $name.\n".
    "Here is the message:\n $message".
    
$to = "smg@schuremediagroup.com";//<== update the email address
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: thank-you.html');


// Function to validate against any email injection attempts
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;
  }
}
   
?> 

Open in new window


<form method="post" name="myemailform" action="form-to-email.php">
                <div class="row fild_1">
                    <div class="col-sm-6">
                        <input type="text" class="form-control" name="name" placeholder="Full Name">
                    </div>
                    <div class="col-sm-6">
                        <input type="email" class="form-control" name="email" placeholder="Email">
                    </div>
                </div>
                <div class="row fild_2">
                    <div class="col-sm">
                        <input type="text" class="form-control" name="website"placeholder="Website">
                    </div>
                </div>
                <div class="form-group">
                    <textarea class="form-control" name="message" rows="3" placeholder="Message"></textarea>
                </div>
                <button type="submit" class="btn btn-primary">SEND MESSAGE</button>
            </form>

Open in new window

0
Forgot Password page

I am attempting to code a page were a user can go to create a temporary password which will be sent to their email address.

I have included some code at which point I receive the following error. - password_hash() expects at least 2 parameters, 1 given

	

// Create a new, random password:
		
$p = substr(md5(uniqid(rand(), true)), 3, 15);
		
$ph = password_hash($p);

Open in new window

0
Not being a PHP coder and out of practise in Javascript I hope someone can help me with this. A website I'm working with has a drop-down menu that's really ugly, but a mobile alternative that the company likes and prefers. I initially thought it was controlled through SCSS but found the following javascript. Of course it may still be a SCSS issue but I'd like to try this first.

function isMobile() {
    var useragent = navigator.userAgent;
    return useragent.indexOf('Android') != -1
        || useragent.indexOf('iPhone') != -1
        || useragent.indexOf('iPod') != -1
        || useragent.indexOf('iPad') != -1;
}

Open in new window


What I need is for this function to return a "yes" so that it's always a mobile device.

many thanks

Rob
0
Thank you for looking at my question,

I am trying to use phpspreadsheet - plan is to extract data rom .xlsx spreadsheet(s) into a MySQL database but can't get past square one.

I have a php script that is located in var/www/html/ProjectName

 Our IT department have installed Composer and PHPSpreadsheet on the same server but in a folder Composer that is on the same level as the var folder.

 All phpspreadsheet examples I can find show the following require and use statement

<? php

        require 'vendor/autoload.php';

	use phpoffice\phpspreadsheet\spreadsheet;
	use phpoffice\phpspreadsheet\writer\xlsx;

?>

Open in new window


Does this mean the code reads the require and use paths as starting in the projectname directory?

I can use
require '../../../../composer/vendor/autoload.php';

Open in new window

to get to the autoload file but how do I specify the paths in the Use statements to point to the right location?
CESTrack_2.php
0
Bootstrap 4: Exploring New Features
LVL 13
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Hello,

I need to extract data from a spreadsheet (xlsx) into an array. I am struggling with phpspreadsheet and really need some help.

My first attempt returns the number of rows in the first sheet of the workbook but when I try to display the contents to the screen in a table the code falls over with http 500 error - I can't see why and don't know how to capture the cause of the error.

      require '../../../../composer/vendor/autoload.php';
      
      use phpoffice\phpspreadsheet\spreadsheet;
      use phpoffice\phpspreadsheet\writer\xlsx;
      
      $xlfile = 'ExcelTest.xlsx';
      $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($xlfile);
      
      $xls_data = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
      
      $nrows = count($xls_data);
      
      echo '<h2> No. Rows: ' . $nrows . '</h2>';   //Code works to here
      
/*      

        // If I include this the whole thing falls over
      echo '<table>';
      foreach ($xls_data[0] as $column){
            echo '<tr><td>' . $column . '</td></tr>';
      }
      echo '</table>';
*/
ExcelTest.xlsx
CESTrack_2.php
0
I have created a website using mostly Lucee (coldfusion) but it also has some javascript code, php and a MySQL database. I would like to use the same code for a new website and it would use its own database. What is the best way to copy over the files? One option is to use FTP to upload the files but that takes a long time since there are a lot of files. Is there a way to package the files into one file and then install it for the new website?

Also, I have noticed that a copy of my cfm and cfc files are found in a directory called cfclasses and they have been renamed. It seems that *.cfm have been renamed to *_cfm$cf.class and *.cfc have been renamed to *_cfc$cf.class. Are these precompiled files? Can I use these files instead to speed up loading of the site and so that I don't have to give away my source? If so do I have to rename all of these files back to their original names? Is there a fast way to do this?
0
Hi, I have a js script that I use to display a message and I need help editing the script to highlight parts of the rendered text.

The script generates a message like this:

This reservation is for a One Bedroom Condo for 3 nights arriving on Monday, September 24, 2019, and departing on Thursday, September 27, 2019, with the choice of No Tickets Included.

and I would like to highlight some parts of the text like this:

This reservation is for a One Bedroom Condo for 3 nights arriving on Monday, September 24, 2019, and departing on Thursday, September 27, 2019, with the choice of No Tickets Included.

On the script, I believe the section that displays the message is this:
 else {
      var descText = "";
      var roomTypeText = $("#roomTypeSel option:selected").text();
      if (roomTypeText) descText += "This reservation is for a "+ roomTypeText+" for  ";
      descText+=days +" night"+(days==1?"":"s")+" arriving on "+arrivalDate+" and departing on "+departureDate
      var ticketChoice = $("#Tickets option:selected").text();
      if (ticketChoice && ticketChoice!= "No Tickets") descText += " with the choice of " +ticketChoice;
      $("#description").html(descText);
      getPrice(dateString,days,roomType);

Open in new window


Please help me edit the attached file to get the desired result.

Note: By highlight, I mean bold text.

Thanks,

Jorge B
calendarmain.js
0
Hello,

I am getting some weird server caching with bluehost.

I get a fatal php error with my functions file, so I fixed the file..but I still get the exact same error.. so I delete the functions file, and 15 minutes later, i dumped my cache, cleared DNS cache through terminal, but I still get the php error

WTF is happening?

Bluehost assured me they server is not caching
0
I have code that is returning a comma in a number higher than 1000 and I need to get rid of the comma.

This current code returns a number with a comma if the number is higher than 1000...

        $totals = array('subtotal' => number_format($subtotal,2),
                          'total'    => number_format($order['OrderTotal'],2));

This code does not return the comma but does add two extra zeroes after the decimal point, so it returns something like 1252.3400...

        $totals = array('subtotal' => ($subtotal),
                          'total'    => ($order['OrderTotal']));

So, that second code bit "fixes" the issue with the comma but now I need to get rid of the two extra zeros at the end returned by that second block of code.
0
Hi, I have a js script that generates the date format without the day of the week like September 24, 2019, but I need it to display Tuesday, September 24, 2019. Could you please help me edit the script to make that change?

Thank you in advance for your help.

Jorge B.
calendarmain.js
0
I have a web-based application built for a shop intranet which has the requirement for users to be able to print to local printers installed on the web-server or network printers on the LAN (whichever is easier). The clients need to be able to produce receiving and shipping tickets from the app to the printers in those departments, so; server-side printing.

I have tried an number of approaches to this using PHP shell functions and incorporating printhtml.exe from http://www.printhtml.com/ but with no success.
Research online shows an old php_printer dll but it will not load as an extension in v5.4. I know this is possible, at least in theory, but I am stuck.
Can anyone suggest a solution? Thanks.
0
Im using php but i have a problem, when allowing user to create a list they adding charaters they shouldnt, here is a list i collected below

. ; / ? ! " @ $ ()

how can i make sure non of these enter the database in one go instead of mutiple find and replaces ?
0
I don't know PHP and a website I manage is a WordPress site which has a custom made contact form that is being brute force attacked. I know how to add a captcha in ColdFusion but don't know how to do that in PHP. Does anyone know how to add a captcha in PHP that would be easy for me to implement?
0
Learn SQL Server Core 2016
LVL 13
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Thank you for looking at my question,

I have a php script that is located in var/www/html/Project

Our IT department have installed Composer and PHPSpreadsheet on the same server but in a folder Composer that is on the same level as the var folder.

How do I alter this require statement

require 'vendor/autoload.php'

so that it points to composer/vendor/autoload.php where, as I mentioned above, the composer folder is at the same level as the var folder in the directory tree?
0
Hi experts,

I need SQL syntax help please.

Here is my business scenario; I need to get a count by distinct employee type of 4 different measures. If the count of employees by each measure does not equal zero/null then show the total count. If the count of employees by each measure equals zero or null, show zero.

I'd like to use PHP to echo the results in a table that would take the following format:

distinct_type | MeasureA | MeasureB | MeasureC | MeasureD
Emp Type X | 1 | 0 | 1 | 1
Emp Type Y | 0 | 1 | 0 | 1
Emp Type Z | 1 | 1 | 0 | 0

Something like...I know I am way off...

(SELECT DISTINCT employee.type AS  'distinct_type' FROM mydatabase ORDER BY employee.type)
UNION ALL
(SELECT employee.type, COUNT(*) AS 'MeasureA' FROM my database WHERE employee.type=distinct_type AND measures.a=1 GROUP BY employee.type ORDER BY employee.type ASC)
UNION ALL
(SELECT employee.type, COUNT(*) AS 'MeasureB' FROM my database WHERE employee.type=distinct_type AND measures.b=1 GROUP BY employee.type ORDER BY employee.type ASC)
UNION ALL
(SELECT employee.type, COUNT(*) AS 'MeasureC' FROM my database WHERE employee.type=distinct_type AND measures.c=1 GROUP BY employee.type ORDER BY employee.type ASC)
UNION ALL
(SELECT employee.type, COUNT(*) AS 'MeasureD' FROM my database WHERE employee.type=distinct_type AND measures.d=1 GROUP BY employee.type ORDER BY employee.type ASC)
0
Thank you for looking at my question,

The IT department have installed Webmin on a MySQL server. I have written a bit of php code and saved it to the correct place on the server.

The code is a simple table and begins like this:
<?php # Script 1.0 - Section1.php
      require_once $_SERVER['DOCUMENT_ROOT'] . '/CESTrack/Includes/configinc.php';
      //require_once $_SERVER['DOCUMENT_ROOT'] . '/CESTrack/Includes/mysql_connect.php';
      
      $Page_Title = "KLTD E-D1";
      include($_SERVER['DOCUMENT_ROOT'] . '/CESTrack/Includes/CESTrack_Header.html');
      
      echo '<h2>CES Tracker</h2>';
      
      echo '<table width="100%">';
            echo '<tr>';
                  echo '<td align="center">';
                        echo '<table width="80%" border="2">';
                              echo '<tr>';
                                    echo '<td colspan="16">';
                                          echo '<h2>HONKER LTD CES DASHBOARD</h2>';
                                    echo '</td>';
                              echo '</tr>';
                              
                              echo '<tr>';
                                    echo '<td width="13%" align="left">';
                                          echo'<h2>Activity</h2>';
                                    echo '</td>';
                                    
                                    echo '<td width="13%" align="center" colspan="3">';
                                          echo'<h2>Queries</h2>';
                                    echo '</td>';
                                    
                                    echo '<td width="13%" align="center" colspan="3">';
                                          echo'<h2>SENQ Enq/Quotations</h2>';
                                    echo '</td>';
                                    
                                    echo '<td width="13%" align="center" colspan="3">';
                                          echo'<h2>SENQ Orders</h2>';
                                    echo '</td>';
                                    
                                    echo '<td width="13%" align="center" colspan="3">';
                                          echo'<h2>Projects</h2>';
                                    echo '</td>';
                                    
                                    echo '<td …
0
Dear Experts,
I'm trying to include a file which is on one folder up,
however it doesn't work.

I'm using PHP 7.3
Help is needed.

my code is
<?php  include'../header-about.php';  ?>

Open in new window

0
Problem with my query, when adding a value that has a single quote to a database field.

eg. //-- values
        $value1 = "Peter";
        $value2 = "O'Leary";
        $value3 = "Contact Person";
     //-- query
        $stmt = $mysqli->prepare("INSERT INTO table1 (field1, field2, field3) VALUES (?,?,?)");
        $stmt->bind_param('sss',  $value1, $value2, $value3);
        $stmt->execute();
        $newId = $mysqli->insert_id;
        $stmt->close();

This does not insert anything, and $newId has no value.

So it seems I have a really silly question... I'm sure it's something really obvious, but I'm dead tired and can't figure it out.

I've tried...
$value2 = htmlspecialchars("O'Leary", ENT_QUOTES, 'UTF-8');
$value2 = mysqli_real_escape_string($mysqli, "O'Leary");
0
There are two buttons in PHP. If user click button 1, it will go to action1.php. If user click button2, it will go to action2.php

Any idea how to code it ?

Thx
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.