Celebrate 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 suddenly can't seem to access my local websites on my Mac via MAMP. My ddns.log file contains the following:

mamp_dyndns[41389:21445531] DynDNS: [no update] empty username and/or password

Open in new window


I do have my DynDNS username and password stored properly in the MAMP interface, and my DynDNS account is in good standing and is configured as it's always been.

Any help on figuring this out would be appreciated.

Thanks,
Jon
0
Free Tool: Port Scanner
LVL 10
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.

Is it possible to bypass the need for a LAMP server (LAMP = the Linux operating system, the Apache HTTP Server, the MySQL relational database management system (RDBMS), and the PHP programming language)?

I am looking for a way to simply put some files on a file share for a specific group and let everyone have access to whatever is required to run the application, but without having access to a full LAMP server.

Can writing php files that conform to newer standards accomplish this?  If not, is there any way to accomplish this without any installs?
0
Hello!

I have a PHP script that should create a valid image file on server side. The following code runs fine:
$filename = $_GET['filename'];

// Only proceed if we got valid input
if ($filename !== null) {
    echo "$filename is not null.";
    $image = @imagecreatetruecolor(10, 10)
                or die('Cannot Initialize new GD image stream');

    if (strpos($image, '/gif') !== false) {
        $image_type = "GIF";
        header('Content-Type: image/gif');
        $successful = imagegif($image, "./$filename");
    } else if (strpos($image, '/jpeg') !== false) {
        $image_type = "JPG";
        header('Content-Type: image/jpeg');
        $successful = imagejpeg($image, "./$filename");
    } else if (strpos($image, '/png') !== false) {
        $image_type = "PNG";
        header('Content-Type: image/png');
        $successful = imagepng($image, "./$filename");
    }

    if ($successful) {
        echo "Image written to '$filename'.";
    } else {
        echo "Could not write $image_type image to '$filename'.";
    }
    imagedestroy($image);
    echo "image destroyed.";
} else {
    echo "$filename is null.";
}

Open in new window


This works fine & an image with the $filename is created. But actually, I do not only receive the file name but the image content as well. So, the real code is

$filename = $_GET['filename'];

$image = $_GET['image'];

// Only proceed if we got valid input
if ($filename !== null) {
    echo "$filename is not null.";
    $image = base64_decode($image);
    $slash1 = strpos($image, '/');

    $image_type = substr($image, $slash1, strpos($image, ';') - $slash1);

    if (file_exists($filename)) unlink($filename);

    header('Content-Type: image/' . $image_type);

    switch ($image_type) {
        case "gif":
            $successful = imagegif($image, "./$filename");
            break;
        case "jpeg":
        case "jpg":
            $successful = imagejpeg($image, "./$filename");
            break;
         case "png":
            $successful = imagepng($image, "./$filename");
            break;
    }
    if ($successful) {
        echo "Image written to '$filename'.";
    } else {
        echo "Could not write $image_type image to '$filename'.";
    }
    imagedestroy($image);
    echo "image destroyed.";
} else {
    echo "$filename is null.";
}

Open in new window


But still, I get the reply Could not write image to 't.jpg'. Can you see my error(s)?
0
Hello

I have an Order HTML page where a User can enter data into fields.  On Submit PHP file is used to write the data to SQL Tables called Orders and Orders_details.

Currently, when l test this I'm getting the below error.
Capture.JPG
Below is my PHP file:
If you need table structures I can provide these too.

The line error is highlighted below.
Capture.JPG===================

<!DOCTYPE HTML>
<html>
<head>
<title>Product_Order</title>
<meta charset="utf-8">

</head>
<body>

<?php

  /* Set oracle user login and password info */
  $dbuser = ;  
  $dbpass = ;  
  $db = ;
  $connect = oci_connect($dbuser, $dbpass, $db);

   /* Display connection error if fails */
  if (!$connect)  {
    echo "An error occurred connecting to the database";
    exit;
  }

  //Extract CGI variables
  $productitem = $_POST['productitem'] ;
  $price = $_POST['price'] ;
  $quantity = $_POST['quantity'] ;
  $firstname = $_POST['firstname'] ;
  $lastname = $_POST['lastname'] ;
  $address = $_POST['address'] ;
  $phone = $_POST['phone'] ;
  $email = $_POST['email'] ;
  $creditcard = $_POST['creditcard'] ;


  // count the record in orders table and use id number $count+1 for the new record
  $query_count = "SELECT max(ID) FROM Orders";

  echo "SQL: $query_count<br>";

  /* check the sql statement for errors and if errors report them */
  $stmt = oci_parse($connect, $query_count);

  if(!$stmt)  {
    echo "An error…
0
Hello,

I have the below search field in my HTML file.

Capture.JPG
This is connected to a PHP file on Submit.

If the User clicks on 'Search' only, without entering any data, I want all data to be displayed.
Currently, it will only display data it you enter at least one character.

Here is my SQL Select Query within my PHP file.

$query = "SELECT * FROM Products WHERE regexp_like(Title,'$book_name','i')";
0
Hello Experts,

This post is more or less to pick your brain about things/ideas I should implement into my current system. Basically, the only requirement for my system was turn my employer's paper-based car seat rental program into a paperless system.

Here are screenshots of my system:

Index.php
Index.php
Rental-form.php
Rental-form.php
Rent-success.pdf

(See attached PDF)

Return-form.php
return-form.php
Right now, the system does the following:
  1. Presents the user (coworker) with a choice to either rent or return a car seat;
  2. Provides an inventory of any available seats (from a MySQL database);
  3. Generates a PDF version of our current rental agreement using FPDF;
  4. Emails the generated PDF to the renter and another department in my office (not implemented yet); and
  5. Presents the user with an HTML table in order to return any rented car/booster seats.

Being that I am a hobbyist php programmer, I am kind of in the dark when it comes to certain things. My career has nothing to do with programming, either. I enjoy PHP and took this task upon myself for fun.
rent-success.pdf
0
I have a form with validation when the page loads I get this error (developers tools)

menu.js:89 Uncaught TypeError: Cannot read property 'left' of undefined
    at HTMLDocument.<anonymous> (menu.js:89)
    at j (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at Function.ready (jquery.min.js:2)
    at HTMLDocument.J (jquery.min.js:2)
(anonymous) @ menu.js:89
j @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
J @ jquery.min.js:2

The page is:

http://hospitalesmx.com

I can figure out what the problem is
0
using email version4 app on android7
i mark hostupon hosted linux php email as spam but same senders keep sending email
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 have seen a few questions like this and variations of this but I am still confused as how to go about doing this. I have different dealers in different regions and want to list them by region in one long list.

West Coast
dealer 1
dealer 2
dealer 3

East Coast
dealer 1
dealer 2
dealer 3

And so on...

I have a database table with a list of regions and another table with a list of dealers.

The dealer table has a column which contains the region id from the regions table so I can join the tables.

I tried this:

$stmt = $link->prepare("SELECT `region_name`, `dealer_name` FROM `dealer_region` as `dr` INNER JOIN `dealers` as `d` ON dr.`id` = d.`region_id` GROUP BY `region_name`");
$stmt->execute();
$result = $stmt->get_result();
$numRows = $result->num_rows;
if($numRows > 0) {
    while($row = $result->fetch_assoc()) {
        $dealer_name = $row['dealer_name'];
        $region_name = $row['region_name'];
        echo $region_name . "<br />" . $dealer_name . "<br />";
    }
}

$stmt->close();

Open in new window


But this only results in one dealer being shown under each region instead of all.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 4
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.

is this a php script?how to use it? is for creating a source.txt

<?php
$ips = $_POST['ips'];
$users = $_POST['users'];
function rand_string( $length ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen( $chars );
for( $i = 0; $i < $length; $i++ ) {
$str .= $chars[ rand( 0, $size - 1 ) ];
}
return $str;
}
$key = rand_string(8) . ".txt";
$fh = fopen($key, 'w') or die("can't open file");
$ips=explode("\n", $ips);
$users=explode("\n", $users);
foreach($ips as $ip){
foreach($users as $user){
$string= $ip.":".$user;
$string = preg_replace('/\s+/', '', $string);
fwrite($fh, $string);
fwrite($fh, " \r\n"); }}
$print = "Done! Poti sa descarci fisierul sursa si sa il adaugi in dubrute <a href=http://hiphopize.me" . $key . " >Click</a>";
echo $print;
?>

Open in new window


<html>
<head><title>RDP_SRCBuilder</title></head><center>
<body><form method="POST" action=create.php>Ips:<textarea id="ips" name="ips" cols="40" rows="15"></textarea>Users:<textarea id="users" name="users" cols="40" rows="15"></textarea><br><input type="submit" value="Show them all!"></center><br>
</body></html>

Open in new window

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
I have a project to enrol my students  using biometric fingerprint scanner. my app is develop in php. how can achieve that?
0
I have a Wordpress Loop that Generates names from a query.  However, sometimes the name is repeated.  I only want to show the name once.  Is there anyway to limit this?

<?php
  $args = array(
                    'posts_per_page' => -1,
                    'post_type' => 'post',
                    'category_name' => $alias,
                    'meta_key'	=> 'Athlete Name',
                );
                $wp_query = new WP_Query($args);
 <ul>
                        <li class="show-all">
                            All
                        </li>
                        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                                <?php
                                $key_name = get_post_custom_values($key = 'Athlete Name');
                                $keyname = $key_name[0];
                                ?>

       
                                <!--  START Custom Player Menu  --> 

                                <li class="<?php echo $keyname; ?>">
                                    <?php echo $keyname; ?>
                                </li>     
                                <!--  END Custom Player Menu  --> 
                                <?php
                            endwhile;
                        endif;
                        ?>
                    </ul>

Open in new window


So if that list generates a list of 10 names and John Doe appears twice, I only want that name to appear once. Is it Group BY and how do you add that into a Wordpress Query?
0
I have links on my homepage:
Home page of website

I am trying to get the link to open in a page with the same layout without having to recreate the layout.
I can not find any tuts on how to make the layout the default.
A post inside the page opens as such
default layout

Any help is appreciated.
0
This isn't very critical since it is allowing me to still get the result I am looking for, but it still bothers me.

I have the following php function (the $runnumber and echo statements were added to follow the flow, they will be removed):
function verifydate($dueDate,$length,$runnumber) {
  echo "Run number: " . $runnumber . "<br>";
  echo "Current due date: " . $dueDate . "<br>";
  $dayName = strftime("%A", strtotime("$dueDate"));
  echo "Current day of week: " . $dayName . "<br>";
  if ($dayName == "Saturday") {
    $length = $length + 2;
    $dueDate = date("Y-m-d", mktime(0, 0, 0, date("m"),date("d")+$length,date("Y")));
    echo "Since the day is Saturday, adding 2 more days to the due date and checking again.<br><br>";
    $runnumber = $runnumber + 1;
    verifydate($dueDate,$length,$runnumber);
  }
  if ($dayName == "Sunday") {
    $length = $length + 1;
    $dueDate = date("Y-m-d", mktime(0, 0, 0, date("m"),date("d")+$length,date("Y")));
    echo "Since the day is Saturday, adding 1 more day to the due date and checking again.<br><br>";
    $runnumber = $runnumber + 1;
    verifydate($dueDate,$length,$runnumber);
  }
  $conn2 // a connection to my database.
  $sql = "SELECT dayID FROM excludedDays WHERE excludedDay = '$dueDate'";
  $result = $conn2->query($sql);
  echo "Since the day is not on a weekend, checking to see if it is an excluded day using the MySQL query:<br>";
  echo $sql . "<br>";
  echo "Which returned " . $result->num_rows . " result.<br>";

Open in new window

0
Hi experts, I am trying to prepare my data for display using my function html, as below.  

I am trying to do it all in one go, but the array_walk_recursive doesn't seem to be working as expected - basically, O'Flanagan is displaying as O in my form.  It's the first time I have used it.  Or maybe the problem is that I don't understand how htmlspecialchars works, ie it doesn't actually change the parameter given to it.

function html($text)
{
	return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
}

$sql = "SELECT ts_team_code, ts_team_name, ts_managername, ts_manager_details, ts_instructions
	     FROM teams_seasons t";

$arr_fobg_teams = $dbi->db_select($sql,'Error occurred with FOBG team');

array_walk_recursive($arr_fobg_teams,'html');

Open in new window


and then eg. echo $arr_fobg_teams[1]['ts_managername'] shows O

if I say  echo html($arr_fobg_teams[1]['ts_managername']) it's fine.... shows O'Flanagan

Where am I going wrong?
0
Hello experts,

Here is my code:

<input type="checkbox" name="seat_rented[]" value="<?php echo $row['seat_serial'];?>">
$n = count($seat);
foreach($seat as $x) {
    $pdf-> Write(0, $x . ", ");
} 

Open in new window

I only want to concatenate the comma when $n is >1. If $n equals 1, I want to concatenate a period. I can't think of the if or while statement to handle this...
0
I'm a Beginner. Skill Set means Which Web technologies needs to learn.and how to learn like training manual,courses,books,Practice,Senior's Guidance.I don't want to be a Full-stack developer.i want to be a back-end developer(web applications,dynamic web pages).
0
On Demand Webinar: Networking for the Cloud Era
LVL 10
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

I have an older XAMPP installation hosting one website that went down. I have backups that I created using mysqldump before the crash and was wondering if I bring up a new Linux, Apache, MySQL, PHP installation would it be possible to do a restore. What should I be looking out for before rebuilding this server? If the versions of the various components are different will that affect the recovery?Thanks.
0
I am rewriting a url so instead of:

mysite.com/dealers.php?id=5

Open in new window


it is:

mysite.com/dealers/dealer-name

Open in new window


Instead of using $_GET['id'] and passing the ID, I am passing the slug i.e.: $_GET['slug']

I have the slug saved in the database but also have the record ID. I would feel more comfortable using the ID but just wanted to know if it is okay to use the slug or what is the best practice?
0
I now have two pages. A Searchpage and a Presentation- and upload page.

Searchpage: http://kroweb.dk/gfdev/gravsten_raw/

Presentation/upload page: http://kroweb.dk/gfdev/dataupload/

Both these pages works fine as it is now. The presentation/upload page uploads the entered data in the dataform to a new record in the database, and it uploads an image to a specified folder on the server.

When entering a searchstring e.g.”Lyng” on the Searchpage, it returns a list of results, where entries in the first column (with the headline “Sogn”) links to the Presentation/upload page.

The task now, is to get these two pages to work together, and to create the right common functionality.

(From here I need help to create the right code)

Clicking the link that opens the Presentation/upload page should do two things:

1.      Grab the id of the selected record from the “id” column in the database
2.      Retrieve and insert in the headline of the updateform (where it says …. ‘Sogn’ right now), the entry in the row “Sogn” in the actual record in the db. And at the same time retrieve data, if any is present, from the rows “navn”, “tlf”, “email” and “besked” in the database and insert them in the appropriate fields in the form. Finally it should display images, if any present, tied to the specific record on the page (see also  bullet 2. Below).

Furthermore I need to use the id for:

1.      Use in an SQL update query like: $sql = "UPDATE my_table SET name='name in form', …
0
I want to add php plugin in netbeans 8.2 on my computer.

The problem is there is no internet connectivity on that computer so i cannot install plugin through netbeans itself using following method

Tools-> plugin -> available plugins.

so, how  would i able to make php application on my computer.
  is there anyway to download plugin from another computer having internet connectivity and then make it installed on my computer.
0
Hello!

I am currently changing the code for a Web application (written with Angular.JS and the ionic framework with jQuery) that has a page generator. This generator page writes the image information into a relational database (phpMyAdmin, 10.1.22-MariaDB). What I have to do is to add a new form to this app where the user selects an existing page from a list & opens it in the page generator.

The <div> element that holds the image object is created in the page generator with a $templateCache.put command and has the following form:

"$templateCache.put("ivm-image-builder/templates/image-builder.html", "
	"<div class=\"hero\"\n" +
		[…]
"		<div class=\"hero-image\" ivm-bg-axis=\"y\" ivm-bg-drag ivm-bg-disabled=\"disabled\" ng-style=\"imageOptions.style\" ngf-background=\"ngModel\"></div>\n" +
		[…]

Open in new window


The code runs properly when creating a new page. When using this generator page for an existing page that had been saved in the database, I can easily fill the text fields (like "page name" or "URL" (a text field)), but I wonder how the images can be displayed properly. I wonder if a longtext field or a BLOB is the appropriate field type in the DB.

My question is: How can I display an image received from the database, which has no associated URI & is not saved at any accessible location? Is it the right way to associate the image information with the ngModel tag?
0
Hi,

I have built a small wordpress widget that floats in the bottom right hand corner of my client's website(s), so that their users can click it to make a payment to them... which simply redirects the user to my payment platform / website where my customer has an account.

FLOW - widget sits on clientwebsite.com and when they click it, the customer is brought to mysplink.com/abc (their payment profile on splink)

QUESTION
I need to be able to track how many users land on mysplink.com from a widget that sits on another site.

I was thinking of using something like mysplink.com/abc/ref=widget-abc and then i can view that in Google Analytics?

01 - would this approach be the best way to do this?

02 - any other advice on approaches would be greatly appreciated

Thank you in advance for your help.
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.