PHP

119K

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

Hello Experts,
Is it possible to use multiple data from a single MySQL field separated by comma such as (PHP,MySQL,Ajax,jQuery) as dropdown options?

The column name is "Skills" and has multiple data as described above. What I want is that, I want to be able to use each data in this column as dropdown Options in the form.

How do I use Select?

Thanks.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012
LVL 12
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

I have developed a list filter page which updates using ajax. Everything works well until I have discovered that search engines do not see this content!

Is there anything I can do to make this content visible to search engines using ajax, before I start a redevelopment?
0
I have this php script in my siteground account

https://lapalabramx.com/ip.php

I get

Fatal error: Call to a member function query() on boolean in /home/galaplas/public_html/lapalabramx.com/ip.php on line 21


In hostgator the same script:

http://apuntatemx.com/ip1.ph

Works ok

Code error line is

$result = $conn->query($sql);

I have googled and find nothing. I dont know if it is adiffrence in php or my sql

<?php
$servername = "localhost";
$username = "***";
$password = "***";
$dbname = "galaplast_respuestas";
$actividad="Paco";
// Create connection
$conn = mysqli_connect($servername, $username, $password,$dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} else {
	echo "ConnectionOk";
}
$ip=get_client_ip();
echo $ip;
$ipdec=ip2long($ip);
echo $ipdec;
$sql="select * from blocks where  " . $ipdec ."  BETWEEN ips AND ipe";
echo $sql ."<br>";
$result = $conn->query($sql);
$resultip = $conn->query($sql);
$rowip = $resultip->fetch_assoc();
if( $resultip->num_rows>0) {
$pais="MEXICO";
} else {
	$pais="NOMEX";
}
		
$conn->close();
?>

Open in new window

0
Hi - I have the following code which is used to post the value of a hidden form element to the page via PHP Post - the values and rows are generated from grabbing results from a database and it will output the results for each entry found.

The issue I have is the value posted called 'elm2' is always posted as the last one on the results set - i.e., it the last value on the table for t_ID is '33' then regardless of which row I click, it will always post as 33 - I think I can see the problem, all the outputted rows have the same name/id, but different values and I think it is just taking the last one on the list and posting this, not the one I am clicking.

Is this the problem and is there any way around it, or another way I could approach it?


<?php

$conn_task = new mysqli($dbhostname, $dbusername, $dbpassword, $dbdatabase);


$elm1 = $_POST['elm1'];
$elm2 = $_POST['elm2'];

echo "$elm1";
echo "$elm2";

?>

form start

<form id="PH33FORM" action="<?php echo $_SERVER['PHP_SELF'];?>" method='post'>
  <table>

    <?php

    if ($conn_task->connect_error) {
      die("Connection failed: " . $conn_task->connect_error);
    } 

    $sql = "SELECT * FROM xxxx";
    $result = $conn_task->query($sql);

    if ($result->num_rows > 0) {

      while($row = $result->fetch_assoc()) {

        $t_ID = $row["VWDF1"];
        $t_date = $row["tsk_aim_date"];

        echo "<tr><td>" . $row["t_ID"]. "</td><td>$t_date</td><td 

Open in new window

0
Currently running ost v1.10.1 - no customisations.

I am having trouble understanding how the knowledgebase properties work together to make articles available on the public interface.

The attached image shows our screen with Knowledgebase items in two places (Featured Questions and Featured Knowledgebase items).

What I want to do is to have all FAQ's public and viewable by using the Knowledgbase button and just feature some of them on the front screen either in Featured Questions (at the side) or Featured Knowledgebase items (at the bottom).  I don't mind which one.

There are two options (on the Agent panel) that I can see for defining what happens to the FAQ's....
Knowledgebase>Categories - Featured/Public/Private
Knowledgebase>FAQs>Listing Type - Featured/Public/Internal

I have spent lots of time looking at the various options but it seems that any combination of these settings (other than marking Private) will result in the FAQs appearing as Featured in one of those positions.

Is there any way that I can have (say) the Category/FAQs displayed in the sidebar on my example - available to the public in the knowledgebase but not appearing on the client screen.

I hope this is clear.
0
Hi,

I have the following code - it is a form where I am trying to get the value from the form posted to the page and the value collected via a PHP post.

The first form item works - I can get the value all ok from the checkbox when it is checked/unchecked, I am having trouble with the second one (where the cell is clicked) - it posts ok, but doesn't post a value, how can I get it to post a value? I thought defining the value would do it, but that didn't work.

Any help would be appreciated !

<?php

$elm1 = $_POST['elm1'];
$elm2 = $_POST['elm2'];

echo "$elm1";
echo "$elm2";

?>

form start

<form id="PH33FORM" action="<?php echo $_SERVER['PHP_SELF'];?>" method='post'>
  <table>
    <tr><td><input type='checkbox' value='VALUE1' id='elm1' name='elm1' onchange='document.getElementById("PH33FORM").submit()'></td></tr>
    <tr><td value='VALUE2' id='elm2' name='elm2' onclick='document.getElementById("PH33FORM").submit()'>VALUE</td></tr>
    <input type="submit" value="Submit">
  </table>
</form>

Open in new window

0
HI,

I am trying to create a SQL procedure but i keep getting no results. I am using php pdo to call the procedure and on execute it returns false;

DELIMITER $$

CREATE PROCEDURE add_activity_result(
	IN var_stat VARCHAR(1),		
	IN var_squad INT(11),		
	IN var_e INT(11),		
	IN var_me INT(11),		
	IN var_res varchar(200)	

)
BEGIN

	SET @squad = NULL, @res = NULL;
	
	SELECT 
		@squad = r.squadId, @res = r.result
	FROM `events-results` AS r
	JOIN events AS a ON a.id = r.eventId AND a.status = var_stat
	JOIN group AS s ON a.eventMember
	WHERE eventId = var_act AND a.id IS NOT NULL;
	
	IF(@squad IS NULL) THEN
		
		INSERT INTO `events-results` ( eventId, creatorId, date, squadId, leagueId, result ) VALUES ( var_act, var_me, NOW(), var_squad, var_league, var_res );
		
		INSERT INTO users_activity_log ( date, playerId, table_name, table_id, details ) VALUES ( NOW(), var_me, "events-results", LAST_INSERT_ID(), "Added a result to an activity" );

	ELSEIF(@squad = var_squad) THEN
	
		UPDATE `events-results` SET score_home = var_home, score_away = var_away WHERE squadId = var_squad AND eventId = var_act;
		
		INSERT INTO users_activity_log ( date, playerId, table_name, table_id, details ) VALUES ( NOW(), var_me, "events-results", var_act, "Updated a result to an activity" );
	
	ELSEIF(@res != var_res) THEN
		
		UPDATE `events-results` SET contested = NOW() WHERE squadId = @squad AND eventId = var_act;
		
		INSERT INTO `events-resolutions` ( eventId, date, creatorId, result ) 

Open in new window

0
Hi There

I have a question about dateformats

I am searching for a solution/validation for the next problem. in the formfields I get 2 different dates:
yyyy-mm-dd and dd-mm-yyyy. Is there a javascript to think of. doing the following:

if (date = dd-mm-yyyy) {convert to yyyy-mm-dd}

I hope someone can help me

regards

ron
0
Hey,  

I've been using a function in Wordpress which works great. It stores cookies from ads, and appends UTM's to the end of links, so we can track sources.

My friend has a pure PHP, MySQL website, and we want to try and convert this function we have in WordPress into this PHP website.

This is the function we are using in Wordpress,  It's on all pages of the website.   How can i convert this to a php function.

function replace_links($text) {
	$url = explode('?', 'https://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
	$addCookiesToLink = "";
	if (strlen($url[1]) > 1) {
		$text = str_replace('intelliapp2.driverapponline.com/c/cretec', 'intelliapp2.driverapponline.com/c/cretec?' . $url[1], $text);
	}
		else { //no parameters in URL. Cookies?
		if(isset($_COOKIE['orig_utmsource'])) {
			$addCookiesToLink .= "utm_source=" . $_COOKIE['orig_utmsource'];
		}
		elseif(isset($_COOKIE['orig_utm_source'])) {
			if(strlen($addCookiesToLink) > 0) {
				$addCookiesToLink .= "&";
			}
			$addCookiesToLink .= "utm_source=" . $_COOKIE['orig_utm_source'];
		}
		elseif(isset($_COOKIE['orig_utmmedium'])) {
			if(strlen($addCookiesToLink) > 0) {
				$addCookiesToLink .= "&";
			}	
			$addCookiesToLink .= "utm_medium=" . $_COOKIE['orig_utmmedium'];
		}
		elseif(isset($_COOKIE['orig_utmcampaign'])) {
			if(strlen($addCookiesToLink) > 0) {
				$addCookiesToLink .= "&";
			}	
			$addCookiesToLink .= "utm_campaign=" . $_COOKIE['orig_utmcampaign'];
		}
		

Open in new window

0
Oracle 12c / PHP7

ORA-01008: not all variables bound err
The table has a collumn name with a reserved word. (I know... Unfortunately I cannot change the collumn name)

$query = 'INSERT INTO leads_bu (leads_bu."SOURCE") VALUES (:SSOURCE)';
$stmt = oci_parse($conn, $query);
oci_bind_by_name($stmt, ":SSOURCE", $source, 20, SQLT_CHR); // VARCHAR2 (20)
$ins_result = oci_execute($stmt);

I've tried everything to get past this error. Thanks for your help.
0
Cloud Class® Course: Amazon Web Services - Basic
LVL 12
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

PHP: Can't figure out why vars are coming up as undefined.

I have a bunch of inclusions to do the printing with FPDF.  

The one line works with both printing one at a time and print all.
The full format works if you print one at a time, but when I select print all I get the following error message:

Notice: Undefined index: SECOND in /home/langsyst/public_html/seabreezesoftware/Retail/Full_Format_PDF_inc.php on line 205

The table layout is this:
16       STORE       int(6)                   Yes       0                   Change Change       Drop Drop       

    Primary Primary
    Unique Unique
    Index Index
    More

17       BASEMENT       int(5)                   Yes       0                   Change Change       Drop Drop       

    Primary Primary
    Unique Unique
    Index Index
    More

18       MEZZANINE       int(5)                   Yes       0                   Change Change       Drop Drop       

    Primary Primary
    Unique Unique
    Index Index
    More

19       SECOND       int(5)                   Yes       0                   Change Change       Drop Drop       

    Primary Primary
    Unique Unique
    Index Index
    Mor

The one line code is:
while ($ROW = $Survey_Data->fetch_array())  
	{
		if ($_SESSION['Last_Page'] == "Space_Edit.php")
		{
			// Footage
			$ROW['STORE'] = $_POST['Store'];
			$ROW['BASEMENT'] = $_POST['Basement'];
			$ROW['MEZZANINE'] = $_POST['Mezzanine'];
			$ROW['SECOND'] = $_POST['Second'];
			$ROW['OTHER'] = $_POST['Other'];			
			$ROW['TOTAL'] = $ROW['STORE'] + $ROW['BASEMENT'] + $ROW['MEZZANINE'] + $ROW['SECOND'] +$ROW['OTHER'];
			
			// Sizes
			$ROW['FRONTAGE'] = $_POST['Frontage'];
			

Open in new window

0
TCPDF Not working - CentOS 7.0. When trying to create a PDF file the system gives 500 Internal Server Error

See: https://dev.dom.com/custom/tcpdf/generate/auto-generate-single-pdf.php

Any help with this greatly appreciated.
0
Problem displaying foreign characters on the website from a MS SQL Server

The Name in SQL Database is : Lukáš Kovdsanda
This is displaying on website as : Luk� Kovdsanda

However, if I save from the website to the database it saves in the database as this "Lukáš Kovdsanda"

  select SERVERPROPERTY('collation') give the MS SQL collation as : Latin1_General_CI_AS

What do I need to do on the html/php code to fix this
0
I got some questions about SEO friendly url's

1.-I was wondering if it is possible to use a SEO friendly url's to download a file, I mean usually to download a file most of us use url's like "http://www.grupossc.com/pdf/something.pdf", but I would like to know if it is posible to add a "rewriterule" in my .htaccess to use a SEO friendly url like "http://www.grupossc.com/downloads/something" to download the pdf file localted in the folder "pdf" and hide the real path of the file.

2.- ¿It is possible to use SEO url's with php includes?
In my code i got code like <?php include ("assets/principal.php"); ?>, but I wanna know if it is possible to add a "rewriterule" in my .htaccess to use a SEO friendly url to use includes like <?php include ("http://www.grupossc.com/myseourl/myphpfile"); ?>
0
Hello Experts,

i want to make a chart with chart.js in php. the values are stored in sqlite db file.
i dont know how to get this work. i think the problem is in timestamp value.
can someone help me fix this?

regards


ps: you need to rename the file p1_db to p1.db from the zip file i uploaded. db files are not alowed to be uploaded.
chart.zip
0
Hello guys I Have a VAT calculator
price devided by 1.12 and less with 0.01..how cal I make the user input to automatically add thousand separator... instead of 10000000 it with display 100,000,000 also with the result. Here is my code


<head>
<link rel="stylesheet" type="text/css" href="plugins/style.css">
<style>
input[type=text], select {
    width: 100%;
    height: 50px;
    padding: 12px 20px;
    margin: 8px 0;
    display: inline-block;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 46px;
    font-style: bold;
    text-align: center;
}
</style>
</head>
<br>
<center>
<div class="header">
            <h2><b>WITHHOLDING CALCULATOR</b></h2>
</div>
<form>
<br/>
<input type="text" class="price" name="price" id="price"/>
<br/>
<h2><b>Quarter</b></h2>
<h2 name="vat" id="vat">0.00</h2>
<h2><b>Less</b></h2>
<h2 name="less" id="less">0.00</h2>
<h2><b>Payable</b></h2>
<h2 name="payable" id="payable">0.00</h2>
</center>
</form>
<script  type="text/javascript">
$(document).ready(function() {
    $('#price').keyup(function(ev){
var tot1 = $('#price').val();
        var vat = $('#price').val() / 1.12;
        $('#vat').html((vat).toFixed(2));
    });
});
</script>

<script  type="text/javascript">
$(document).ready(function() {
    $('#price').keyup(function(ev){
var tot1 = $('#price').val();
        var less = $('#price').val() / 1.12 * 0.01;
        $('#less').html((less).toFixed(2));
   …
0
SQL Statement,

I am having a problem with this SQL statement (I think it is an easy fix!) but I just cannot get it right.

SELECT ppm_name, ppm_id FROM main WHERE ppm_user_link='$UID' and ppm_id=MAX(ppm_id)

I would like to select the columns 'ppm_name' and 'ppm_id' from the 'main' table where it matches the 'UID' and it is the highest 'ppm_id' << I think this is where the error is.. with the MAX(ppm_id)?

How can I select these columns from the table where it is the highest ppm_id and ppm_user_link matches the $UID variable?

THanks in advance!
0
I have a CRUD page that creates, updates and deletes users, it also exports a csv file. what I need is for the page to display users between certain dates if wanted. I have is set up to go to a different page called updateusers.php. I'm not sure if there is a way to update on the page.

Right now the updateusers.php is is giving me this error:

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\Admin_System\updateusers.php on line 89
CRUD_users.php
updateusers.php
0
Randomly I receive 'corrupted' from a php form.

The 'corruptions' are always the same, and cause my scripts to fail as integers are delivered to my database as a mix of text and integer.

An example would be as below. The actual text has been replaced with XX and NN, but I have left the corruptions in place - see 1961댊 in the birthyear field and Mr0 in the title field. Both inputs are from a select form field, which are correct.

SQL: set dateformat dmy insert into tblmembers ( accountno, companyid, memoldaccountno, memaccountreference, memsubaccountreference, mempreviousscheme, mempreviousschemeno, title, firstname, surname, email, mobile, telephone, birthday, birthmonth, birthyear, gender, image, memberstatus, primarymember, uniquemember, createdby, token, consentemail, consenttext, consentpost, consentphone, terms, termsaccepted, createddate, updateddate) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, getdate(), getdate(), getdate() ) ; SELECT SCOPE_IDENTITY()

PARAMS:: 'array ( 0 => \'xxxx-A-xxxx\', 1 => \'xxx\', 2 => NULL, 3 => NULL, 4 => NULL, 5 => \'\', 6 => \'\', 7 => \'Mr0\', 8 => \'xxx\', 9 => \'xxx\', 10 => \'nnnn@nnnn.com\', 11 => \'nnnnn\', 12 => \'nnnnn\', 13 => \'02\', 14 => \'nn\', 15 => \'1961댊\', 16 => \'F\', 17 => NULL, 18 => \'Active\', 19 => \'primary\', 20 => \'xxxxx\', 21 => \'Online signup\', 22 => \'xxxx\', 23 => \'Yes\', 24 => NULL, 25 => NULL, 26 => NULL, 27 => \'VersionDate: nnnn\', )'

0
Free Tool: IP Lookup
LVL 12
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

sample.phpRunning, or utilising PHP scripts from VB6.

I have a large VB6 application which I developed over many years, and has been operating for many many years now.

My software has no issue consuming Web Services using MSXML2 to call various XML and JSON feeds.

However, in this instance, I need to communicate back and forward, and I'm slightly stumped as to best way to move forward. I've been presented with a PHP code which (a) has a login function to get a authorisation code, and (b) using that authorisation code, I need to send variables to submit a transaction, which supposedly will return a response.

I've attached the basic (modified) PHP script, and I'm looking for "nudges" in the right direction. The variables needed to pass to the login function, and order function are contained in my vb6 software.

Much Appreciated any assistance.
0
I have some code that looks like this:
	$work = $_SESSION['Add_Name_1'].$_SESSION['Add_Name_2'].$_SESSION['Add_Name_3'];
	echo "work = ".$work;
	if ($work == "NNN")
	{
		Header ("Location:Update_Space.php");
		exit;
	}

Open in new window

I've checked the vars, if one is checked it works.  But if none of the vars are checked , I get the following error:

work = NNN
Warning: Cannot modify header information - headers already sent by (output started at /home/langsyst/public_html/seabreezesoftware/Retail/Space_Contact_Update.php:27) in /home/langsyst/public_html/seabreezesoftware/Retail/Space_Contact_Update.php on line 144

Let me know if you need more info.
0
I am trying to send curl requests to google batches api, but i get an error (resource(2) of type curl).

Google Batch Documentation: https://developers.google.com/calendar/batch#batch-example-request

Here is my code:
function buildMixedRequest() {
    $CAL_BASE_URL  = 'https://www.googleapis.com/calendar/v3/calendars/';
    $CAL_BATCH_URL = 'https://www.googleapis.com/batch';        

    $ch = curl_init( $CAL_BATCH_URL );

    $events = array();
    $events[] = array( 'calendar_id' => 'primary', 'BookingRef' => '#1', 'StartDate' => '2018-06-6T09:05:00', 'EndDate' => '2018-06-6T11:05:00' );
    $events[] = array( 'calendar_id' => 'primary', 'BookingRef' => '#2', 'StartDate' => '2018-06-7T11:05:00', 'EndDate' => '2018-06-7T11:55:00' );  

    $calendar_id = 'primary';
    $access_token = '{my_token_here}';
    $boundary = 'batch_' . uniqid();
    $data = '';

    //$data .= "--" . $boundary . "\r\n";
    //$data .= 'Content-Type: application/http';

    // Add batches
    foreach ( $events as $event ) {
        $data .= "--" . $boundary . "\r\n"
            . 'PUT ' .  $CAL_BASE_URL . $calendar_id . '/events' . "\r\n"
            . 'Content-Type: application/json' . "\r\n"
            . 'Content-Length: ' . strlen(json_encode($event)) . "\r\n";
        $data .= json_encode($event) . "\r\n\r\n";
    }

    // Headers
    $headers = array(
        "Authorization: Bearer " .  $access_token,
        "Host: www.googleapis.com",
        "Content-Type: multipart/mixed; 

Open in new window

0
I have a function that puts a set of links where I want them.  My problem is I don't want them to show on the On Sale category page.  The slug is on-sale.

add_action( 'woocommerce_before_main_content', 'shop_az', 11 );

function shop_az() {
	
	if (is_product_category != ( 'on-sale' )) {
		
		
	

echo '<div class="shophead"><a href="/product-category/home/shop_a_z_page_1_c_28/">A</a>&nbsp;<a href="/product-category/home/shop_a_z_page_1_c_28/shop_b_page_1_c_29/">B</a>&nbsp;<a href="/product-category/home/shop_a_z_page_1_c_28/shop_c_page_1_c_27/">C</a>&nbsp;<a href="/product-category/home/shop_a_z_page_1_c_28/shop_d_page_1_c_30/">D</a>&nbsp;<a href="/product-category/home/shop_a_z_page_1_c_28/shop_e_page_1_c_31/">E</a>&nbsp;<a href="/product-category/home/shop_a_z_page_1_c_28/shop_f_page_1_c_32/">F</a>&nbsp;<a href="/product-category/home/shop_a_z_page_1_c_28/shop_g_page_1_c_46/">G</a>&nbsp;<a href="/product-category/home/shop_a_z_page_1_c_28/shop_h_page_1_c_47/">H</a>&nbsp;<a href="/product-category/home/shop_a_z_page_1_c_28/shop_i_page_1_c_48/">I</a>&nbsp;<a href="/product-category/home/shop_a_z_page_1_c_28/shop_j_page_1_c_49/">J</a>&nbsp;<a href="/product-category/home/shop_a_z_page_1_c_28/shop_k_page_1_c_50/">K</a>&nbsp;<a href="/product-category/home/shop_a_z_page_1_c_28/shop_l_page_1_c_51/">L</a>&nbsp;<a href="/product-category/home/shop_a_z_page_1_c_28/shop_m_page_1_c_52/">M</a>&nbsp;<a 

Open in new window

0
Has the coding for "Google Maps" changed?  The code worked about 2 weeks ago.  I haven't changed it and now I'm getting a message that it cant find the site.

$city = "new%20york%20ny%20%22office%20building%22&sa=N&tab=il";
			$url = "'http://www.maps.google.com/maps?hl=en&biw=1020&bih=541&gbv=2&safe=images&ie=UTF-8&q= %20{$Street_Num}%20{$Street_Name}%20{$city}'";

Open in new window


What's up?
0
I have a JSON formatted configuration file that I need to load into PHP and work with. Whats the best way to do this?

I was thinking of using file_get_contents and then json_decode to move it into an array.
0

PHP

119K

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.