Hello im having some problems with my forms. It says "Saw a form start tag, but there was already an active form element. Nested forms are not allowed." but when im looking in my code the forms are not even nested in my code can i have some help.
$sql8 = 'SELECT läggtill.serier, läggtill.id, läggtill.id2, läggtill.säsonger, läggtill.betyg, kategorier.kategori from läggtill inner join'
. ' kategorier on läggtill.kategorier=kategorier.id order by läggtill.serier';
$resultat8 = $mysqli->query($sql8);
$antal8 = $resultat8->num_rows;
while ($rad8 = $resultat8->fetch_assoc()) {
echo "<li>" .$rad8['serier'] .', ' .$rad8['säsonger'] .' Säsonger, ' .$rad8['kategori'] .'<br>'.
'Betyg: ' .$rad8['betyg'] .'/10 </li>' .'<br>';
$id = $rad8['id'];
?>
<?php
echo '<form action="alla.php" method="POST">
<button name=' .$id .'>Ta bort</button>
</form>'
?>
<?php
if (isset($_POST[$id])) {
$sql9 = "Delete from läggtill where id=" . $id . " LIMIT 1";
if ($resultat9 === $mysqli->query($sql9)) {
header('location: alla.php');
} else {
echo "det misslyckades.";
}
echo "asdasd";
}
$id2 = $rad8['id2'];
echo "<div class=" . 'Update' . '>'
?>
<?php
echo "<form action='alla.php' method='POST'>
<label for='serier'>Serie: </label>
<input type='text' name='serier' id='serier'><br>";
$sql14 = 'SELECT * FROM kategorier';
$resultat14 = $mysqli->query($sql14);
$antal14 = $resultat14->num_rows;
if ($antal14 == 0) {
echo 'Inget funnet';
} else {
$sql15 = 'SELECT kategori, id FROM kategorier';
$resultat15 = $mysqli->query($sql15);
$antal15 = $resultat15->num_rows;
if ($antal15 == 0) {
echo 'Inget kategori funnen';
} else {
echo 'Kategori: <select name =kategorier>';
while ($rad15 = $resultat15->fetch_assoc()) {
echo '<option value='. $rad15['id'] . '>' . $rad15['kategori'] . '</option><br>';
}
echo '</select>';
}
}
echo '<br><button name= . $id2' . '>Uppdatera</button>';
if (isset($_POST[$id2])) {
$kategorier = $_POST['kategorier'];
$betyg = $_POST['betyg'];
$serier = $_POST['serier'];
$säsonger = $_POST['säsonger'];
if(strlen($kategorier) && strlen($säsonger) && strlen($serier) && strlen($betyg)) {
$sql12 = '"UPDATE läggtill SET kategorier="" . $kategorier . "", säsonger="" . $säsonger . "", serier="" . $serier . "","
. " betyg="" . $betyg . "" WHERE id2="" . $id2 . "";';
if($resultat9 == $mysqli->query($sql12)) {
header('location: alla.php');
} else {
echo 'Det misslyckades';
}
}
}
}
echo "</form>";
echo "</div>";`**enter code here**`
check have updated few things, hope it will work out
<?php
$sql8 = 'SELECT läggtill.serier, läggtill.id, läggtill.id2, läggtill.säsonger, läggtill.betyg, kategorier.kategori from läggtill inner join'
. ' kategorier on läggtill.kategorier=kategorier.id order by läggtill.serier';
$resultat8 = $mysqli->query($sql8);
$antal8 = $resultat8->num_rows;
while ($rad8 = $resultat8->fetch_assoc()) {
echo "<li>" . $rad8['serier'] . ', ' . $rad8['säsonger'] . ' Säsonger, ' . $rad8['kategori'] . '<br>' .
'Betyg: ' . $rad8['betyg'] . '/10 </li>' . '<br>';
$id = $rad8['id'];
?>
<?php
echo '<form action="alla.php" method="POST">
<button name=' . $id . '>Ta bort</button>
</form>'
?>
<?php
if (isset($_POST[$id])) {
$sql9 = "Delete from läggtill where id=" . $id . " LIMIT 1";
if ($resultat9 === $mysqli->query($sql9)) {
header('location: alla.php');
} else {
echo "det misslyckades.";
}
echo "asdasd";
}
$id2 = $rad8['id2'];
echo "<div class=" . 'Update' . '>'
?>
<?php
echo "<form action='alla.php' method='POST'>
<label for='serier'>Serie: </label>
<input type='text' name='serier' id='serier'><br>";
$sql14 = 'SELECT * FROM kategorier';
$resultat14 = $mysqli->query($sql14);
$antal14 = $resultat14->num_rows;
if ($antal14 == 0) {
echo 'Inget funnet';
} else {
$sql15 = 'SELECT kategori, id FROM kategorier';
$resultat15 = $mysqli->query($sql15);
$antal15 = $resultat15->num_rows;
if ($antal15 == 0) {
echo 'Inget kategori funnen';
} else {
echo 'Kategori: <select name =kategorier>';
while ($rad15 = $resultat15->fetch_assoc()) {
echo '<option value=' . $rad15['id'] . '>' . $rad15['kategori'] . '</option><br>';
}
echo '</select>';
}
}
echo '<br><button name= . $id2' . '>Uppdatera</button></form>';
if (isset($_POST[$id2])) {
$kategorier = $_POST['kategorier'];
$betyg = $_POST['betyg'];
$serier = $_POST['serier'];
$säsonger = $_POST['säsonger'];
if (strlen($kategorier) && strlen($säsonger) && strlen($serier) && strlen($betyg)) {
$sql12 = '"UPDATE läggtill SET kategorier="" . $kategorier . "", säsonger="" . $säsonger . "", serier="" . $serier . "","
. " betyg="" . $betyg . "" WHERE id2="" . $id2 . "";';
if ($resultat9 == $mysqli->query($sql12)) {
header('location: alla.php');
} else {
echo 'Det misslyckades';
}
}
}
}
echo "</div>";
Being a complete noob, I'm trying to create a way for my php page to show all data registered in a database when the values of the columns "identity" and "idricovero" are the same ones used at the start of the session.
Currently it shows only the latest data entered, while I'd like the page to "update" with every new data.
Here's the code
<html>
<body>
<?php
require "connessione.php";
$operatore="";
session_start();
if (!empty($_SESSION['username'])) {$operatore = $_SESSION['username'];}
$idpazok = $idricok = $cartellaok = 0;
$identity = $idpaz = "";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
if (!empty($_GET['identity'])) {
$identity = test_input($_GET['identity']);
$idpazok = 1;
}
if (!empty($_GET['idricovero'])) {
$idricovero = test_input($_GET['idricovero']);
$idricok = 1;
}
}
if ($idricok AND $idpazok) {
//prendo i dati della cartella paziente
$query = "SELECT * FROM Accertamentomirato WHERE `identity` = '".$identity."' AND idricovero = '".$idricovero."'";
//echo "<h2>".$query."</h2>";
$results = mysqli_query($conn, $query);
if (mysqli_num_rows($results) > 0) {
$row = mysqli_fetch_assoc($results);
$dataorarilevazione = $row['dataorarilevazione'];
$csm1 = $row['csm1'];
$csm2 = $row['csm2'];
$csm3 = $row['csm3'];
$cartellaok=1;
} else {
echo "<h2 class=error> Cartella paziente non esistente</h2>"; //.mysqli_error($conn);
}
mysqli_free_result($results);
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if ($cartellaok) {
echo "<h1>" . "ACCERTAMENTO MIRATO" . "</h1>";
echo "<fieldset>";
echo "<legend>".$datarilevazione. "</legend>";
echo "<fieldset>";
echo "<legend>".$orarilevazione."</legend>";
echo "<table>";
if (!empty($csm1)) {echo "<tr> " . "<td> " . "TEMPO DI REMPIMENTO CAPILLARE: " . "</td> " . "<td>".$csm1."</td> " . "</tr>";}
if (!empty($csm2)) {echo "<tr> " . "<td> " . "SENSIBILITÀ TATTILE: " . " </td> " . "<td>".$csm2."</td> " . "</tr>";}
if (!empty($csm3)) {echo "<tr> " . "<td> " . "MOBILITÀ DELLE ESTREMITÀ: " . "</td> " . "<td>".$csm3."</td> " . "</tr>";}
echo "<tr> " . "<td> " . "Operatore: " . "</td> " . "<td>".$operatore." </td> " . "</tr>";
echo "</table>";
echo "</fieldset>";
echo "</fieldset>";
}
?>
</body>
</html>
I have an HTML form where I can add first name, last name and phone number. When I try to insert a value into the phone number field I get this error:
message from webpage
For the first name and last name fields it works everytime.I'm using google chrome. Could be a browser error or it is a code error?
This is the part of code which includes the form:
require('libraries/Interview.class.php');
require('libraries/PhoneBook.class.php');
require('libraries/Beneficiari.class.php');
require('libraries/Marci.class.php');
require('libraries/Modele.class.php');
require_once('connect.php');
require('libraries/Agentii.class.php');
require ("include/callcenter-header.php");
$_SESSION['username'] = 'admin';
$phone_no ="";
if (strlen($phone_no) == 9) {
$contact = PhoneBook::listBYPhoneNo($phone_no, $conn);
$selected_contact = null;
$beneficiari = Beneficiari::listAllNoOwner($db);
$content_agentii = "<option value=''>Alege agentie</option>";
$content_beneficiari = "<option value=''>Alege beneficiar</option>";
$btn_add_new = "";
$selected_bname = "";
$selected_aname = "";
if ($contact) {
if (count($contact) == 0) {
$selected_contact = $contact[0];
} else {
for ($x = 0; $x < count($contact); $x++) {
if ($contact[$x]['default'] == 0) {
$selected_contact = $contact[$x];
}
}
}
$agentii = Agentii::listAll_byBeneficiar($selected_contact['id_beneficiar'], $db);
for ($b = 0; $b < count($beneficiari); $b++) {
if ($selected_contact['id_beneficiar'] == $beneficiari[$b]['id']) {
$selected_bname = $beneficiari[$b]['nume'];
};
$selected = ($selected_contact['id_beneficiar'] == $beneficiari[$b]['id'] ? "selected = 'selected'" : '');
$content_beneficiari .= "<option " . $selected . " value='" . $beneficiari[$b]['id'] . "'>" . $beneficiari[$b]['nume'] . "</option>";
}
for ($a = 0; $a < count($agentii); $a++) {
if ($selected_contact['agency_id'] == $agentii[$a]['id']) {
$selected_aname = $agentii[$a]['nume'];
};
$selected = ($selected_contact['agency_id'] == $agentii[$a]['id'] ? "selected = 'selected'" : '');
$content_agentii .= "<option " . $selected . " value='" . $agentii[$a]['id'] . "'>" . $agentii[$a]['nume'] . "</option>";
}
$btn_upd = "<button class='upd_pb'>Actualizeaza info</button>";
} else {
for ($b = 0; $b < count($beneficiari); $b++) {
$content_beneficiari .= "<option value='" . $beneficiari[$b]['id'] . "'>" . $beneficiari[$b]['nume'] . "</option>";
}
$selected_contact = null;
$agentii = null;
$btn_add_new = "<button class='add_new_pb'>Inregistreaza contact</button>";
}
}
?>
<script>
function OnNewCall(myCallTraceId, callParams)
{
$.ajax({
type: "POST",
url: "dynamic/dynamic.functions.cc_interview.php",
data: {ck_new_call: myCallTraceId, callParams: callParams},
success: function (response) {
$('#contact_info_form').html(response);
$('#flt9_assets').val($("#res_client_company option:selected").html());
$('#flt10_assets').val($("#res_client_agency option:selected").html().split(",")[0]);
filterData(1);
}
});
}
</script>
<br/>
<div style="text-align: left" class="contact_info">
<fieldset>
<legend>Informatii client</legend>
<table id="contact_info_form">
<tr>
<td><label>Call Trace ID :</label><br/><input type="text" id="res_ctid" value="-" /></td>
</tr>
<tr>
<td><label>Nume :</label><br/><input type="text" id="res_client_firstname" value="<?php echo #$selected_contact['first_name']; ?>" /></td>
<td><label>Prenume :</label><br/><input type="text" id="res_client_lastname" value="<?php echo #$selected_contact['last_name']; ?>"/></td>
<td><label>Telefon :</label><br/><input type="text" readonly="readonly" id="res_client_phone" value="<?php echo $phone_no; ?>"/></td>
<td><label>Email :</label><br/><input type="text" id="res_client_email" value="<?php echo #$selected_contact['email']; ?>"/></td>
</tr>
<tr>
<td><label>Beneficiar :</label><br/><select id="res_client_company"><?php echo $content_beneficiari; ?></select></td>
<td><label>Agentia :</label><br/><select id="res_client_agency" ><?php echo $content_agentii; ?></select></td>
<td><label>Adresa :</label><br/><input type="text" id="res_client_address" value="<?php echo #$selected_contact['adresa_agentie']; ?>"/></td>
<td><span id="contact_info_act_btn"><?php echo $btn_add_new; ?><?php echo $btn_upd; ?></span></br><span id="btn_act_resp"></span></td>
</tr>
</table>
</fieldset>
<script>
$('#contact_info_form').on('change', '#res_client_company', function () {
$('#flt9_assets').val($("#res_client_company option:selected").html());
$('#flt10_assets').val('');
filterData(1);
$.ajax({
type: "POST",
url: "dynamic/dynamic.functions.agentii.php",
data: {req_benef: $(this).val()},
beforeSend: function () {
$('#res_client_agency').html('');
},
success: function (response) {
$('#res_client_agency').html(JSON.parse(response));
}
});
});
$('#contact_info_form').on('change', '#res_client_agency', function () {
if ($("#res_client_agency option:selected") !== null) {
$('#flt10_assets').val($("#res_client_agency option:selected").html().split(",")[0]);
filterData(1);
}
});
$('#contact_info_form').on('click', '.add_new_pb', function () {
var request = {
first_name: $('#res_client_firstname').val(),
last_name: $('#res_client_lastname').val(),
phone: $('#res_client_phone').val(),
email: $('#res_client_email').val(),
company: $('#res_client_company').val(),
agency: $('#res_client_agency').val(),
address: $('#res_client_address').val()
};
$.ajax({
type: "POST",
url: "dynamic/dynamic.functions.cc_interview.php",
data: {req_new_pb_entry: JSON.stringify(request)},
beforeSend: function () {
$('#contact_info_act_btn').html('');
},
success: function (response) {
var resp = JSON.parse(response);
if (resp['result']) {
$('#contact_info_act_btn').html(resp['html']);
$('#btn_act_resp').html("Contactul a fost inregistrat cu succes !");
} else {
$('#contact_info_act_btn').html(resp['html']);
$('#btn_act_resp').html("Contactul nu a putut fi inregistrat !");
}
}
});
});
$('#contact_info_form').on('click', '.upd_pb', function () {
var request = {
first_name: $('#res_client_firstname').val(),
last_name: $('#res_client_lastname').val(),
phone: $('#res_client_phone').val(),
email: $('#res_client_email').val(),
company: $('#res_client_company').val(),
agency: $('#res_client_agency').val(),
address: $('#res_client_address').val()
};
$.ajax({
type: "POST",
url: "dynamic/dynamic.functions.cc_interview.php",
data: {req_upd_pb_entry: JSON.stringify(request)},
beforeSend: function () {
$('#contact_info_act_btn').html('');
},
success: function (response) {
var resp = JSON.parse(response);
if (resp['result']) {
$('#contact_info_act_btn').html(resp['html']);
$('#btn_act_resp').html("Contactul a fost actualizat cu succes !");
} else {
$('#contact_info_act_btn').html(resp['html']);
$('#btn_act_resp').html("Contactul nu a putut fi actualizat !");
}
}
});
});
$('#res_client_phone').on('click', '', function () {
try
{
window.external.Dial($('#res_client_phone').val(), 0, -1);
} catch (err)
{
alert("Error on Dial Function !" + err);
}
});
</script>
</div>
And this is the dynamic.functions.cc_interview.php code:
require '../connect.php';
/*
* WHEN user selects an equipment
*/
if (isset($_POST['cci_set_et'])) {
$echipID = str_replace('act_lnk_', '', $_POST['cci_set_et']);
require '../libraries/Interview.class.php';
require '../libraries/Echipamente.class.php';
require '../libraries/Ingineri_service.class.php';
$echipament = Echip::listEchipId($echipID, $db);
$ingineri = Ingineri_service::listAllDistinct($db);
$question = Interview::listFirstQuestionByEchip($echipID, $conn);
#$answers = Interview::listAnswers($question[0]['id'], $conn);
$response = array();
$html = "";
$html .= "<tr class='qRow' id='qRow-" . $_POST['q_count'] . "'><td>" . #$question[0]['text'] . "</td>";
$html .= "<td><input type='hidden' id='qR-" . #$question[0]['id'] . "' value=''><input type='hidden' id='qRid-" . $question[0]['id'] . "' value=''>";
for ($x = 0; $x < count($answers); $x++) {
switch (#$question[0]['multiple_choice']) {
case 0 :
$name = "q" . $question[0]['id'] . "";
break;
case 1 : $name = "q" . $question[0]['id'] . "-" . $answers[$x]['id'];
break;
default : $name = "q" . $question[0]['id'] . "";
}
$html .= "<div>" . $answers[$x]['text'] . " <input class='in_qResp' name='" . $name . "' type='" . $answers[$x]['input_type'] . "' id='R-" . $answers[$x]['id'] . "-" . $answers[$x]['next_question_id'] . "' value='" . $answers[$x]['text'] . "' /> ";
if ($answers[$x]['has_hint'] == 1) {
$html .= " | <a class='ahint'>HINT</a><div class='tooltip'>content</div>";
}
$html .= "</div>";
}
$html .= "<button class='qSubmit' id='qS-" . #$question[0]['id'] . "'>Submit</buton></td></tr>";
$ingineri_html = "";
for ($i = 0; $i < count($ingineri); $i++) {
$selected = ($ingineri[$i]['inginer_service'] == $echipament[0]['inginer_service'] ? "selected='selected'" : "");
$ingineri_html .= "<option " . $selected . " value='" . $ingineri[$i]['inginer_service'] . "'>" . ucwords(str_replace('.', ' ', $ingineri[$i]['inginer_service'])) . "</option>";
}
$response['question']['id'] = $question[0]['id'];
$response['equip_class'] = $echipament[0]['categorie'];
$response['equip_mark'] = $echipament[0]['numeMarca'];
$response['equip_model'] = $echipament[0]['numeModel'];
$response['equip_serial'] = $echipament[0]['serie'];
$response['equip_cod'] = $echipament[0]['cod'];
$response['agency_id'] = $echipament[0]['agentie'];
$response['question']['text'] = $question[0]['text'];
$response['question']['response'] = "";
$response['engineer_html'] = $ingineri_html;
$response['html'] = $html;
echo json_encode($response);
}
/*
* When user submits an answer
*/
if (isset($_POST['cci_set_nq'])) {
$answer_token = explode('-', $_POST['cci_set_nq']);
$answer_id = $answer_token[1];
require '../libraries/Interview.class.php';
$selected_answer = Interview::findAnswer($answer_id, $conn);
$question = Interview::listNextQuestionByAnswer($answer_id, $conn);
$answers = Interview::listAnswers($question[0]['id'], $conn);
$response = array();
$html = "";
$html .= "<tr class='qRow'><td>" . $question[0]['text'] . "</td>";
$html .= "<td><input type='hidden' id='qR-" . $question[0]['id'] . "' value=''><input type='hidden' id='qRid-" . $question[0]['id'] . "' value=''>";
for ($x = 0; $x < count($answers); $x++) {
switch ($question[0]['multiple_choice']) {
case 0 :
$name = "q" . $question[0]['id'] . "";
break;
case 1 : $name = "q" . $question[0]['id'] . "-" . $answers[$x]['id'];
break;
default : $name = "q" . $question[0]['id'] . "";
}
$html .= "<div>" . $answers[$x]['text'] . " <input class='in_qResp' name='" . $name . "' type='" . $answers[$x]['input_type'] . "' id='R-" . $answers[$x]['id'] . "-" . $answers[$x]['next_question_id'] . "' value='" . $answers[$x]['text'] . "' /> ";
if ($answers[$x]['has_hint'] == 1) {
$html .= " | <a class='a_hint'>HINT</a><div class='tooltip'></div>";
}
$html .= "</div>";
}
$html .= "<button class='qSubmit' id='qS-" . $question[0]['id'] . "'>Submit</buton></td></tr>";
$response['question']['id'] = $question[0]['id'];
$response['question']['text'] = $question[0]['text'];
$response['question']['response'] = "";
$response['action'] = $selected_answer['action'];
$response['html'] = $html;
echo json_encode($response);
}
/*
* Function to insert new action into table actuni when agent decides so .
*/
if (isset($_POST['cci_set_aNi'])) {
require '../libraries/Actiuni.class.php';
$request = json_decode($_POST['cci_set_aNi']);
$request->equip_id = str_replace('act_lnk_', '', $request->equip_id);
$request->resolution->interview_string = "Reprezentant client : " . $request->client_first_name . " " . $request->client_last_name . " \n " .
"Telefon client : " . $request->call_id . " \n" .
"Rezultat interviu : \n" . $request->resolution->interview_string . " \n";
// $id_sesizare = Actiuni::insert('call_incident', date('Y-m-d H:i'), $request->deadline, $request->engineer, $request->equip_id, $request->resolution->interview_string, 'nevalidata', date('H:i'), $_SESSION['username'], $request->agency_id, '0', 'RON', $db);
$id_sesizare = 212312;
echo $id_sesizare;
}
/*
* Function to insert new Phone Book entry into table phone_book
*/
if (isset($_POST['req_new_pb_entry'])) {
require '../libraries/PhoneBook.class.php';
$request = json_decode($_POST['req_new_pb_entry']);
$inserted = PhoneBook::insert($request->first_name, $request->last_name, $request->phone, $request->email, $request->agency, $conn);
if ($inserted) {
$response['result'] = TRUE;
$response['html'] = "<button class='upd_pb'>Actualizeaza info</button>";
} else {
$response['result'] = FALSE;
$response['html'] = "<button class='add_new_pb'>Inregistreaza contact</button>";
}
echo json_encode($response);
}
if (isset($_POST['req_upd_pb_entry'])) {
require '../libraries/PhoneBook.class.php';
$request = json_decode($_POST['req_upd_pb_entry']);
$updated = PhoneBook::update($request->first_name, $request->last_name, $request->phone, $request->email, $request->agency, $conn);
$response = array();
if ($updated) {
$response['result'] = TRUE;
$response['html'] = "<button class='upd_pb'>Actualizeaza info</button>";
} else {
$response['result'] = FALSE;
$response['html'] = "<button class='upd_pb'>Actualizeaza info</button>";
}
echo json_encode($response);
}
if (isset($_POST['ck_new_call'])) {
$callTraceId = $_POST['ck_new_call'];
$callParams = $_POST['callParams'];
parse_str($callParams, $callParams_arr);
require('../libraries/PhoneBook.class.php');
require('../libraries/Beneficiari.class.php');
require('../libraries/Agentii.class.php');
$phone_no = intval($callParams_arr['MCC_ANI']);
if (strlen($phone_no) == 9) {
$contact = PhoneBook::listBYPhoneNo($phone_no, $conn);
$selected_contact = null;
$beneficiari = Beneficiari::listAllNoOwner($db);
$content_agentii = "<option value=''>Alege agentie</option>";
$content_beneficiari = "<option value=''>Alege beneficiar</option>";
$btn_add_new = "";
$selected_bname = "";
$selected_aname = "";
if ($contact) {
if (count($contact) == 0) {
$selected_contact = $contact[0];
} else {
for ($x = 0; $x < count($contact); $x++) {
if ($contact[$x]['default'] == 0) {
$selected_contact = $contact[$x];
}
}
}
$agentii = Agentii::listAll_byBeneficiar($selected_contact['id_beneficiar'], $db);
for ($b = 0; $b < count($beneficiari); $b++) {
if ($selected_contact['id_beneficiar'] == $beneficiari[$b]['id']) {
$selected_bname = $beneficiari[$b]['nume'];
};
$selected = ($selected_contact['id_beneficiar'] == $beneficiari[$b]['id'] ? "selected = 'selected'" : '');
$content_beneficiari .= "<option " . $selected . " value='" . $beneficiari[$b]['id'] . "'>" . $beneficiari[$b]['nume'] . "</option>";
}
for ($a = 0; $a < count($agentii); $a++) {
if ($selected_contact['agency_id'] == $agentii[$a]['id']) {
$selected_aname = $agentii[$a]['nume'];
};
$selected = ($selected_contact['agency_id'] == $agentii[$a]['id'] ? "selected = 'selected'" : '');
$content_agentii .= "<option " . $selected . " value='" . $agentii[$a]['id'] . "'>" . $agentii[$a]['nume'] . "</option>";
}
$btn_upd = "<button class='upd_pb'>Actualizeaza info</button>";
} else {
for ($b = 0; $b < count($beneficiari); $b++) {
$content_beneficiari .= "<option value='" . $beneficiari[$b]['id'] . "'>" . $beneficiari[$b]['nume'] . "</option>";
}
$selected_contact = null;
$agentii = null;
$btn_add_new = "<button class='add_new_pb'>Inregistreaza contact</button>";
}
$response = "";
$response .="<tr>";
$response .="<td colspan=\"2\"><label>CALL TRACEID :</label><br/><input type=\"text\" id=\"res_ctid\" value=\"" .$callTraceId. "\" /></td>";
$response .="</tr>";
$response .="<tr>";
$response .="<td><label>Nume :</label><br/><input type=\"text\" id=\"res_client_firstname\" value=\"" . #$selected_contact['first_name'] . "\" /></td>";
$response .="<td><label>Prenume :</label><br/><input type=\"text\" id=\"res_client_lastname\" value=\"" . #$selected_contact['last_name'] . "\"/></td> ";
$response .="<td><label>Telefon :</label><br/><input type=\"text\" id=\"res_client_phone\" value=\"" . $phone_no . "\"/></td>";
$response .="<td><label>Email :</label><br/><input type=\"text\" id=\"res_client_email\" value=\"" . #$selected_contact['email'] . "\"/></td>";
$response .="</tr>";
$response .="<tr>";
$response .="<td><label>Beneficiar :</label><br/><select id=\"res_client_company\">" . $content_beneficiari . "</select></td>";
$response .="<td><label>Agentia :</label><br/><select id=\"res_client_agency\" >" . $content_agentii . "</select></td>";
$response .="<td><label>Adresa :</label><br/><input type=\"text\" id=\"res_client_address\" value=\"" . #$selected_contact['adresa_agentie'] . "\"/></td>";
$response .="<td><span id=\"contact_info_act_btn\">" . $btn_add_new . "" . $btn_upd . "</span></br><span id=\"btn_act_resp\"></span></td>";
$response .="</tr>";
error_log($response);
echo $response;
}
}
?>
PHP beginner on line:).
I have two files (viewKands.php-listing records and izbrisi.php-for deleting records from database. I try to delete record from db(upisi). But no luck.
Here is the code...Where is my mistake?
viewKands.php:
$kon = mysqli_connect("localhost", "root", "", "upisi");
$kon->set_charset("utf8");
if (mysqli_connect_error()) {
echo "Greska pri konekcija so baza: " . mysql_error();
}
$sqlView = "SELECT idPrijava,brPrijava,jazik,struka,profil,imeKand,tatIme,"
. "prezKand from tblprijava ";
$result = mysqli_query($kon, $sqlView);
$rBr = 1;
while ($rowV = $result->fetch_assoc()) {
$id = $rowV["idPrijava"];
echo "<tr><td>" . $rBr . "</td><td>" . $rowV["brPrijava"] . "</td><td>" . $rowV["jazik"] . "</td><td>" . $rowV["struka"] .
"</td><td>" . $rowV["profil"] . "</td><td>" . $rowV["imeKand"] . " " . $rowV["tatIme"] . " " . $rowV["prezKand"] .
"</td><td><a href='uredi.php'>Уреди</a></td>" . " <td><a href='izbrisi.php?id=$id'>X</a></td>" . "</td></tr>";
$rBr++;
}
And izbrisi.php (for deleting records)
$delkon = mysqli_connect("localhost", "root","","upisi");
$delkon->set_charset("utf8");
if (isset($_GET["idPrijava"]) != "") {
$delete = $_GET["idPrijava"];
$dqry = "DELETE FROM tblprijava WHERE idPrijava='$delete'";
$delete = mysqli_query($delkon, $dqry);
if ($delkon->query($dqry) === TRUE) {
header("Location:viewKands.php");
} else {
echo mysqli_error($delete);
}
} else {
echo "ID error";
}
$delkon->close();
Change code to izbrisi.php
$delkon = mysqli_connect("localhost", "root","","upisi");
$delkon->set_charset("utf8");
if (isset($_GET["id"]) != "") {
$delete = $_GET["id"];
$dqry = "DELETE FROM tblprijava WHERE idPrijava='$delete'";
$delete = mysqli_query($delkon, $dqry);
if ($delkon->query($dqry) === TRUE) {
header("Location:viewKands.php");
} else {
echo mysqli_error($delete);
}
} else {
echo "ID error";
}
$delkon->close();
Trying to access object parameter value from the class in function print_debug_info() and getting runtime error.
class debugInfoAPICall
{
var $uri = "";
var $request = "";
var $response = "";
var $signature = "";
var $timestamp = "";
var $exectime = -1;
var $httpcode = -1;
function __construct($uri, $request, $response, $signature, $timestamp, $exectime, $httpcode) {
$this->uri = $uri;
$this->request = $request;
$this->response = $response;
$this->signature = $signature;
$this->timestamp = $timestamp;
$this->exectime = $exectime;
$this->httpcode = $httpcode;
}
function print_debug_info (){
echo "<b>API:</b> <font class=\"text-info\">" . $this->$uri . "</font> <br>";
if ($this->httpcode != 200){
echo "<span class=\"glyphicon glyphicon-alert\" style=\"color:#FF8C00\"></span> <b>Response Time:</b> <font class=\"text-danger\">" . $this->httpcode . "</font> <br>";
}else{
echo "<b>HTTP Code:</b> " . $this->httpcode . " <br>";
}
if ($this->exectime > 500){
echo "<span class=\"glyphicon glyphicon-alert\" style=\"color:#FF8C00\"></span> <b>Response Time:</b> <font class=\"text-danger\">" . $this->$exectime . " ms</font> <br>";
}else{
echo "<b>Response Time:</b> " . $this->exectime . " ms<br>";
}
echo "<b>Timestamp:</b> " . $this->timestamp . " <br>";
echo "<b>Signature:</b> " . $this->signature . " <br><br>";
echo "<b>Request Data JSON:</b> <pre>" . $this->request . "</pre> <br>";
echo "<b>Response Data JSON:</b> <pre>" . $this->response . "</pre> <br>";
}
}
When accessing from outside the class there is no problem to get the parameter values of the object and print them so the below works fine.
foreach ($apiCallLog as &$value) {
echo "<b>URI:</b> " . $value->uri . " <br>";
if ($value->httpcode != 200){
echo "<span class=\"glyphicon glyphicon-alert\" style=\"color:#FF8C00\"></span> <b>Response Time:</b> <font class=\"text-danger\">" . $value->httpcode . "</font> <br>";
}else{
echo "<b>HTTP Code:</b> " . $value->httpcode . " <br>";
}
if ($value->exectime > 500){
echo "<span class=\"glyphicon glyphicon-alert\" style=\"color:#FF8C00\"></span> <b>Response Time:</b> <font class=\"text-danger\">" . $value->exectime . " ms</font> <br>";
}else{
echo "<b>Response Time:</b> " . $value->exectime . " ms<br>";
}
echo "<b>Timestamp:</b> " . $value->timestamp . " <br>";
echo "<b>Signature:</b> " . $value->signature . " <br>";
echo "<b>Request Data JSON:</b> <pre>" . $value->request . "</pre> <br>";
echo "<b>Response Data JSON:</b> <pre>" . $value->response . "</pre> <br>";
}
unset($value);
However this one is not working and throwing: Notice: Undefined variable: uri in /path/functions.php on line 27
foreach ($apiCallLog as &$value) {
$value->print_debug_info();
}
In print_debug_info, change
$this->$uri
to
$this->uri
Also, change all like this (remove the $ after the -> everywhere in print_debug_info). This is the proper way to access class parameters. These were probably just typos in your code. ;)