0
<?php
if(isset($_GET['search']))
{
    $search_record = $_GET['search'];

    $query = "SELECT * FROM semester_result,SUBJECT,std_reg WHERE semester_result.sub_id=subject.sub_id AND 
              semester_result.student_id = std_reg.student_id AND std_reg.roll_no='$search_record' ";

    $run = mysqli_query($conn,$query);

    if ($run->num_rows > 0)
    {
        while($row = mysqli_fetch_array($run))
        {
            $name = $row['fname'];
            $lname = $row['lname'];
            $sub=['subject_name'];
            echo $sub_id=['mid_mrks'];

?>

When I echo $name or $lname it works fine, but when I echo $sub or $sub_id it shows the following error:

Notice: Array to string conversion in C:\wamp\www\semester\content\result.php on line 49.

1
  • 1
    $sub = $row['subject_name']. Commented Oct 8, 2015 at 15:55

2 Answers 2

1

That error is due to passing an array variable to the echo() function, rather than a string.

In your example changing:

    $sub=['subject_name'];

to:

    $sub=$row['subject_name']; 

will fix the problem.

Sign up to request clarification or add additional context in comments.

Comments

1

What about this?

$name = $row['fname'];
$lname = $row['lname'];
$sub = $row['subject_name'];
echo $sub_id = $row['mid_mrks'];

I think you forgot $row in front of ['subject_name']

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.