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

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
Free Tool: Subnet Calculator
LVL 11
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

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
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
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
Might anybody have a zip file of PHP MySQLi Dreamweaver starter pages?  No extensions really work anymore and I need to create a dynamic website.  I have DMXzone, Webassist and DWzone extensions but they all fail in one way or another.  I want to write the code the correct way from now on.  Thanks
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 5
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.

I have a parent and child theme.
index.php is only present in the parent theme but whatever changes I make to it are ignored when I visit the website.
I realise changes should be made to an overload version of index.php in the child theme but this is just for testing purposes to work out why it doesn't appear to get looked at. I've even made the code in the index.php invalid by removing a few php tags but it has no effect whatsever. I would at least expect the website to break - but it doesn't.
0
Hi,

I have this page http://kroweb.dk/gfdev/godser/godser.php

Everything is working nicely except for two things.

I would like to get the searchfield in focus when the page opens or is refreshed  - searchfield id is "input_1"

I need to get the Return key to perform the search as well as the Search button does. The search button ("Søg") works nicely, but the Return key return nothing and it seems thar it is actually resetting the page.

Hoping that somebody can guide me in the right direction I paste in a little code here below.

I have this form:
<form action=""  id="search2" form title="Skriv evt. bare en del af det sted du søger, eller brug % som jokertegn når du søger bredt. Hvis du søger eksakt skal du skrive det eksakte navn på det du søger" style="padding-top:10px; padding-bottom:10px;" method="POST" >

         <input type="search" id="input_1" placeholder= "Søg" style="width: 300px; height: 35px; border: 1px solid #666666;border-radius:2px;color:#666666; color: #9F5584; font-weight: ligther; font-size: 13px; padding-left:10px;" name="query"  />

         <input type="button" submit title="Klik her, eller tast Enter, for at aktivere søgningen." style="margin-left:15px; padding-right:10px;height:30px;font-family:arial; font-size: 12px; text-align:left; background-color:#cccccc; border: 2px solid #grey;border-radius:2px; color:black; background-color:#cccccc; box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);" name="soeg" 

Open in new window

0
I have a Linux server and I would like a PHP script to monitor a list of websites to check if they are active. For example I would like to check for any websites returning a 500 internal server error. Upon detecting this error I would like an email and SMS notification sent.

I understand the script needs to be called either by a CRON job or internal scheduler on a regular basis such as every 5 minutes.

I wish to reiterate that the websites being monitored are hosted externally on a Windows server but a Linux server will be used to do the monitoring.
0
Why I'm always getting warning: Natalie_query() expects parameter 1 to be mysqli, null given in c:\xampp\htdocs\view\dokumen.php on line 57
0
when i pass array how can i get input value in php

$value1=$resultpackages['Package_Price'];
                    $value2=$resultmarkup['markup'];
                    $value3=($value1*$value2)/100;
                    $value4=$value1+$value3;
                    $downname1=$_POST['downloadname'];

                    $priceid=$resultpackages['package_id'];
                    $pricevalue=$value4;
                    $price = array("$priceid","$value2","$value3","$pricevalue","$downname1");

                    $TP = json_encode($price);
                    $RequestTP = urlencode($TP);

Open in new window


the problem is downname1 is empty how i can do
0
I have extracted the data from a website and filter it but unable to format it properly , Shall be thankful if someone can help

All required files are attached herewith.

I am new in regex and dom use.
folder.zip
0
Hi everyone, I have been wondering how to convert any exception to SoapFault. Let's say I have this:

<?php
class MyClass
{
    public function operation1($p1, $p2)
    {
        throw new Exception('ERROR',1);
        return true;
    }
    public function operation2($p1, $p2)
    {
        throw new SoapFault('001','ERROR',null,'',' ');
        return true;
    }
}  
$soap = new SoapServer();
$soap->setClass('MyClass');
$soap->handle();
?>

Open in new window


If I call "operation2", I will get a SoapFault, which is what I expect, however, if I call "operation1" I will get uncaught exception message.
So far I have tried this dirty fix, which is working. But this is what I want to achieve:

try
{
$soap = new SoapServer();
$soap->setClass('MyClass');
$soap->handle();
}
catch(SoapFault $e)
{
  //it is never caught
}
catch(Throwable $e)
{
   echo sprintf('<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>%s</faultcode>
         <faultstring>%s</faultstring>
         <detail>%s</detail>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>','000',$e->getMessage(),'');
}

Open in new window


Does anyone if this can be done and how?
0
Hi,
I have a datatables table I am using to allow a person to resort the row order of the slides (see attached as example). In my mysql table I am using an additional column to set the row order of each row.
So essentially in mysql I have
id - primary auto increment
SlideOrder - I am using for the sequence
SlideTitle
and a couple created/modified datetime etc.

 
table example
When the user drops a row into place the code I'm using is below to send to server ( I start getting sketchy here on in):

oTable.on( 'row-reorder', function ( e, diff, edit ) 
{
var result;
var sendloop = [];
 		
	for ( var i=0, ien=diff.length ; i<ien ; i++ )
	{
		var rowData = oTable.row( diff[i].node ).data();
		result = ''+diff[i].newData+','+diff[i].oldData+'';
		sendloop.push(result);
	}
        	
	var jsonString = JSON.stringify(sendloop);
   
$.ajax({
        type: "GET",
        url: "/dealboxx/ohs/admin/sort",
        data: {data : jsonString}, 
        cache: false
    });
    });

Open in new window


The result of which sends an ajax request and the data variable (when I drag row 1 below row 4 for example):
data["1,2","2,3","3,4","4,1"]

Had I dragged row 2 below row 3 initially I'd be sending:
data["2,3","3,2"]

Had I dragged row 3 in front of row 1:
data["1,3","2,1","3,2"]

When the data gets to my server (my wrong code) does this:
public function sortCourse(Request $request)
    {
	$obj = json_decode($request->input('data'), true);
	
	foreach($obj as $row)
	{
     
		$insertArray = explode(",",$row);
		
		$slidechange = DB::table('ohs_courses_content')
			->select('id')
			->where('SlideOrder',$insertArray[1])
		    ->first();
		
    
	DB::table('ohs_courses_content')
            ->where('id', $slidechange->id)
            ->update(['SlideOrder' => $insertArray[0]]);
 	 	}
	
    
    }

Open in new window


Depending on what I initially dragged it may work (if I'm dragging down or up). Couple drags into it and its a mess.

So my logic etc is no doubt totally wrong.

any help would be very much appreciated as always.
tj
0
Hi EE.

How can one get a control value like on a textbox get it value and set the button id to that value from textbox and for dropdown get the selected item value and set that value to a button id when clicking that button in php or html?
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!

<?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){
                 //insert member data into database
                    $db->query("INSERT INTO nov(f_name,name, cpu_count, memory_size, disk_space_size, nic_count, power_state) VALUES 

Open in new window

0
<?php include 'dbConfig.php';
 
       
      //$res=mysqli_query($db,"Select f.fname,f.sname,f.mail,f.num,f.gen,s.tadd,s.padd,s.amail,s.anum,s.status from first f,second s ");
        $sql2 = "Select f.fname,f.sname,f.mail,f.num,f.gen,s.tadd,s.padd,s.amail,s.anum,s.status from first f,second s";
               

                  $result2 = mysqli_query($db, $sql2) or die("Error: ".mysqli_error($db));
                 
echo "<tr><td colspan='5'></td></tr>";
             while($row = mysqli_fetch_array($result2))  
                          {  
                               echo '  
                               <tr>  
                                    <td>'.$row["f.fname"].'</td>  
                                    <td>'.$row["f.sname"].'</td>  
                                    <td>'.$row["f.mail"].'</td>  
                                    <td>'.$row["f.num"].'</td>  
                                    <td>'.$row["f.gen"].'</td>  
                                    <td>'.$row["s.tadd"].'</td>  
                                    <td>'.$row["s.padd"].'</td>  
                                    <td>'.$row["s.amail"].'</td>  
                                    <td>'.$row["s.anum"].'</td>  
                                    <td>'.$row["s.status"].'</td>  
                                     
                                     
                               </tr>  
                               ';  
                          …
0
<?php include 'dbConfig.php';
 ?>
        <div class="table" style="display: <?php echo isset($_POST['find']) ? "none" : "block" ?>">

        <table class="table table-bordered table-striped msg-reports-table" id="table" display="">
        <tr>
          
        </tr> 
        <?php
      //$res=mysqli_query($db,"Select f.fname,f.sname,f.mail,f.num,f.gen,s.tadd,s.padd,s.amail,s.anum,s.status from first f,second s ");
//echo $$sql1="select f.fname,f.sname,f.mail,f.num,f.gen,s.tadd,s.padd,s.amail,s.anum,s.status from 
// ( SELECT 
// * first from to_numbers
//  ) f left outer join
//   ( SELECT 
// *  from second  
//    ) s";res;

//      
$res=   mysqli_query($db,"Select * from first UNION select * from second ");
        echo "<tr><td colspan='5'></td></tr>";
             while($row = mysqli_fetch_assoc($res))  
                          {  
                               echo '  
                               <tr>  
                                    <td>'.$row["f.fname"].'</td>  
                                    <td>'.$row["f.sname"].'</td>  
                                    <td>'.$row["f.mail"].'</td>  
                                    <td>'.$row["f.num"].'</td>  
                                    <td>'.$row["f.gen"].'</td>  
                                    <td>'.$row["s.tadd"].'</td>  
                                    <td>'.$row["s.padd"].'</td>  
                                    <td>'.$row["s.amail"].'</td>  
                             

Open in new window

0
Hi

Currently I am using CKPlayer for my video in the website.
But in the source code, it showed all the video url.
Is there a method to hide them?
Thank you



<div class="g-sectionWrap">
<div class="section">
<div class="m-vod">
<div class="title">Video Title</div>
<div class="playbox">
<div id="playbox" style="background-color: rgb(0, 0, 0); width:

962px; height: 400px;"><video controls=""
src="http://www.xxx.com/video/firstvideo.m3u8" id="ckplayer_a1"
width="100%" height="400" autoplay="autoplay"></video></div>

<script type="text/javascript">
var flashvars={
f:'http://www.xxx.com/video/ckplayer/firstvideo.swf',
a:'http://www.xxx.com/video/firstvideo.m3u8',
c:0,
s:4,
h:3,
p:1,
i:'',//
};
var video=['http://www.xxx.com/video/firstvideo.m3u8'];


if(navigator.userAgent.indexOf('Mobile')>0||navigator.userAgent.indexOf('Pad')>0){

var html5first = true;
}else{
var html5first = false;
}
CKobject.embed('http://www.xxx.com/statics/building/js/video/ckplayer/ckplayer.s
wf','playbox','ckplayer_a1','100%','400',html5first,flashvars,video)

</script>
</div>

Open in new window

0
So this one is about the weirdest thing I've ever seen, but let me try to explain. I have a web page set up with multiple accordions (like these, I used this exact code): https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_accordion_symbol.

Inside each of those accordions is a grid layout, like this one: http://www.marcorpsa.com/ee/t2716.html

Inside each grid are two inputs (uniquely named across the entire page - no repeats). When I submit the form, none of them are submitting their updated values, except for the inputs in the grids in the last accordion. If I do a var_dump($_POST), I see where the inputs are being submitted, but they don't reflect any values that were put in by the user into them (they're just submitting whatever was in them when the page loaded).

Does anyone have any ideas why this could be happening and what in the world to do to fix?
0
please answer my very first question
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.