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

I keep getting this error every time I go to the chargeticket_list page.

Controller

public function chargeticket_list() {
$data['charge_tickets'] = $this->Chargeticket_model->list_charges($this->input->post('date1'), $this->input->post('date2'));
$this->load->view( 'inc/header' );
$this->load->view( 'chargeticket/chargeticket_list', $data );
$this->load->view( 'inc/footer' );
}

Open in new window

Model

public function list_charges($date1, $date2) //This function returns an array
    {   $this->db->join( 'customers', 'charges.idcustomers = customers.idcustomers' );
        $this->db->where('ch_date >=', $date1);
        $this->db->where('ch_date <=', $date2);
        $query = $this->db->get('charges'); //create query
        return $query->result_array(); //creates array from query
    }

Open in new window

View

<script type="text/javascript">

$(document).ready(function (){
    $('.date1').datepicker({
dateFormat: 'yy-mm-dd'});
});

$(document).ready(function (){
    $('.date2').datepicker({
dateFormat: 'yy-mm-dd'});
});
</script>

<div class="container">
<?php 
    $attributes = array('id'=>'chargeticket_list', 'class'=> 'form-horizontal');
    echo form_open('chargeticket/chargeticket_list', $attributes);
?>

<div class="form-group">
    <?php $ldata = array('class' => 'control-label col-sm-4');
    echo form_label('From','date1', $ldata ); 
    $data = array('class' => 'form-control date1','name' => 'date1');?>
    <div class="col-sm-4"><?php 

Open in new window

0
Free Tool: Site Down Detector
LVL 12
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

I'm having trouble parsing xml data using PHP.  I'll attach my XML file, and I'm trying to create a variable for each <LINE type="VALLEY" /> attribute in the file.  Any help would be appreciated!
0
PHP coding for entering radio button form  data into a MYSQL database.

if (empty($PostANoticeTBR_errors)) { // If everything's OK...

}

if ($_POST['public'] == 'No') { // Does not not appear on public page.
	
		$q = "UPDATE notices SET public = '0' WHERE id=$id LIMIT 1";
		$r = @mysqli_query ($connect, $q);
		if (mysqli_affected_rows($connect) == 1) { // If it ran OK.
		}
}
// Print a message:
			echo '<p><h3a>This Notice will not appear on the Public page.</h3a></p>';
			
} else { 
	
		$q = "UPDATE notices SET public = '1' WHERE id=$id LIMIT 1";
		$r = @mysqli_query ($connect, $q);
		if (mysqli_affected_rows($connect) == 1) { // If it ran OK.
		}
}
			echo '<p><h3a>This Notice will appear on the Public page.</h3a></p>';


	<br />
	<p> If you do not want your notice to appear to the public, check the No button. 
      <input type="radio" name="public" value="0"> No
      <input type="radio" name="public" value="1" checked="checked"> Yes</p><br />
      <button class="button" style="vertical-align:center"><span>Submit Your Notice &rarr;</span></button>
	<input type="hidden" name="id" value="' . $_SESSION['user_id'] . '" />
<br> 

Open in new window

0
Is there a better way to sum multiple columns in an array without having to iterate over the array for each column?

From a previous question, i was lead to a solution that allowed me to calculate the total for a single column in an array, this wasy perfect, because that array only had 2 columns.

Example PHP
$sum = 0;
        foreach($arr as $balance)
        {        
            if($balance["balanceType"] == "Checking")
            {
                $sum += $balance["SumToday"];
            }
        }

This works perfectly.

But what if i want to sum multiple columns at the same time? Is it possible to write this into one expression as opposed to using the above method for each column as my new array has 5 columns i would like to get totals for?

Ideal scenario would be to return the total Today, This Week, This Month, This Year, All Time for balanceType Checking.

Example Array:

        0 => {#863 ▼
      +"client": "Client 1"
      +"today": "0"
      +"past 7 days": "1"
      +"past 30 days": "2"
      +"this year": "3"
      +"all time": "12"
      +"balanceType": "Checking"
    }
    1 => {#864 ▼
      +"client": "Client 1"
      +"today": "0"
      +"past 7 days": "0"
      +"past 30 days": "0"
      +"this year": "8"
      +"all time": "7"
      +"balanceType": "Savings"
    }
    2 => {#865 ▼
      +"client": "Client 2"
      +"today": "0"
      +"past 7 days": "0"
      +"past 30 days": "6"
      +"this year": "85"…
0
How can I refresh dataTable after insert with modal?

My table is as follows:
<table id="dynamicTable" class="table table-striped table-bordered table-hover">
	<thead>
		<tr>
			<th class="center">
				<label class="pos-rel"><span class="lbl">#</span></label>
			</th>
			<th>Staff Name</th>
			<th>User ID</th>
			<th class="hidden-480">Password</th>
			<th class="hidden-480">Role</th>
			<th class="hidden-480">Class Assigned</th>
			<th>Actions</th>
		</tr>
	</thead>
	<tbody>

		<?php
		if($total_rows > 0)
		{
			$cnt = 1;
			foreach($result as $row)
			{
				$id = $row['UserId'];
				$staff_name = $row['Initials'];
				$staff_loginid = $row['Username'];
				$staff_password = $row['Password'];
				$staff_role = $row['Role'];
				$class_assigned = $row['ClassAssigned'];

				if($staff_role == 'Admin'){
					$role = "<div class='badge badge-info'>Admin</div>";
				}else if($staff_role == 'Form Master'){
					$role = "<div class='badge badge-warning'>Form Master</div>";
				}else {
					$role = "<div class='badge badge-success'>Subject Teacher</div>";
				}             
				?>
				<tr>
					<td><?php echo $cnt;?></td>
					<td><?php echo $row['Initials'];?></td>
					<td><?php echo $row['Username'];?></td>
					<td class="hidden-480"><?php echo $row['Password'];?></td>
					<td class="hidden-480"><?php echo $role;?></td>
					<td class="hidden-480"><?php echo $row['ClassAssigned'];?></td>
					<td><div class="hidden-sm hidden-xs action-buttons">
						<a 

Open in new window

0
I have an API that is already written and working. When a customer sends a URL with an apostrophe, it creates problems because the program has to interface with another (AS400) interface that does not accept apostrophes and kicks out the whole record.

If the variable references within the body of the code were $_GET variables, I would just do a foreach and remove them. But the references are all using $_REQUEST and I am not sure that doing a foreach through $_REQUEST is advisable. It works, but is it advisable?
foreach($_REQUEST as $idx => $val)
{
    $_REQUEST[$idx] = str_replace("'" , '' , $val);
}

Open in new window

0
See following code. Little bit of php, some Javascript & HTML.

$fname= "testersrpt/test" . date('Y-m-d') . ".pdf";
$pdf->Output($fname, "F");			
?>
<!DOCTYPE html>

<html>
<head>
<title>Untitled</title>
<script>
str = "<? print $fname; ?>";
	function on_load() {
		window.open(str);
		window.location = "gen_testers_by_city.php";
	}	
</head>
<body onload="on_load();">



</body>
</html>	

Open in new window


My intent is for the browser to open (in a separate window) the file called str (which is IN that folder) and to redirect to gen_testers_rpt.php (in the same forder we are presently in).

It does neither.

It shows several echos I have inserted for debug purposes & the rest a blank scree.

Why?

Why
0
Try to insert data to myphpadmin table, but its not letting me inset data. Connection to database ECHO ok. It was working fine til I tried to use jquery for live SUMMING, but it stop inserting data to the table. Now that I remove all the coding for Jquery is still not inserting data to the table Attached you will find  the file with the issue. I tried error_reporting there were some errors i fixed that but still no data inserting .

Thanks in Advance.
MasterInsert1.php
0
Hello Experts,

I need help on modal form validation.

The following code inserts properly (only when all inputs are filled correctly).

I'm having trouble validating subject_taught and class_taught inputs.

More so, I want the form to clear all inputs (reset) after insert without error. The datatable should refresh afterwards.

The code:
<?php
include('../includes/connection.php');


if ( ! empty($_POST) ) {
	
    if ( empty( $_POST["initial"] ) || empty( $_POST["username"] ) || empty( $_POST["password"] ) || empty( $_POST["role"] ) || empty( $_POST["subject_taught"] ) || empty( $_POST["class_taught"] ) ) {

    	$response = '<div class="alert alert-danger">
		<span class="badge badge-danger">Empty Field(s) Detected!</span> All fields are required.</div>';

        die($response);
    }

    // Validation passed so let's deal with the DB stuff

	$initial = $_POST["initial"];
	$username = $_POST["username"];
	$password = $_POST["password"];
	$role = $_POST["role"];
	$class_assigned = $_POST["class_assigned"];
	

	$master_query = '';
	
	$stmt = $conn->prepare("SELECT Username FROM Users WHERE Username = ?");
        $stmt->bind_param("s", $username);
        $stmt->execute();
        $staffList = $stmt->get_result();

    if (mysqli_num_rows($staffList) > 0 ) {

    	$response = '<div class="alert alert-danger">
		The Username: <span class="badge badge-pink">'.$username.'</span> already exists. Try another one!</div>';

	die($response);
  

Open in new window

0
Hi all,

How can i sum a column in an array based on the value of another column in the array?

For example, the following array i need to return Sum of Balance Type Checking and Sum of Balance Type Savings to my view.

my current code in my controller is $checkingSum = array_sum(array_column($arr, 'Balance', 'BalanceType'=>"Checking" ?));

basically im trying to say sum balance where balance type = checking, easy to do in SQL but not sure how with php/arrays

My Array

$arr =
array 176: [

0 => array:3 [
"client" => "Client 123"
"Balance"=>"25"
"BalanceType"="Checking"
]

1 => array:3 [
"Client"=>"Client 123"
"Balance"=>"25"
"BalanceType"=>"Savings"
]

2 => array:3 [
"Client"=>"Client 456"
"Balance"=>"25"
"BalanceType"=>"Checking"
]

3 => array:3 [
"Client"=>"Client 456"
"Balance"=>"25"
"BalanceType"=>"Savings"
]

]
0
Cloud Class® Course: Microsoft Office 2010
LVL 12
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

I'm migrating my website from http to https.   Most of the site works as expected, but a php contact form handler does not work.  This file works fine on the http site, but not on the https site.  I tested the https site with a php-info testing file, and it worked.  I've uploaded the form, but removed my Email address from the $myemail field.  Removing this code allows the form to work:

session_start();
 if(!isset($_SESSION["contact_form"])){ //if contact form was not really visited, just exit.
 exit;
 }

That code is useful, because it avoids processing the form if a spam-bot has simulated a response to the form without actually visiting it. Please let me know if you have a solution which would allow inclusion of that code.
contact-form-handler.php
0
I am getting this error when I try to upload an image to my server.  I haven't change anything except for the normal centos updates.  Here is the error:

https://gyazo.com/03f0e39e905cdeddda55c2629a53b7b9

This is also affecting my ability to update a plugin.  Where I get this error:

https://gyazo.com/ef7f4ed9f0d28e9d9cfa4a40a3536e02

I have used this writeup to try and fix the problem.  However, nothing changed.  

http://www.wpbeginner.com/wp-tutorials/how-to-fix-image-upload-issue-in-wordpress/

Please help me get this working again.
0
Hello all.

I am trying to pass on parameters contained in my initial search form, onto the pagination script in my results page.  I'm not sure how to do this properly.

My set up currently is flawed in that I lose my initial search criteria when I click on the [Next], [Last] etc buttons in my pagination script.  I guess this is because I need to pass the parameter values from my initial search into the pagination? Currently my simple pager code looks like this:

<ul class="pagination justify-content-end">
					  
					 <?php
					 if($pageno <= 1){?>
						<li class="page-item disabled"><a class="page-link" href="#">&#x276e; &#x276e; First </a></li>
					<?php } ?>

					<?php
					if($pageno > 1){?>
						<li class="page-item"><a class="page-link" href="?pageno=1"> &#x276e; &#x276e; First </a></li>
					<?php } ?> 
					  
					  
					  <li class="page-item"><a class="page-link" href="<?php if($pageno <= 1){ echo '#'; } else { echo "?pageno=".($pageno - 1); } ?>"> &#x276e; Previous</a></li>
					  
					  <li class="page-item"><a class="page-link" href="<?php if($pageno >= $total_pages){ echo '#'; } else { echo "?pageno=".($pageno + 1); } ?>"> Next &#x276f;</a></li>
					  
					 
					 <?php
					 if($pageno >= $total_pages){?>
						<li class="page-item disabled"><a class="page-link" href="#">Last &#x276f; &#x276f;</a></li>
					<?php } ?>

					<?php
					if($pageno < $total_pages){?>
						<li class="page-item"><a class="page-link" href="?pageno=<?php 

Open in new window

0
I am making my Ajax Response. For this I take 3 variables in a while loop and save values of 3 database columns in them. As there are multiple records
in DB so I have concact the value like $value .= 'value from db'. After the loop I have put these three variables in an array and sent them by using json_encode.

Here is  the sample code
 
while($projects_row = mysqli_fetch_assoc($projects_result))
		{         
			$projects_name .= '<li id="project-id-5a01bffbcfbeb40a008b458a" data-id="5a01bffbcfbeb40a008b458a">
			<span class="li-txt" style="color:#ff0000;width: calc(100% - 90px);"><a id="myAnc" href="#">'.$projects_row['project_title'].'</a></span>
			<span class="thumb-container"><span class="thumb thumb-3" style=""></span> 
			<span class="thumb thumb-6" style=""></span> </span></li>';		

			$projects_detail .= $projects_row['project_detail'];			
			$projects_image .= $projects_row['project_image'];			
        }  

echo json_encode(array("message1" =>$projects_name, "message2" =>$projects_detail, "message3" =>$projects_image ));
		

Open in new window


In my Ajax Success function I am retrieving the values as:
  $.ajax({
                url:"myresponse.php",
                type: "POST",
                data:  {"country_id":country_id},
                dataType: "json",								
					success: function(data)
					{				
						console.log(data);
						//alert(data.message1);
						//alert(data.message2);
						jQuery("#project-list").html(data.message1);
						jQuery(".pr-cont-info").html(data.message2);												
					},
				
              });  

Open in new window


The issue is data.message1 and data.message2 contains data of all rows. I need to seperate the data of each row so that I can use any row data anywhere.
For example, in my case data.message1 contains data of 3 rows like 'USA Project 1 USA PROJECT 2 USA PROJECT'. I have print that data in a DIV and due <li> tags
one record is printed in one line. Now i want that if user click on USA Project1, then it only shows the details of Project1.  Currently it shows the details of all 3 rows.

So how to fix this issue?
0
I'm trying to decrypt using Rijndael in PHP, but appear to be getting different values compared to what i get when doing it using C#?

Here's my C# code:

    RijndaelManaged rijndaelManaged = new RijndaelManaged();
    rijndaelManaged.KeySize = 256;
    rijndaelManaged.BlockSize = 128;
    rijndaelManaged.Mode = CipherMode.CBC;

    ICryptoTransform decryptor = rijndaelManaged.CreateDecryptor(rgbKey, Array4);

    count2 = fileStream.Read(buffer4, 0, count1); //6D-18-80-01-DD-B6-3E-5B-26-83-CE-30-C7-AC-57-79
    cryptoStream.Write(buffer4, 0, count2);

    ^^ this value is 31-3B-3B-31-3B-3B-40-FD-00-20-A9-A2-00-08-71-CA

Open in new window


And here's my PHP code

    $rgbKey = "de299ceff91f2a216969a22e482a6c1616c6e64e552d46ffafb713f1743e32d1";
    $rgbIv = "ECCD26BE791BB360E2010F6378CD5631";

    $rijndael = new Rijndael();
    $rijndael->setKey($rgbKey);
    $rijndael->setIV($rgbIv);
    $rijndael->enableContinuousBuffer();
    $rijndael->setKeyLength(256);
    $rijndael->setBlockLength(128);

    echo bin2hex($rijndael->decrypt("6D188001DDB63E5B2683CE30C7AC5779")); 

    ^^ this value is c3d0ea2da27565c46fc7f1d2c0684baaf246

Open in new window


I get the correct value here when doing online: http://aes.online-domain-tools.com/link/1300553gqcXhtYR9LB/
0
I'm currently trying to port over some C# to PHP, although I'm stuck on a block of code, I can't seem to work out the equivalent in PHP?

using (CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, decryptor, CryptoStreamMode.Write))
		{
			// traite les données du fichier crypté depuis Start jusqu'à la fin - les 128 bytes de la signature
			while (fileStream.Position < fileStream.Length - 128L)
			{
				int count2 = fileStream.Read(buffer4, 0, count1);
				num2 += count2;
				cryptoStream.Write(buffer4, 0, count2);
				if (count2 <= 0)
					break;
			}
			cryptoStream.FlushFinalBlock();
			cryptoStream.Close();
		}

Open in new window


If anyone could point me in the right direction, that'd be great!

The complete function in C# would be:

public static void Decode(string filename, MemoryStream memoryStream)
{
	using (FileStream fileStream = new FileStream(filename, FileMode.Open))
	{
		byte[] bytes_0to3 = new byte[4];
		byte[] bytes_4to7 = new byte[4];

		// Take the first 4 bytes of crypted file
		fileStream.Seek(0L, SeekOrigin.Begin);
		fileStream.Read(bytes_0to3, 0, 3);
		// Take the next 4 bytes of crypted file from byte 4
		fileStream.Seek(4L, SeekOrigin.Begin);
		fileStream.Read(bytes_4to7, 0, 3);

		// Convert to dec val
		int lenght_1 = BitConverter.ToInt32(bytes_0to3, 0); // 80000000 - 00000080 = 128
		int lenght_2 = BitConverter.ToInt32(bytes_4to7, 0); // 10000000 - 00000010 = 16

		int Start = lenght_1 + lenght_2 + 8;

		byte[] numArray3 = 

Open in new window

0
I have multiple row of td that i retrieve from database. Now I have to to keyup for each row once i input value into LUAS_KESELURUHAN AND LUAS_KEKOSONGAN textbox. The answer must be display on REMISI textbox.. I have used javascript for this action but it only keyup this action for the first line..can someone here help me since i have stuck for this problem for a few days..Thank you
Problem:


And here is my code:
<script>
function kira1(){
	var LUAS_KESELURUHAN = document.getElementById('LUAS_KESELURUHAN').value;
	var LUAS_KEKOSONGAN = document.getElementById('LUAS_KEKOSONGAN').value;
	
	if (LUAS_KESELURUHAN != "" ){
	remisi = LUAS_KESELURUHAN*LUAS_KEKOSONGAN;
	document.getElementById('REMISI').value = remisi;
	}
}
</script>

while($rowChk = $resultChk->fetch(PDO::FETCH_ASSOC)){
	
		echo "<tr>";
		echo "<form id='makRemisi' method='post'>";
		?>
		<div style="display:none;">
		<?php
		echo "<div id = 'show_idx'>";
		echo "<td>"?><input type="text" name="LUAS_KESELURUHAN" id="LUAS_KESELURUHAN" onkeyup="kira1()" value="<?php print $rowb["LUAS_KESELURUHAN"] ?>"><?php " 
                </td>";
		echo "<td>"?><input type="text" name="LUAS_KEKOSONGAN" id="LUAS_KEKOSONGAN" onkeyup="kira1()" value="<?php print $rowb["LUAS_KEKOSONGAN"] ?>"><?php " 
                </td>";
		echo "<td>"?><input type="text" name="REMISI" id="REMISI" value="<?php print $rowb["REMISI"] ?>"><?php "</td>";
		echo "<td>"?><input class="easyui-filebox" name="fileName[]" 

Open in new window

0
I have used fpdf (a pdf generator) for years, I use it in many programs, it works beautifully.

A new program I finished yesterday uses it, but it produces a blank page.

So as a test, I wrote the simplest program using fpdf as a test:

<?php
date_default_timezone_set("America/Chicago");
// fpdf test
require_once('fpdf.php');
$pdf=new FPDF('L', 'pt', 'Letter');
$pdf->SetAutoPageBreak(false);
$pdf->SetDisplayMode('real');
$pdf->SetTopMargin(2);
$pdf->SetleftMargin(10);
$pdf->SetTitle('Testers by Agency, Date');
$pdf->AddPage();
$yd = 10;
$pdf->SetXY(50,$yd);
$pdf->Cell(500,30,"Backflow Test Report Testers Selection Summary",0,0,"C");
$fname= "testersrpt/test" . date('Y-m-d') . ".pdf";
$pdf->Output($fname, "F");
?>

Open in new window


The file named test2018-06-20.pdf is in that folder on the server, I download & open with Acrobat, a blank page.

For those of you who do NOT know fpdf, it should produce a centered heading on the page with text "Backflow Test Report Testers Selection Summary"
0
All thanks to Chris Stanyon who has been helping in making sure I'm successful in my project.

Now, I have a bootstrap modal that inserts into mysql using explode. I like to use same type of modal form to update the data fetched from database.

When I click on the Edit button on the datatable, I want the Modal to open the record of the selected user for necessary update.

Please Note: I use Ajax to post to the database.

The sample of what I want is attached and the script for my insert is as follows:

Modal for Insert:
<!-- new staff modal-->
<div class="modal fade" role="dialog" id="addStaffModal">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Add New Staff</h4>
      </div>

      <form class="form-horizontal" method="post" id="newStaff-Form" action="data.php">
      <div class="modal-body">
      	
      	<div id="response" class="center"></div>
      	
        <div class="form-group">
    		<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="initials">Initials<span style=color:red;> *</span>
    		</label>
    		<div class="col-xs-12 col-sm-9">
    			<div class="clearfix">
    				<input type="text" name="initials" 

Open in new window

0
Cloud Class® Course: Ruby Fundamentals
LVL 12
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Php problem with a query returning undefined error message.

I can't see what is wrong with the following code
	$SqlString1 = "SELECT * FROM survey_data WHERE SEQ = '$Building_Id' and STOREKEY = '$Space_Id'";
	$Survey_Data = $conn->query($SqlString1);
	$row_survey = $Survey_Data>fetch_array();

Open in new window


It returns:
Fatal error: Call to undefined function fetch_array() in /home/langsyst/public_html/seabreezesoftware/Retail/Update_Space.php on line 383

It's probably me.  I'm having a bad day
0
Hi Experts

Could you point how to present and validate a combobox value by using CakePHP?

Accordingly to:
Data Model  - There's a FK from Usuarios table to Posts table
img002
The page's layout
 img004
View's code: add_with_validation.ctp
  <div class="posts form">
<p>
	This form is like the first one but here we validate that a post must have
	at least one tag.
</p>
<?php echo $this->Form->create('Post'); ?>
	<fieldset>
		<legend><?php echo __('Add Post validating the number of tags'); ?></legend>
	<?php
		echo $this->Form->input('name');
        
        // Tags correctly presented    
        echo $this->Form->input('Post.Tag',array('label'=>'At least one Tag', 'type'=>'select', 'multiple'=>true));
	
        
        //Code to present the Users combo (what I need to be done)
		echo $this->Form->input('Post.Usuario',array('label'=>'At least one Usuario', 'type'=>'select', 'multiple'=>true));
	?>
	</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="actions">
	<h3><?php echo __('Actions'); ?></h3>
	<ul>
		<li><?php echo $this->Html->link(__('List Posts'), array('action' => 'index')); ?></li>
	</ul>
</div>

Open in new window


The correspondent controller's code
  public function add_with_validation() {
    if ($this->request->is('post')) {
      $this->Post->create();
      if ($this->Post->save($this->request->data)) {
        $this->Session->setFlash(__('The post has been saved'));
        return $this->redirect(array('action' => 'index'));
      } else {
        $this->Session->setFlash(__('The post could not be saved. Please, try again.'));
      }
      
    }
    $tags = $this->Post->Tag->find('list');
    $this->set(compact('tags'));
// I guess something must to be done here to consider "usuarios" - my tryes resulter in errors...

  }

Open in new window



Model's code
<?php
	
  App::uses('AppModel', 'Model');
/**
 * Post Model
 *
 * @property Tag $Tag
 */
class Post extends AppModel {

/**
 * Display field
 *
 * @var string
 */
  public $displayField = 'name';

/**
 * Validation rules
 *
 * @var array
 */
  public $validate = array(
    'name' => array(
      'notempty' => array(
        'rule' => array('notBlank'),
      ),
    ),
    
    // My Try to validate the usuario combo contents

        'Usuario' => array(
        'multiple' => array(
        'rule' => array('multiple', array('min' => 1)),
        'message' => 'You need to select at least one tag',
        'required' => true,
      ),
    ),
    
    'Tag' => array(
      'multiple' => array(
        'rule' => array('multiple', array('min' => 1)),
        'message' => 'You need to select at least one tag',
        'required' => true,
      ),
    ),
  );

Open in new window


Thanks in advance!
0
Currently working on an app in A with 3 pages (activities if you will).

A login, register & reservation page. All work fine except for the latter. Whenever i try sending data to my local database, on the reservation page I get an error. The error's inside my succes/fail message after i've pressed the send button

How do i fix this ?



Reservation.JAVA (called Reserveer.JAVA)

 
package com.example.baudelo.zeilreservering;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class Reserveer extends AppCompatActivity {
    EditText Eindereservering;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_boten);
        Eindereservering = (EditText)findViewById(R.id.dteDatum);
    }

public void OnRes(View view) {
    String dte_datum = Eindereservering.getText().toString();
    String type = "reserveer";
    BackgroundWorker backgroundWorker = new BackgroundWorker(this);
    backgroundWorker.execute(type, dte_datum);
}

}

Open in new window

BackgroundWorker.JAVA

package com.example.baudelo.zeilreservering;

import android.app.AlertDialog;
import android.content.Context;
import android.os.AsyncTask;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import 

Open in new window

0
PHP:  syntax error, unexpected '=' in D:\wamp64\bin\php\php7.0.10\php.ini on line 1030

Please help to me

Thanks
0
Dear Experts,
I retrive some data from another web site with this below code

$con1 = file_get_contents('https://the_website_i_get'); 
$encokartan=explode('<ul class="my-list">', $con1); 
$encokartan=explode('</ul>', $encokartan[1]);  
echo $encokartan[0]; 

Open in new window


the out put like below

US A: 4,7427 % 0,440 S: 4,7638
ER A: 5,4858 % 0,500 S: 5,5123
ER/USD 1,1567 % 0,050
BTT 94166,0 % -0,287
AN A: 194,0 % 0,350 S: 194,9
THV F: 19,49 % 0,880

How can I get the first 5 list items?
I don't want to show the 6th list item. "THV F: 19,49 % 0,880"
Thank you
0
Hello all,

I'm a hobbyist, starting to dip my toe into Bootstrap 4, along with JQuery and Ajax.

I've got a PHP script, which works fine for tabs in Bootstrap 3 - and I'm now trying to convert it into Bootstrap 4 Collapse/Accordion - but cannot get it working - my ajax content currently appears outside all the accordion tabs, at the very bottom of the screen. I've spent some time researching this, but cannot see examples on what I'm trying to achieve.
 
For my Bootstrap 4 Accordion, when it initially appears, I want the first panel open and populated with my dynamic ajax content - with loading gif -  with each panels content being dynamically refreshed with ajax with each panel press.

<script>
$(document).ready(function() {


    $("#247button").click(function() {
 
        $("#ajax-content").empty().append("<div id='loading'><img src='/images/loading.gif' height='60' width='60' alt='Loading' /></div>");
        $("#nav li a").removeClass('current');
        $(this).addClass('current');
 
        $.ajax({ url: this.href, success: function(html) {
            $("#ajax-content").empty().append(html);
            }
    });
    return false;
    });
 
    $("#ajax-content").empty().append("<div id='loading'><img src='/images/loading.gif' height='60' width='60' alt='Loading' /></div>");
    $.ajax({ url: '/247getday2staffTIMES.php', success: function(html) {
            $("#ajax-content").empty().append(html);
    }
    });
});
</script>  


<div id="accordion">
 

Open in new window

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.