PHP Syntax Error... unexpected T_VARIABLE? - php

Full error:
Parse error: syntax error, unexpected T_VARIABLE in /home/u572186424/public_html/safe.php on line 56
I have been staring at line 56 and cannot figure it out...
exit();
The whole file follows:
<?php
include_once("connect.php");
?>
<?
$sql = "SELECT * FROM users WHERE id='" . mysql_real_escape_string($_SESSION['user_id']) . "'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$id = htmlspecialchars($row->id);
$userip = htmlspecialchars($row->userip);
$username = htmlspecialchars($row->username);
$password = htmlspecialchars($row->password);
$account_type = htmlspecialchars($row->account_type);
$money = htmlspecialchars($row->money);
$exp = htmlspecialchars($row->exp);
$req_exp = htmlspecialchars($row->req_exp);
$level = htmlspecialchars($row->level);
$health = htmlspecialchars($row->health);
$max_health = htmlspecialchars($row->max_health);
$lastactive = htmlspecialchars($row->lastactive);
$energy = htmlspecialchars($row->energy);
$max_energy = htmlspecialchars($row->max_energy);
$will = htmlspecialchars($row->will);
$max_will = htmlspecialchars($row->max_will);
$brave = htmlspecialchars($row->brave);
$max_brave = htmlspecialchars($row->max_brave);
$strength = htmlspecialchars($row->strength);
$agility = htmlspecialchars($row->agility);
$guard = htmlspecialchars($row->guard);
$labor = htmlspecialchars($row->labor);
$iq = htmlspecialchars($row->iq);
$rank = htmlspecialchars($row->rank);
?>
<?php
$sql = "SELECT * FROM sitestats WHERE id='1'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$admins = htmlspecialchars($row->admins);
$mods = htmlspecialchars($row->mods);
$hdo = htmlspecialchars($row->hdo);
$admins_ip = htmlspecialchars($row->admins_ip);
$mods_ip = htmlspecialchars($row->mods_ip);
$admin_array = explode("-", $admins);
$mod_array = explode("-", $mods);
$hdo_array = explode("-", $hdo);
$admin_ip_array = explode("-", $admins_ip);
$mod_ip_array = explode("-", $mods_ip);
?>
<html>
<body>
<?
if(isset($_SESSION['user_id'])) {
$sql = "UPDATE users SET lastactive=NOW() WHERE id='" . mysql_real_escape_string($_SESSION['user_id']) . "'";
mysql_query($sql);
}
else{
header("Location: logout.php");
exit(); // Error here
}
$query = "SELECT account_type,rank FROM users WHERE username= "$username";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
if($row['account_type'] == 1){
$row['rank'] = "Player";
$rank = "Player";
}
elseif($row['account_type'] == 2){
$row['rank'] = "VIP";
$rank = "VIP";
}
elseif($row['account_type'] == 3){
$row['rank'] = "HDO";
$rank = "HDO";
}
elseif($row['account_type'] == 4){
$row['rank'] = "Moderator";
$rank = "Moderator";
}
elseif($row['account_type'] == 5){
$row['rank'] = "Admin";
$rank = "Admin";
}
elseif($row['account_type'] == 6){
$row['rank'] = "Owner";
$rank = "Owner";
}
?>
</body>
</html>
How can I fix this problem?

The syntax highlighting shows you. Problem is the extra quote " here:
$query = "SELECT account_type,rank FROM users WHERE username= "$username";
Try:
$query = "SELECT account_type,rank FROM users WHERE username= '$username'";

There are no dots when you concatenate the query and $username:
$query = "SELECT account_type,rank FROM users WHERE username= "$username";

Related

How do i update each array item into mysqli database in one query

With my code below i have array item with multiple record i which to update each record into database with one query but only the last item of each array record was updated here is my code
:
<?php
require("init.php");
$sql = "SELECT item_name, quantity
FROM books WHERE book = 1644445";
$query = mysqli_query($conn, $sql);
while($row = mysqli_fetch_array($query))
{
$da = $row["item_name"];
$qty = $row["quantity"];
$sql = mysqli_query($conn, "SELECT * FROM promo WHERE code = '$da' LIMIT 1");
$productCount = mysqli_num_rows($sql);
if($productCount > 0)
{
while ($row = mysqli_fetch_array($sql))
{
$id = $row["id"];
$type = $row["name"];
$code = $row["recharge"];
}
}
$set="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$coe=substr(str_shuffle($set), 0, 12);
if(preg_match('/(65265)/i', $type))
$type = "20";
if(preg_match('/(562546)/i', $type))
$type = "13";
if(preg_match('/(MTN)/i', $type))
$type = "12";
if(preg_match('/(56556)/i', $type))
$type = "16";
$disp = str_split($code, $type);
for($b = 0; $b<$qty; $b++){
$pin = "$disp[$b]";
$gam = array(0 => array("post" => $pin));
foreach($gam as $gg)
{
$pp = $gg["post"];
$go = mysqli_query($conn, "UPDATE promo SET recharge='$coe$pp' WHERE id=$id");
if($go)
{
echo "<br/> $pp";
echo "<br/> $coe";
}
}
}
}
?>
i appliciate your impact
Try this:
<?php
require("init.php");
$sql = "SELECT item_name, quantity
FROM books WHERE book = 1644445";
$query = mysqli_query($conn, $sql);
while($row = mysqli_fetch_array($query))
{
$da = $row["item_name"];
$qty = $row["quantity"];
$sql = mysqli_query($conn, "SELECT * FROM promo WHERE code = '$da' LIMIT 1");
$productCount = mysqli_num_rows($sql);
if($productCount > 0)
{
while ($row = mysqli_fetch_array($sql))
{
$id = $row["id"];
$type = $row["name"];
$code = $row["recharge"];
}
$set="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$coe=substr(str_shuffle($set), 0, 12);
if(preg_match('/(65265)/i', $type))
$type = "20";
if(preg_match('/(562546)/i', $type))
$type = "13";
if(preg_match('/(MTN)/i', $type))
$type = "12";
if(preg_match('/(56556)/i', $type))
$type = "16";
$disp = str_split($code, $type);
for($b = 0; $b<$qty; $b++){
$pin = "$disp[$b]";
$gam = array(0 => array("post" => $pin));
foreach($gam as $gg)
{
$pp = $gg["post"];
$go = mysqli_query($conn, "UPDATE promo SET recharge='$coe$pp' WHERE id=$id");
if($go)
{
echo "<br/> $pp";
echo "<br/> $coe";
}
}
}
}
}
?>
The update is only executed if $productCount > 0.

mysql SELECT WHERE query inside elseif loop not doing anything and no error

I run my script ( see below ) but the place where industry & keywordrw vars are set it just doesn't do anything
The other queries where just the industry is set works fine
the other 2 that involve doing multiple LIKE queries on the keyword variable don't do anything
<?php
if (!isset($industry)) {
$industry = '';
mysql_select_db($dbn, $dbc);
$limit = 100;
$query = mysql_query("SELECT * FROM listings WHERE (title LIKE '%$keywordrw%' OR description LIKE '%$keywordrw%') LIMIT 0,100", $dbc);
$result = mysql_fetch_assoc($query);
echo mysql_error();
echo $keywordrw;
} elseif (!isset($keyword)) {
$industry = $_GET['industry'];
mysql_select_db($dbn, $dbc);
$limit = 100;
$query = mysql_query("SELECT * FROM listings WHERE category LIKE '$industry' LIMIT 0,100", $dbc);
$result = mysql_fetch_assoc($query);
echo mysql_error();
echo $industry;
} elseif (isset($keyword) && ($industry)) {
mysql_select_db($dbn, $dbc);
$limit = 100;
$query = mysql_query("SELECT * FROM listings WHERE (title LIKE '%$keywordrw%' OR description LIKE '%$keywordrw%') AND (category = '$industry') LIMIT 0,100", $dbc);
$result = mysql_fetch_assoc($query);
echo mysql_error();
echo $keywordrw . '-' . $industry;
} else {
mysql_select_db($dbn, $dbc);
$limit = 100;
$query = mysql_query("SELECT * FROM listings LIMIT 0,100", $dbc);
$result = mysql_fetch_assoc($query);
echo mysql_error();
//echo $keywordrw.'-'.$industry;
}
?>
Changed a few things and updated working code is below
if(!isset($industry))
{
$industry = '';
mysql_select_db($dbn,$dbc);
$limit = 100;
$query = mysql_query("SELECT * FROM listings WHERE title LIKE '%keywordrw%'",$dbc);
$result = mysql_fetch_assoc($query);
echo mysql_error();
} elseif(!isset($keyword)) {
$industry = $_GET['industry'];
mysql_select_db($dbn,$dbc);
$limit = 100;
$query = mysql_query("SELECT * FROM listings WHERE category LIKE '$industry' LIMIT 0,100",$dbc);
$result = mysql_fetch_assoc($query);
echo mysql_error();
} elseif(isset($keyword) &&($industry)){
mysql_select_db($dbn,$dbc);
$limit = 100;
$query = mysql_query("SELECT * FROM listings WHERE (title LIKE '%$keywordrw%' OR description LIKE '%$keywordrw%') AND (category = '$industry') LIMIT 0,100",$dbc);
$result = mysql_fetch_assoc($query);
echo mysql_error();
} else {
mysql_select_db($dbn,$dbc);
$limit = 100;
$query = mysql_query("SELECT * FROM listings LIMIT 0,100",$dbc);
$result = mysql_fetch_assoc($query);
echo mysql_error();
//echo $keywordrw.'-'.$industry;
}

PHP Fatal error: Could not queue new timer in Unknown on line 0

I write a simple web application for my compnay that can let user log in to arrange their work time. Besides, user can also view the report of he's or she's attandence that I use ajax to callback from java.jar. (We use java to analyze)I use Xampp to set up the server in virtual machine HyperV and it can run successfully at the begining but after twenty hours or more than one day it won't let anyone to log in.
I open the error.log shows that :
PHP Fatal error: Could not queue new timer in Unknown on line 0
. . . and than:
PHP Warning: mysqli_connect(): (HY000/2002): Unknown Error
I don't understand what can cause that happend and how to solve it.
I alreday know is when I restarted the apache server, it can still be used till that error happened.
My System Enviroment :
win7 64 bit HyperV
xampp Apache/2.4.18, php/7.0.6, mysql/ 5.1
Here is my code:
mysql_start.php
<?php
header("Content-Type:html;charset=utf-8");
$servername = "127.0.0.1";
$username = "root";
$password = "cc1234";
$dbname = "cc_tw000427";
$conn = null;
try {
$conn = new mysqli($servername, $username, $password, $dbname);
} catch (Exception $e) {
$error_message = "Connect Error (" .$conn->connect_errno ." )" . $conn->connect_error;
error_log($error_message, 3, "php_error_log");
header("location:login.php?err=$e");
}
$conn->set_charset("utf-8");
$strDBColLoingAccount = "AccountID";
checklogin.php
session_start();
include_once("mysql_start.php");
$yid = trim(filter_input(INPUT_POST, "yid"));
$passd = trim(filter_input(INPUT_POST,"passd"));
$strSql = "SELECT acc.*, b.String_10_1 FROM basicstoreinfomanageacc_sub acc,basicstoreinfo b
WHERE acc.$strDBColLoingAccount ='$yid' AND acc.String_50_1 = b.String_50_1";
$result = $conn->query($strSql);
$n = $result->num_rows;
if ($n == 0) {
header("Location:../desktop/login.php?err=1");
echo "Error 1";
exit();
}
while ($row = $result->fetch_assoc()) {
$passd_right = $row["AccountPwd"];
$user_id = $row["AccountID"];
$user_name = $row["AccountName"];
$user_dep_id = $row["String_10_1"];
$user_dep = $row['String_50_1'];
}
$result->close();
if (($passd_right == "") || ($passd_right == NULL)){
session_start();
$_SESSION['user_id'] = $user_id;
$_SESSION['user_name'] = $user_name;
header("location:newpwd.php");
exit();
}
if ($passd == $passd_right) {
$_SESSION['user_id'] = $user_id;
$_SESSION['user_name'] = $user_name;
$_SESSION['loginOK'] = 'yes';
$_SESSION['year_i'] = date('Y',time());
$_SESSION['year_f'] = date('Y',time());
$_SESSION['month_i'] = date('m',time());
$_SESSION['month_f'] = date('m',time());
$_SESSION['day_i'] = date('d',time());
$_SESSION['day_f'] = date('d',time());
$_SESSION['Hour'] = date('Y-m-d G:i:s',strtotime('+6 hour'));
$_SESSION['user_dep_id'] = $user_dep_id;
$_SESSION['user_dep'] = $user_dep;
header("Location:../desktop/Punch.php");
} else {
header("Location:../desktop/login.php?err=1");
}
$conn->close();
?>
Next two *.php files are used to receive the post from the web.
The select.php is used to select the data from mysql than output in html tag.
The save.php is used to save the data post from web.
select.php
<?php
session_start();
include_once '../control/mysql_start.php';
$strYear = $_POST['year'];
$strMonth = $_POST['month'];
$strDay = $_POST['day'];
.
.//some codes
.
$strSql = "SELECT * FROM basicemploymentinfo bei WHERE bei.BelongStore = '". $_SESSION['user_dep']."'".
"AND ((bei.datetime_2 is null AND bei.datetime_3 is null) OR (bei.datetime_2 is null AND bei.datetime_3 >= STR_TO_DATE('" . $strDate . "', '%Y-%m-%d'))" .
" OR (bei.datetime_2 <= STR_TO_DATE('" . $strDate . "', '%Y-%m-%d') AND bei.datetime_3 is null)" .
" OR (bei.datetime_2 <= STR_TO_DATE('" . $strDate . "', '%Y-%m-%d') AND bei.datetime_3 >= STR_TO_DATE('" . $strDate . "', '%Y-%m-%d'))) "
."AND bei.Active ='Y'";
$EmpId = array();
$EmpName = array();
if ($result = $conn->query($strSql)) {
while($row = $result->fetch_assoc()) {
array_push($EmpId, $row['String_20_1']);
array_push($EmpName, $row['String_20_2']);
.
.//some codes
.
}
}
$Emp = array_combine($EmpId, $EmpName);
$strSql = " SELECT Distinct date_format(DateTime_1, '%e') as date, AutoCheck
FROM hrotcheck
WHERE date_format(DateTime_1, '%Y-%m-%d') = '$newformat'
AND AutoCheck = 'C'
AND String_20_1 IN ($array_emp_id)";
if ($result = $conn->query($strSql)) {
$n = $result->num_rows;
if ($n > 0) { $checkboxVerify = 'C';}
}
$result->close();
foreach ($Emp as $EId => $EName)
{
.
.//some codes
.
$strSql = "SELECT RegularM_1, RegularM_2, FORMAT(OT_3, 1) as OT_3, TOM, TOTM, Notes, AutoCheck FROM hrotcheck where string_20_1 = '" . $EId . "' AND"." date_format(DateTime_1,'%Y-%m-%d') = '$newformat'";
$result = $conn->query($strSql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$RegularM_1 = $row['RegularM_1'];
$RegularM_2 = $row['RegularM_2'];
$OT3 = $row['OT_3'];
$tom = $row['TOM'];
$totm = $row['TOTM'];
$notes = $row['Notes'];
}
}
$result->close();
.
.//I did a lot of SQL select and use that to create htmltable
.
$output .= '
<tr data-table="sub">
<td>'.$row['string_20_1'].'</td>
<td>'.$row['string_20_2'].'</td>
.
.//<td>...</td>
.
<td class="'.$condition16.'">'.$notes.'</td>
<td class="'.$condition17.'"></td>
</tr>
';
}
.
.//some codes
.
$strSql01 = "SELECT * FROM manufacturejobschedulingpersonal where string_20_1 = '".
$row['string_20_1']."' AND"." date_format(DateTime_1,'%Y-%m-%d') = '$newformat'";
$result01 = $conn->query($strSql01);
if ($result01->num_rows > 0) {
while ($row01 = $result01->fetch_assoc()) {
.
.//some codes
.
}
}
$result01->close();
.
.//some codes
.
$result->close();
$conn->close();
echo $optionUse.'?'.$checkboxVerify.'?'.$output.'?'.$hasCheckDate;
?>
save.php
<?php
session_start();
include_once '../control/mysql_start.php';
$arrayObjs = $_POST;
.
.//some codes
.
$msDanger = '';
foreach($arrayObjs as $array)
{
foreach($array as $row)
{
$UserId = $row['UserId'];
$UserName = $row['UserName'];
.
.//some codes
.
$strSql = "SELECT * FROM manufacturejobschedulingpersonal where string_20_1 = '".
$UserId."' AND"." date_format(DateTime_1,'%Y-%m-%d') = '$DateTime_1'";
$result = $conn->query($strSql);
if( $result->num_rows > 0) {
if ($table == 'main') {
$strSql = "Update manufacturejobschedulingpersonal SET String_10_1 ='$String_10_1', String_Assist01 ='$assist_1',String_Assist02='$assist_2' where string_20_1 = '".
$UserId."' AND"." date_format(DateTime_1,'%Y-%m-%d') = '$DateTime_1'";
} else {
$strSql = "Update manufacturejobschedulingpersonal SET String_10_1 ='$String_10_1' where string_20_1 = '".
$UserId."' AND"." date_format(DateTime_1,'%Y-%m-%d') = '$DateTime_1'";
}
$result = $conn->query($strSql);
} else {
$strSql = "INSERT INTO manufacturejobschedulingpersonal (string_20_1,string_20_2,YM,DateTime_1,String_10_1,String_Assist01,String_Assist02)".
"VALUES ( '$UserId', '$UserName', '$YM', '$DateTime_1', '$String_10_1','$assist_1','$assist_2')";
$result = $conn->query($strSql);
}
.
.//A lot of sql CRUD
.
}
}
$conn->close();
$last_line = exec('java -jar C:/CCERP/ChainCodeERP/ExtraModule/HRMultiOTCheck/HRMultiOTCheck.jar -ssa '.$javaDate.' ' .$javaDepId, $return_var);
echo 'Updated';
?>

PHP - sort/order an array by timestamp

Why I am getting 0 instead values from the database? What I am doing wrong if I give $_POST['dataType'] === 'start'. I never call a multiple DB select request. What I am doing wrong?
UPDATED:
if(isset($_POST['dataType'])){
switch ($_POST['dataType']) {
case 'start':
$data_type = 'pictures, videos, audio, documents';
break;
case 'picture':
$data_type = 'pictures';
break;
case 'video':
$data_type = 'videos';
break;
case 'audio':
$data_type = 'audio';
break;
case 'document':
$data_type = 'documents';
break;
default:
$data_type = '';
}
if (!empty($data_type)) {
$userId = mysqli_real_escape_string($connect, $_SESSION['userId']);
if ($_POST['dataType'] !== 'start')
$sql = "SELECT * FROM " . $data_type . " WHERE user_id = " . $userId;
else {
$sql_picture = "SELECT * FROM pictures WHERE user_id = " . $userId . " ORDER BY upload_time";
$sql_videos = "SELECT * FROM videos WHERE user_id = " . $userId . " ORDER BY upload_time";
$sql_audio = "SELECT * FROM audio WHERE user_id = " . $userId . " ORDER BY upload_time";
$sql_documents = "SELECT * FROM documents WHERE user_id = " . $userId . " ORDER BY upload_time";
}
// Check connection
if ($connect->connect_error) {
mysqli_close($connect);
echo 1;
}
else {
if ($_POST['dataType'] !== 'start'){
$result = $connect->query($sql);
if ($result->num_rows > 0) {
$indexOfSuggests = 0;
$data = array();
while ($row = $result->fetch_assoc()) {
$id = $row['id'];
$user_id = $row['user_id'];
$name = $row['name'];
$public = $row['public'];
$link = $row['link'];
$upload_time = $row['upload_time'];
$data[$indexOfSuggests] = array($id, $user_id, $name, $public, $link, $upload_time);
$indexOfSuggests++;
}
$result->free();
echo json_encode($data);
}
else {
echo 0; // keine ergebnisse
}
}
else {
$indexOfSuggests = 0;
$new_index;
$collectData = array();
for($i = 0; $i < 4; $i++){
$indexOfSuggests = $new_index;
if($i == 0)
$sql = $sql_picture;
else
if($i == 1)
$sql = $sql_videos;
else
if($i == 2)
$sql = $sql_audio;
else
if($i == 3)
$sql = $sql_documents;
$result = $connect->query($sql);
if ($result->num_rows > 0) {
$data = array();
while ($row = $result->fetch_assoc()) {
$id = $row['id'];
$user_id = $row['user_id'];
$name = $row['name'];
$public = $row['public'];
$link = $row['link'];
$upload_time = $row['upload_time'];
$data[$indexOfSuggests] = array($id, $user_id, $name, $public, $link, $upload_time);
array_push($collectData, $data[$indexOfSuggests]);
$indexOfSuggests++;
}
$new_index = $indexOfSuggests;
}
else {
// keine ergebnisse
}
}
echo json_encode($collectData);
}
}
}
else {
header("Location: http://google.com");
}
}
So i got it but in a really uncool way. So the last thing I have to do is to order the array values by date.
here is new fix :)
<?php
if (isset($_POST['dataType'])) {
switch ($_POST['dataType']) {
case 'start':
$data_type = 'pictures,videos,audio,documents';
break;
case 'picture':
$data_type = 'pictures';
break;
case 'videos':
$data_type = 'videos';
break;
case 'audio':
$data_type = 'audio';
break;
case 'documents':
$data_type = 'documents';
break;
default:
$data_type = '';
}
function get_list ($sql,&$list) {
// Create connection
$connect = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($connect->connect_error) {
die(1);
} else {
$result = $connect->query($sql);
while ($row = $result->fetch_assoc()) {
$id = $row['id'];
$user_id = $row['user_id'];
$name = $row['name'];
$public = $row['public'];
$link = $row['link'];
$upload_time = $row['upload_time'];
$list[] = array($id, $user_id, $name, $public, $link, $upload_time);
}
}
}
if (!empty($data_type)) {
$list = array();
$userId = mysqli_real_escape_string($_SESSION['userId']);
if ($_POST['dataType'] !== 'start') {
$sql = "SELECT * FROM " . $data_type . " WHERE user_id = " . $userId;
get_list($sql,$list);
} else {
$data_types = explode(',',$data_type);
foreach($data_types as $type) {
$sql = "SELECT * FROM " . $type . " WHERE user_id = " . $userId;
get_list($sql,$list);
}
}
if(empty($list))
die(0);
else
echo json_encode($list);
} else {
header("Location: http://google.com");
}
}
?>

Multiple mysqli select with json

<?php
include"../database_conn.php";
$con=mysqli_connect("localhost","admin","123456","ayurveadic");
$query_pag_data = "SELECT id from diseases";
$result_pag_data = mysql_query($query_pag_data) or die('MySql Error' . mysql_error());
while ($row = mysql_fetch_array($result_pag_data)) {
$diseases_id = $row['id'];
$result = mysqli_query($con,"SELECT $diseases_id FROM treatment WHERE gender_id = '10' AND diseases_id = '$diseases_id'");
$row_gid = mysqli_fetch_array($result);
if ($row_gid == TRUE){
$sl_dise = mysqli_query($con,"SELECT Diseases_type, id FROM diseases WHERE id = '$diseases_id'");
$rowss = array();
while($r = mysqli_fetch_assoc($sl_dise)) {
$rowss[] = $r;
}
print json_encode($rowss);
}
}
Output is:
[{"Diseases_type":"fever","id":"114"}][{"Diseases_type":"rhrh","id":"123"}]
How can i get this output:
[{"Diseases_type":"fever","id":"114"},{"Diseases_type":"rhrh","id":"123"}]
You need to initialize the JSON array before the outer loop, and print it at the very end, not each time through.
<?php
include"../database_conn.php";
$con=mysqli_connect("localhost","admin","123456","ayurveadic");
$query_pag_data = "SELECT id from diseases";
$result_pag_data = mysql_query($query_pag_data) or die('MySql Error' . mysql_error());
$rowss = array();
while ($row = mysql_fetch_array($result_pag_data)) {
$diseases_id = $row['id'];
$result = mysqli_query($con,"SELECT $diseases_id FROM treatment WHERE gender_id = '10' AND diseases_id = '$diseases_id'");
$row_gid = mysqli_fetch_array($result);
if ($row_gid == TRUE){
$sl_dise = mysqli_query($con,"SELECT Diseases_type, id FROM diseases WHERE id = '$diseases_id'");
while($r = mysqli_fetch_assoc($sl_dise)) {
$rowss[] = $r;
}
}
}
print json_encode($rowss);
Here is you optimised code
<?php
include"../database_conn.php";
$con=mysqli_connect("localhost","admin","123456","ayurveadic");
$query_pag_data = "select diseases.Diseases_type,diseases.id from diseases inner join treatment on treatment.diseases_id = diseases.id where treatment.gender_id = '10' ";
$result_pag_data = mysql_query($query_pag_data) or die('MySql Error' . mysql_error());
$rowss = array();
while ($row = mysqli_fetch_assoc($result_pag_data)) {
$rowss[] = $row;
}
print json_encode($rowss);
?>
Put your
print json_encode($rowss);
after end of thiswhile ($row = mysql_fetch_array($result_pag_data)) {
Also remove this $rowss = array(); array initialization

Categories