Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x

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 have created a PHP page that interrogates an SQL server returning an array.

I need to restrict access to certain users/groups with in active directory. I have achieved this using Authorisation rules within iis, however by turning off allow anonymous users.

I get the following message

Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. ) [1] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. ) )
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 storm is giving me the error message unused local variable, overwritten immediately.

<?php
/*FInd fifth_number - private method*/

  function get_number_root($root) {
      switch($root) {
          case 'A':
              $number = 1;
              break;
          case 'A#':
              $number = 2;
              break;
          case 'Bb':
              $number = 2;
              break;
          case 'B':
              $number = 3;
              break;
          case 'C':
              $number = 4;
              break;
          case 'C#':
              $number = 5;
              break;
          case 'Db':
              $number = 5;
              break;
          case 'D':
              $number = 6;
              break;
          case 'D#':
              $number = 7;
              break;
          case 'Eb':
              $number = 7;
              break;
          case 'E':
              $number = 8;
              break;
          case 'F':
              $number = 9;
              break;
          case 'F#':
              $number = 10;
              break;
          case 'G':
              $number = 11;
              break;
          case 'G#':
              $number = 12;
              break;
          case 'Ab':
              $number = 12;
              break;
          default:
              die('error');
              return $number;
      }

      $number = get_number_root($_POST['root']);
  }
?>

Open in new window

0
I need to find a suitable Geofencing API for an IOT project that I'm working on (either free or otherwise).  

There are supposedly some 3rd party API's available that support geofencing, and I need to find something that's fairly robust/capable.  I just don't exactly know where to begin, since everything I've come across so far appears to be IOS or Andriod specific .. which doesn't apply to what I'm doing.  

What I'm envisioning is something similar to the following (please forgive my pseudo code):

// Load CurrentLocation with the latitude & longitude of the most recent location of IOT Device1
Device1 = getLocation(Device1);  

// Defines a geofence in the geofencing service
Fence1 = APIcallCreateFence(Fence1, polypoint1, polypoint2, polypoint3,...);  

// Query the API to see if the given location is inside the specified fence
isInFence = APIcallQueryFence(Fence1, Device1);  

Open in new window


Can anyone here recommend a suitable API for this?  My preference is for PHP or Javascript based if it's a downloadable library ... but the language isn't important if it's an externally hosted API.

Thanks in advance,
- Yvan
0
Hi Experts,

I am trying to write a very simple plugin for my client, and this is my first plugin, but cannot figure out how to submit from within /wp-admin?

As a test , I put together the following, but when I submit I get 404 Error. I see this is because the submit action is looking for .../wp-admin/admin-submit.php where admin-submit.php is in my plugins folder, but if I submit directly to it, I know I will get out of the wp-admin structure.  Do I need to doeverythign in iFrame or how do I handle this properly?

aces-test.php
<?php
/**
Plugin Name: Aces Test
Plugin URI: https://www.aces-project.com
Description: This is my <b>Plugin</b> description.
Version: 1.0.0
Author: Aleksandar Poposki
Author URI: https://www.aces-project.com
**/

function wp_add_menu(){
//    add_menu_page('ACES Page Title', 'ACES Options', 'manage_options', 'aces_plugin', '', 'dash-email-alt');
    $admin_page = 'admin-form';
    add_menu_page(
        'Custom Menu Title',
        'custom menu',
        'manage_options',
        $admin_page, 'aces_admin',
        '');
}

function aces_admin(){

    require_once 'admin-form.php';

}

function aces_activate(){
    //Create WP-Admin Page
    
    //echo 'ok';
}

// Activate
register_activation_hook(__FILE__, 'aces_activate');
add_action('admin_menu', 'wp_add_menu');   

function aces_shortcode(){
    $disp = "ACES <b> plugin </b> from nnethbeans.";
    return $disp;
}
add_shortcode('aces-plugin', 'aces_shortcode');
?>

Open in new window


admin-form.php
<?php
/*echo '<div id="divAdmin" style="display:inline-block;  height: 500px; background-color: yellow">
    xxxxxxxx
</div>';*/
?>
<div id="divAdmin" style="display:inline-block;  height: 500px; background-color: yellow">
    <form action="admin-submit.php" method="post">
        name: <input type="text" name="txtName">
        <input type="submit">
    </form>
</div>

Open in new window


admin-submit.php
<?php

$name = $_POST['txtName'];
echo 'Are you sure your name is ' . $name . '?';

Open in new window


Any help will be greatly appreciated.
0
We are currently running a laravel 5.3 site using php 5.6 and would like to use caffeine for those users who insist on leaving forms open  on their devices for extended periods of time.
Unfortunately, it seems that the only version of caffeine I can find to install requires php 7.0, which we will not be prepared to upgrade to for some time.
Does anyone have a workaround?
Thanks!
0
I have an AJAX Call that runs a function and it all works,  However, it does it does not return the Success message.  My code.
<html>
 <form id="unjoin" method="post">
                    <input id="email" name="email" type="hidden" value="<?php echo $unsub; ?>" />
                <input type="submit" name="submit" id="submit" value="Click Here To Unsubscribe">
                </form>
            </div>
            <div id="unsubscribe_bye" class="unsubscribe_bye">

            </div>

<script>
<script>
    $(document).ready(function () {
        $("#unjoin").on('submit', function (e) {
            e.preventDefault();
        });
        $("#submit").click(function () {

            $.ajax({
                url: 'includes/unsubscribe.php',
                data: $("#unjoin").serialize(),
                type: 'POST',
                dataType: 'JSON',
                success: function (response) {
                    $("#unsubscribe_bye").html(response.success);
                    console.log(response);
                    $("#unjoin")[0].reset();
                }
            });

        });
    });
</script>

<?php
$success = "";
$return = new stdClass;

$e = $_POST['email'];

$sql = "SELECT subscriber_id AS subscriber_id FROM test_table WHERE email = :email";

$pdos = $pdo->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));

$pdos->bindParam(':email', $e, PDO::PARAM_STR);

try {
    $pdos->execute();
    $rows = $pdos->fetch();
    $num = 

Open in new window

0
Wordpress whenever I try to approve multiple comments it gives me err connection reset. Started happening after wordpress upgrade.
0
I am storing my cart session array into a cookie like this:

$cart_cookie = serialize($_SESSION['cart_array']);
$cookie_name = "cart";
$cookie_value = $cart_cookie;
$cookie_expire = time() + 86400 * 30;
$cookie_path = "/";
$cookie_domain = "";
$cookie_secure = false;
$httponly = true;
setcookie($cookie_name, $cookie_value, $cookie_expire, $cookie_path, $cookie_domain, $cookie_secure, $httponly);

Open in new window


I then unserialize() it when I want to access it and it seems to work fine. I just wanted to know though if doing it like this is okay or if I need to do it in a different way?
0
Thank you for looking at my question,

I have a php form to which the user keys data in some areas and scans qr codes in others. There is some javascript manipulation and/or input validation for most of the input text boxes - is the input value in the correct numerical range, breaking the scanned value down into component parts and writing the data to the appropriate fields, that kind of thing.

All of this functionality has been working as expected until I added some final validation  - jsValidate() - to the forms OnSubmit event at which point all previous functionality stops working. The code below shows the jsValidate() function commented out which enables the other functionality to work but as soon as I comment it back in the other stuff stops working again.

Why is the OnSubmit event overriding the other functionality and how do I prevent it get the two sets of functions working perfect harmony?

php form:
echo '<form name="AssUpdate" action="'.$action.'" method="POST" onSubmit="return jsValidate()">';
	echo '<input type="hidden" name="ProdnOrder" id="ProdnOrder" value="'.$ProdnOrder.'"/>';
	echo '<input type="hidden" name="Meter" id="Meter" value="'.$Meter.'"/>';
	echo '<input type="hidden" name="StageNo" id="StageNo" value="'.$StageNo.'"/>';
	echo '<input type="hidden" name="StageName" id="StageName" value="'.$StageName.'"/>';
	echo '<input type="hidden" name="TubeAssNo" id="TubeAssNo" value="'.$TubeAssNo.'"/>';
	
	echo '<input type="hidden" 

Open in new window

0
I am using a text box to insert data in to a backend database
The problem is that even if I add breaks when I am typing the text is entered as a complete string with no breaks when viewed in a php page
Can someone please tell me where I am going wrong
0
Important Lessons on Recovering from Petya
LVL 10
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Hi,

After migrate Drupal 8.1 to 8.3.7, this error is shown at web site :


The website encountered an unexpected error. Please try again later.

At apache 2.4 error, I can see this:

 [Thu Sep 21 21:30:38.185852 2017] [proxy_fcgi:error] [pid 22862:tid 139697256294144] [client xxxxxxxxx] AH01071: Got error 'PHP message: PDOException: SQLSTATE[HY000] [2002] Connection refused in /volume1/web/drupal/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php on line 79 #0 /volume1/web/drupal/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php(142): PDO->__construct('mysql:host=127....', , Array)\n#1 /volume1/web/drupal/core/lib/Drupal/Core/Database/Database.php(376): Drupal\\Core\\Database\\Driver\\mysql\\Connection::open(Array)\n#2 /volume1/web/drupal/core/lib/Drupal/Core/Database/Database.php(166): Drupal\\Core\\Database\\Database::openConnection('default', 'default')\n#3 [internal function]: Drupal\\Core\\Database\\Database::getConnection('default')\n#4 /volume1/web/drupal/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php(79): call_user_func_array('Drupal\\\\Core\\\\Dat...', Array)\n#5 /volume1/web/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\PhpArrayContainer->createService(Array, 'database')\n#6 /volume1/web/dr...\n'


I run MariaDB10 and PHP 5.6

Any ideas?

Regards
0
This code only shows one of the pagination links as active if I click on it first. But on page load I want number "1" to be active by default. If I go to page 2, the 2 shows as active. If I then click on 1 and go back t to page 1, then 1 shows as active but only because 1 is now in my url string. But on initial category page load when there is no page number in the url, nothing is set as active but I want 1 to show as active and not clickable.

$page = !empty($_GET['page']) ? $_GET['page'] : 1;

or ($page = 1; $page <= $number_of_pages; $page++) {
    if ($_GET['page'] == $page) {
        echo "<li class='pagination__page--active'><span>{$page}</span></li>";
    }
    else {
        echo "<li><a href='product-category/$page_url/page/{$page}'>{$page}</a></li>";
    }
}

Open in new window

0
Hi,

 mysql_connect()  not work in php version 7,Am manually install mysql in my pc,It's successfully install but still showing the errors,
How to run mysql_connect in php 7?Is it possible to run?
0
Hello Experts,

I am working on a small website that allows users to send a vCard (.vcf file) to an email address they specify. The coding for this function is in php, and I should mention that my php skills are pretty basic. There are 2 versions of the email that sends the vCard: one in English and one in Japanese.
So far, everything is working fine, except that on Android smartphones, the Japanese characters in the subject line of the email get mangled (the body text is fine). It is obviously a character encoding issue.
Researching the issue on google indicates that I need to specify the character encoding for the subject text (in the case of Japanese, I think this would be UTF-8). I have tried a number of things to achieve this, but just cannot get it to work.
I provide the code as an attached file. I’d greatly appreciate it if anyone could have a look at this and let me know of any suggestions for a solution to this. Thank you in advance for any help.
qr-send.php
0
How much experience is required to get hired as a back-end developer or Python,PHP and Ruby.But now i'm looking for php experience.or How i can earn $1500 per month with PHP.
0
Hello there,

I have a question. I'm using magento 1.9 and I have a problem to figure out how to menage and solve this problem.

Basically, I have one product. Inside this product, I want to put another product with the quantity selection too. Right now, I made my page and I load a product with the basic custom options -> chechbox. This works fine, but I would like to give the options to the costumer to select two different quantity.

Think about a ticket, you can buy 4 ticket but just for 2 you want the special options.

I also tried the grouped products. But I don't want to make 3 product every time (one grouped product, one specific ticket, and the one special option). If I do this, I should make one grouped product and maybe I will load dynamically by id the two products in the page. So that, I will have one grouped products for all the products that I want to use with this options.

So, because I'm making my own phtml page, I'm looking if there is any specific code to put the checkbox options manually inside with the quantity too. The ticket will change, but this options would be static.

Ex: show_product.phtml

<?php

$_GET["event"];
$sku = $_GET["event"];

 $vPath = $sku.".html";
 $oRewrite = Mage::getModel('core/url_rewrite')
 ->setStoreId(Mage::app()->getStore()->getId())
 ->loadByRequestPath($vPath);

  $iProductId = $oRewrite->getProductId();
  $oProduct = Mage::getModel('catalog/product')->load($iProductId);

  $id = $iProductId;

  //get id 

Open in new window

0
I am using CANNY INFOTECH SMS API . I want to send sms from Hubspot CRM to push sms via this http sms api.

if any one can help me it will be great. we want to send followup messages via SMS, this is PHP SMS API
0
Hey, guys!

Here's a snippet from a page called "user.class.php:"

 function updateDevices() {
        global $S;
        global $CN;
        date_default_timezone_set('America/Chicago');
        $maxHistory = date('Y-m-d',strtotime("now - 2 weeks"));
        $R = new xajaxResponse();
        $fitBitCalls = array( '/1/user/-/body/weight/date/'.date('Y-m-d').'/'.$maxHistory.'.json',
        '/1/user/-/body/fat/date/'.date('Y-m-d').'/'.$maxHistory.'.json',
        '/1/user/-/body/log/weight/goal.json',
        '/1/user/-/body/log/fat/goal.json',
        '/1/user/-/activities/steps/date/today/max.json',
        '/1/user/-/activities/calories/date/today/'.$maxHistory.'.json',
        '/1/user/-/activities/distance/date/today/'.$maxHistory.'.json',
        );
        //See if this user any devices that have not been synced.
        $stmt = $CN->prepare("SELECT * 	FROM hraUserDevices  UD INNER JOIN hraUserDeviceTypes UT  ON UD.udtID = UT.udtID  WHERE usrID = ? AND (DATEDIFF(day,udFetchedLastDate,getdate()) IS NULL OR DATEDIFF(day,udFetchedLastDate,getdate()) >=1) AND (udUpdating IS NULL  OR udUpdating !=1 OR DATEDIFF(day,udFetchedLastDate,getdate()) >=2)");
        $stmt->execute(array($S->usrID));
        $devices = $stmt->fetchAll();
        $update = $CN->prepare("UPDATE  hraUserDevices SET udUpdating = ? WHERE udID = ? ");

Open in new window


The question I have is, "What is $CN?"

Obviously, it's a database connection. My problem is that it's not defined anywhere on the page, nor is EVER defined that I can see anywhere in the app.

You do, however, have this at the top of the same page:

	private $cn; // $cn = VARIABLE HOLDING THE DB CONNECTION

	function __construct(PDO $conn) {
		if (!isset($conn))
			throw new Exception('User objects must be passed a PDO Connection object ($this->cn) upon construction');
		$this->cn = $conn;
	}

Open in new window


Is there a convention that I'm missing? $CN is not equivalent to $cn, and yet throughout the entire app you see repeated references to $CN but I can't find anywhere that $CN is actually defined.

Any ideas?
0
Hi i've got a database table (user_group_join) with the following tables:

    user_group_join_id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
    user_join_id int(11) NOT NULL,
    group_join_id int(11) NOT NULL,
    FOREIGN KEY (user_join_id) REFERENCES users (user_id),
    FOREIGN KEY (group_join_id) REFERENCES user_group (group_id)

They are populated as follows:

user_join_id = 75
group_join_id = 12
user_join_id = 75
group_join_id = 13
user_join_id = 75
group_join_id = 14

What i need to do is when performing a insert query if for example I change the value 12 from group_join_id to 13 i should only have:

user_join_id = 75
group_join_id = 13
user_join_id = 75
group_join_id = 14

This is my php code, i'm deleting the value first and then add the new one if it is not already stored in the database:

$delete_join_group = mysqli_prepare($conn, "DELETE FROM user_group_join WHERE user_join_id=? AND group_join_id=?");
mysqli_stmt_bind_param($delete_join_group, 'ii', $client_id, $old_group_id);
mysqli_stmt_execute($delete_join_group);
mysqli_stmt_close($delete_join_group);

$new_join_group = mysqli_prepare($conn, "
INSERT INTO user_group_join (user_join_id, group_join_id) 
SELECT ?, ? FROM user_group_join 
WHERE NOT EXISTS (SELECT user_join_id, group_join_id FROM user_group_join 
      WHERE user_join_id=? AND group_join_id=?) 
LIMIT 1 ");
mysqli_stmt_bind_param($new_join_group, 'iiii', $client_id, $new_group_id, $client_id, $old_group_id);

Open in new window

0
Concerto's Cloud Advisory Services
LVL 4
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Hi I have below Table

UsersTable

UserId   Contact

A                mobile
B                 email



The user will upload CSV file having about 100- 200 userid and contact details  

After uploading the csv file ,The data should not insert into table if the userid is already exists in the Table .
0
Hi, I am using bootstrap treeview , I would like to know how I can add node dynamically at run time. means users should able to add any node.

any help will be highly appreciated.

Regards,

Aamir
addNodes.png
0
The problem i am having in alignment of input and select fields. html and css code is attached. I am having hard time for resolving this as i am beginner in css learning.

Select fields for choosing time       from    [hour] [minutes]              to     [hour][minutes]  should be easily understood by user. right now it is not so.
Page is divided into two parts  - > left and right side.  left side's width is 60% and right side's is 40 %.

Form is in the left side. (which is to be consider)
select.php
capture18.PNG
0
please provide the php code with mysql query to hide the message in an image using steganography
0
Going through a tutorial on PHP Symfony and at one point it suggests setting up a git repository. Here's my CLI sequence...

screenshot
This is supposed to be cake and ice cream. Navigate to the home directory, enter "git init" and then, BOOM.

Instead I get an error that says "the git command is not recognized..."

What am I missing?
0
I created two apps one app have full access and another have folder permission access only
now when I use generated token from full access permission the php API download file working fine
but when I use the generated token from folder permission the api return status code 404 ?

Any help would be great.
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.