Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x

PHP

119K

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

Hi Experts,

Can anyone tell me how to add a square (checkbox) and a checkmark into TCPDF?

However, this is to be a read-only PDF, not XHTML.  I'm using a multi cell, outputing options from a db with \n, and next to some I need a square, next to others check boxes.

I was thinking font-awesome in combination with chr(), but I'm not sure how that will work with TCPDF.

Thanks.
0
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.

Hey there, i have files saved on database using this script

     <form method="post" enctype="multipart/form-data" >
     <input type="file" name="myfile"/>
     <button name="btns"> Incarca Schita </button>
     </form>
     <?php
     $dbh = new PDO("mysql:host=localhost;dbname=highmob_comenzi", "highmob", "PW");
     if(isset($_POST['btns'])){
         $name = $_FILES['myfile']['name'];
         $type = $_FILES['myfile']['type'];
         $data = file_get_contents($_FILES['myfile']['tmp_name']);
         $stmt = $dbh->prepare("UPDATE players SET data='$myfile', name='$name', mime='$type' WHERE id='$id'");
         $stmt->bindParam(1,$name);
         $stmt->bindParam(2,$type);
         $stmt->bindParam(3,$data);
	     $stmt->execute();
     }
     ?>
  <?php
$stat = $dbh->prepare("select * from players where id='$id'");
$stat->execute();
while($row = $stat->fetch()){
	echo "<a href='viewschita.php?id=".$row['id']."'>".$row['name']."</a>
	";
}
?>

Open in new window


this is the viewschita.php

<?php
$db = mysqli_connect("localhost","highmob","PW","highmob_comenzi"); //keep your db name
$sql = "SELECT * FROM players WHERE id = $id";
$sth = $db->query($sql);
$result=mysqli_fetch_array($sth);
header('Content-Type:'.$row['mime']);
echo  $row['data'];

?>

Open in new window


The problem is that I'm unable to see the file
0
Dear Experts,
I'm using PHP
I know that some websites use php, but they do not have page extentions like about.php
Do they use folders for every page or do they use something to hide their page extentions?
I click the link, the link is www.domain.com/about-us
do they create about-us folder for every page they have or do they use something for the SEO purposes?
0
Hi Experts,

I have a site with a lot of images that get loaded on a page with infinite scroll..trouble is...everytime page loads they is a delay before the images start to load... https://www.stockimagesafrica.com/downloads/category/southern-africa/ please check the link and see how images are loading..need to add some kind of preloading icon as images begin to load to save time.  Need help with getting this done..
0
I have no administrative knowledge of installing software on a server and consider myself a newbie of this issue. I am asked to upgrade Moodle on our test server so that the tests that we are currently doing under PHP 7 will hopefully find out any issue that arises because of using a newer Moodle version. To start with, I read about this issue at the Upgrade overview, where following is written:

Step 1: Make sure that your server can run Moodle 3.4
(Note: You need to upgrade to Moodle 3.0 or later before upgrading to 3.4.)

Go to Settings > Site administration > Server > Environment

I wonder how it can give detailed information about where to look, as the person who wrote these lines cannot know which operating system my Moodle server is using. Actually, we use Linux Debian, and I can connect over FTP to it. Can you give me support in this issue? I think to upgrade Moodle to the newest version 3.4.1 is not a big deal to an experienced person.

Thank you for your help!
0
Hi,
I have a script that uses a product called PHPDocX, I'm trying to insert an image name from a database based on a $POST value:

?php
$servername = "localhost";
$username = "antony";
$password = "*******";
$dbname = "templatemadness";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
$sql = 'SELECT
id,
letter_logo_image
FROM
template_header
WHERE
[b]id = ******************';//this will need to be a $POST value from index.php[/b]
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        
        echo  $row["letter_logo_image"];//to prove it works!
    }
} else {
    echo "0 results";
}

?>
<?php  echo  $row["letter_logo_image"]; ?>
<?php
require_once 'Classes/Phpdocx/Create/CreateDocx.inc';
require_once 'Classes/Phpdocx/Elements/WordFragment.inc';


$docx = new Phpdocx\Create\CreateDocx();
$docx->modifyPageLayout('A4', array('numberCols' => '1','marginRight' => '400','marginLeft' => '400', 'sectionNumbers' => array(2) ));
//create a Word fragment with an image to be inserted in the header of the document
$imageOptions = array(
	[b]'src' => 'images/***imagename from database***', //this needs to pull the image name from 'letter_logo_image'[/b]
	'dpi' => 600,
);

$headerImage = new Phpdocx\Elements\WordFragment($docx, 'defaultHeader');

Open in new window

0
Dear Experts,
I want to learn why I need to use NULL twice for this nested statement? what is NULL for in this statement?
SELECT table1.uid, 
       table1.isim, 
       NULL, 
       NULL 
FROM   table1 
WHERE  NOT EXISTS (SELECT 1 
                   FROM   table2 
                   WHERE  bayikodu = table1.uid); 

Open in new window

0
I have gone through many sites but not getting any idea regarding how to build the database and how to start working on it in core php. Any help would be great because I need to complete it as a part of my task
0
<?php
include 'config.php';
$class="";
$message='';
$error=0;
$target_dir = dirname(__FILE__)."/Uploads/";
if(isset($_POST['btn-upload']))
{  
    $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
	$fileType = pathinfo($target_file,PATHINFO_EXTENSION);
	if($fileType != "csv")  // here we are checking for the file extension. We are not allowing othre then (.csv) extension .
	{
		$message .= "Sorry, only CSV file is allowed.<br>";
		$error=1;
	}
	else
	{
		if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
			$message .="File uplaoded successfully.<br>";
			
			if (($getdata = fopen($target_file, "r")) !== FALSE) {
			   fgetcsv($getdata);   
			   while (($data = fgetcsv($getdata)) !== FALSE) {
					$fieldCount = count($data);
					for ($c=0; $c < $fieldCount; $c++) {
					  $columnData[$c] = $data[$c];
					}
             $name = mysqli_real_escape_string($connect ,$columnData[0]);
             $cpu = mysqli_real_escape_string($connect ,$columnData[1]);
			 $memory = mysqli_real_escape_string($connect ,$columnData[2]);
			 $disk = mysqli_real_escape_string($connect ,$columnData[3]);
			 $nic = mysqli_real_escape_string($connect ,$columnData[4]);
			 $price = mysqli_real_escape_string($connect ,$columnData[5]);
			 
             $import_data[]="('".$name."','".$cpu."','".$memory."','".$disk."','".$nic."','".$price."')";
            // SQL Query to insert data into DataBase

             }
             $import_data = 

Open in new window

0
I am working with a non profit.

I don’t have a good idea of how Access is used yet, it’s my first day.


Would it be recommended to use a web application instead of Access?

The non profit is a mental health clubhouse. Right now people sign in and out on a piece of paper and it’s manually entered into Access.


It seems like if we used a web app we could allow people to sign in and out digitally and access it automatically.


Additionally we could generate CSV files to import into Excel.


Where should I begin in evaluating this decision?
0
Keep up with what's happening at Experts Exchange!
LVL 11
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Dear Experts,
I select data from my database like this

$sql = "SELECT _key,urun,tarih FROM order WHERE _key between 75 and 120";

$res = $mysqli->query($sql);

if ($res->num_rows > 0) {
    while($row = $res->fetch_assoc()) {
	$key= $row["_key"];	
	$urun= $row["urun"];
	$tarih= $row["tarih"];
	
	if ($key=="98") {$newvariable98=$urun ;}
	if ($key=="106") {$newvariable106=$urun ;}
	if ($key=="120") {$newvariable120=$urun ;}
	
	}
 }

Open in new window


since $row is an array, is there a better way to select key 98,106,120 data? Thank you
0
<?php
include 'config.php';

if(isset($_POST['btn-upload']))
{  


$targetDir = "uploads/";
$fileName = $_FILES['file']['name'];
$targetFile = $targetDir.$fileName;


    echo $fileName . '<br />';
}

?>

Open in new window


Capture.PNG
One file only has been displayed ..

my desire output was 30 filenames displayed .
0
I have in table column named user_date, and I have jquery on frontend to get user status ADULT or YOUNG. When user pick the date, script automaticaly write ADULT or YOUNG, depending on his picked date and current date, = >18 or <18. Now I would, to get number of young users which for one month will be ADULT, and get that number like some alert.
0
Dear Experts,
I need to select to some data from my database but this time I think I need to use an array.

I wrote something like this but it is not working?

$sql = "SELECT id,onay FROM urunler where id between 271 and 290";
$info = array();
$result = $mysqli->query($sql);

    while ($row_user = mysql_fetch_assoc($sql)){
    $info[] = $row_user; 	
	}
	
	foreach ($info as $user) {
    echo "Id: {$user[id]}<br />"
       . "Name: {$user[onay]}<br />";
}

Open in new window

Also, I wonder how can I call a specific variable from this array?
For example if I'd like to see what is inside id 271, should I write it like this?
echo $user[onay][271];

Open in new window

0
i am fresher in php: i have table (admin) where two row is there intime,outtime
i wants to calculete time Diffrence and show to frontend how can i do that12.PNG

i Want to show total time diffrence like this format 08.00.12hrs[hours:minutes:second]
0
Object of class mysqli could not be converted to string in

this message show whne  i try to write in textarea about 700 words

how i can solve this problem
0
good afternoon:
i am some issue of display the attence for Each user:
 I Have Two Table :
First Table Contains Admin table Which Conatains:
userid
intime
outtime
second Table Contains use table Which Conatains:
id
username
password
role
I Have a landing page where i am displaying userinformfation from usertable and one link is there viewattendence ,if user click then it display userattendence  based on her id
But issue is there that attenence is in admin table(login and logout):then how can i get the attendence beacause in landing page  user passses id not userid:and url search for id which is not there in admin table
For this issue i am using mysql query is:
$sql = "select admins.id, admins.intime, admins.outtime
                                 from admins inner join userregisters  Having  admins.userid='" . $_GET["id"] . "'";

Open in new window

How can i do that plz suggest me
0
Hi, I manage a WordPress website for a local motorcycle dealer and he'd like to integrate with iVendi's finance calculator widget.

All the calculator needs is a line of Javascript in order to generate the widget, with 3-4 fields pre-populated (e.g. URL, username, registration, mileage, value).

The widget works great when you manually paste the code in but I just wondered if it was possible to pre-populate the script based on the listings from the motorcycle's WooCommerce listing.

Below is an example of a sample script that works:

<script src="https://newvehicle.com/widgets/lib/finance-comparator/loader.js?username=www.motorcycledealerurl.co.uk&quoteeUid=UNIQUE-ID-STATIC-VALUE&class=Bike&condition=Used&vrm=AE60HDD&registrationDate=01/11/2010&capCode=&capId=&cashPrice=5295&vatIncluded=&currentOdometerReading=25897&vehicleImageUrl=http://www.motorcycledealerurl.co.uk/wp-content/uploads/2017/12/IMGP8321.jpg&cashDepositType=&cashDeposit=500&term=36&annualDistance=10000&dateOnForecourt=" async></script>

Open in new window



I need to have the following fields populated from the WooCommerce listing:

vrm
registrationDate
cashPrice
currentOdometerReading

...ideally these need to be pre-populated for each motorcycle as opposed to manually typing these into the script each time...is this possible?

Thanks in advance!
0
I want to import the directory without set the import location , because i have many directory to import.

$log_directory = '/xampp/htdocs/mydoc';

$results_array = array();

if (is_dir($log_directory))
{
        if ($handle = opendir($log_directory))
        {
                //Notice the parentheses I added:
                while(($file = readdir($handle)) !== FALSE)
                {
                        $results_array[] = $file;
                }
                closedir($handle);
        }
}

//Output findings
foreach($results_array as $value)
{
    echo $value . '<br />';
}

Open in new window


$log_directory = '/xampp/htdocs/mydoc';
I dont wanna set path like this .. izit posible or not ? because i lazy set again and again to import different directory
0
Become an Android App Developer
LVL 11
Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

This should be easy, but it's kicking me squarely in the pants and I don't know what I'm doing wrong.

Here's what I'm using:

      $sql=$conn->prepare("SELECT homepage_id from employers where id=:id");
            $sql->bindParam(':id', $id, PDO::PARAM_INT);
            $row=$sql->fetch();
            $the_name=$row->homepage_id;
            echo $the_name;

I get no errors but no value and there is a value in the database that should be coming up.

What am I doing wrong?
0
This is the last question regarding this webpage. I have records from a database for the last 2 months being displayed on a webpage. It shows the older month on top. I tried to put tables side by side which worked but only 1 header would display for some reason. I am ok with the tables being display 1 on top of the other I would like the most recent month on top. Any time i try and change the display the code has an error and displays nothing. I am not sure if I have to break the data out when displaying. I have attached code and screenshot. I would like Jan on top and then December as there will be a lot of records so will probably have to scroll. Help is always appreciated.
Before.jpg
index.php
0
How can i solve this error :S

below is my index.php

and the line of the function 79 and 133 is-
index.php
0
How to fix this .. can upload the directory but all the csv file content i upload was the same file  ..
Actually there are 30 files , but one file uploaded 30 times.
Here are my code for upload part .. upload.php
<?php
include 'config.php';

if(isset($_POST['btn-upload']))
{    
  $log_directory = '/xampp/htdocs/mydoc';
  $results_array = array();

        if ($handle = opendir($log_directory))
        {
                while(($file = readdir($handle)) !== FALSE)
                {
                    if ($file != "." && $file != "..") {
                        $results_array[] = $file;
                    }
                }
                closedir($handle);
        }

  //Output findings
  foreach($results_array as $value)
{
 $csvMimes = array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain');
    if(!empty($_FILES['file']['name']) && in_array($_FILES['file']['type'],$csvMimes)){
        if(is_uploaded_file($_FILES['file']['tmp_name'])){
            
            //open uploaded csv file with read only mode
            $csvFile = fopen($_FILES['file']['tmp_name'], 'r');
            
            //skip first line
            fgetcsv($csvFile);
            
            //parse data from csv file line by line
            while(($line = fgetcsv($csvFile)) !== FALSE){
       

Open in new window

0
Hi,
I did check the current .php file but I cannot find out how highlighted message would be trigger, within the Web page.

20u.png
0
Hey

I followed these directions
https://developers.google.com/recaptcha/old/docs/php

And I have the code below. I"m always getting the message that says Google Captcha not working no matter what.


<?php
require_once 'recaptchalib.php';
  require_once '../includes/functions.php';
  redirect_tablet_by($_SERVER['HTTP_USER_AGENT']);
  $title = 'Contact Us';
  $description = 'Contact information and directions for Consolidated Utilities, Coastal Water and Sewage, Coastal Water Company, Whitemarsh Estates
    Water System, Woodlawn Water Savannah Ga, and Golden Isles Water System.';
  $privateKey = 'asdf';
  $errors = array();
  $flag = true;
  $name = null;
  $email = null;
  $address = null;
  $subject = null;
  $message = null;
  $alert = null;

$resp = recaptcha_check_answer ($privateKey,
    $_SERVER["REMOTE_ADDR"],
    $_POST["recaptcha_challenge_field"],
    $_POST["recaptcha_response_field"]);

  if (isset($_POST['submit'])) {
      if (isset($_POST['name'])) {
          $name = stripslashes($_POST['name']);
          $length = strlen($name);
          if ($length < 2 || $length > 40) {
              array_push($errors, 'Name must be between 2 and 40 characters.');
              $flag = false;
          }
      } else {
          $name = null;
          array_push($errors, 'Name is a required field.');
          $flag = false;
      }
      if (isset($_POST['email'])) {
          $email = stripslashes($_POST['email']);
          if (!filter_var($email, 

Open in new window

0

PHP

119K

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.