0

I got the above error of shell_exec() has been disabled for security reasons as I haven't used this command in my code(Below).I am try to pass the information from my database table by using a JSON array.

My database has two tables
1) Market
2) signup

Initially i get the rows in the result variable(from my Market Table) and I iterate through these rows and from this result(by using username from Market table) further i apply query to get the data from my signup Table.

Then i got this error:

Warning: shell_exec() has been disabled for security reasons in/home/u636455177/public_html/market.php on line 25

include 'dbconnect.php';

$sql = " SELECT `item`,`encodedimage`,`currentbid`,`time`,`username`,`tag`,`itemdescription` FROM `Market`;";

$json = array();
$result = mysqli_query($con,$sql);

while( $row = mysqli_fetch_array($result) )
{
    $username = $row['username'];
    $sql2 = "SELECT `address`,`city`,`phone`,`email` FROM `signup` WHERE username='$username' ";
    $result2 = mysqli_query($con,$sql2);
    $row2 = mysqli_fetch_array($result2);

    $add = array(
            'encodedImage' => $row['encodedimage'],
            'item' => $row['item'],
            'currentbid' => $row['currentbid'],
            'time' => $row['time'],
                        'username' => $row['username'],
                        'tag' => $row['tag'],
                        'itemdescription' => $row['itemdescription'],
                        `address` => $row2['address'],
                        `city` => $row2['city'],
                        `phone` => $row2['phone'],
                        `email` => $row2['email'] 
            );
    array_push($json,$add);
}

$jsonString = json_encode($json);
echo $jsonString;

?>  

Sample output:

[{"encodedImage":"skdbvksdbv","item":"itemname","currentbid":"200","time":"80:00","username":"hb9996","tag":"electronics","itemdescription":"itemDesc","":"hb99960@gmail.com"}]

One more thing from JSON array i am getting only result of email but other results like address,city,phone are not showing. What was the problem with this and the above error?

Code of dbconnect.php

<?php

$con = mysqli_connect("mysql.hostinger.in","useranme","password","mydb");

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
?>

Link of website and the file where the error is occuring:

http://hammertime.16mb.com
http://hammertime.16mb.com/market.php

harshit batra
  • 75
  • 1
  • 13
  • 1
    Which line of code is line 25? Are you certain `shell_exec` isn't used inside of dbconnect.php? – Nick Aug 03 '16 at 04:18
  • I dont use exec in the dbconnect – harshit batra Aug 03 '16 at 04:21
  • How about my first question? - Which line of code (of what you provided) is line 25? – Nick Aug 03 '16 at 04:22
  • Line no. 25 is `phone` => $row2['phone'], – harshit batra Aug 03 '16 at 04:24
  • are you sure your looking at the right file? –  Aug 03 '16 at 04:24
  • Can you post the contents of dbconnect.php? I suspect your issue is in there... – Nick Aug 03 '16 at 04:27
  • Yes market.php is the file where error occured and dbconnect dosen't have exec command as it simply connect with the database – harshit batra Aug 03 '16 at 04:27
  • 1
    either php is wrong or you are, guess which one i pick –  Aug 03 '16 at 04:29
  • I wonder if you understand how `include` works... When you include another file, it is similar to pre-pending all of the code/content of that file to your current file. The line numbers in the error messages won't correspond the way that you think. Be a little less certain and show more of your code if you want help. – Nick Aug 03 '16 at 04:32
  • the error is NOT possible with the code shown, your clearly looking at the wrong file. –  Aug 03 '16 at 05:52
  • Go to this link hammertime.16mb.com – harshit batra Aug 03 '16 at 06:08
  • In the above link output of market.php is showimg this error you can see the error by yourself. – harshit batra Aug 03 '16 at 06:09
  • Code is working absolutely right .i got error when i write the following lines $username = $row['username']; $sql2 = "SELECT `address`,`city`,`phone`,`email` FROM `signup` WHERE username='$username' "; $result2 = mysqli_query($con,$sql2); $row2 = mysqli_fetch_array($result2); and then in while block address` => $row2['address'], `city` => $row2['city'], `phone` => $row2['phone'], `email` => $row2[' – harshit batra Aug 03 '16 at 06:29
  • possible duplicate of [http://stackoverflow.com/questions/26367359/how-to-run-an-sql-query-inside-a-while-loop-of-another-query](http://stackoverflow.com/questions/26367359/how-to-run-an-sql-query-inside-a-while-loop-of-another-query) – Dhruv Sehgal Aug 09 '16 at 11:06

0 Answers0