Avatar of David Schure
David Schure
 asked on

Undefined variable:

Getting this error message..
<br />
<b>Notice</b>:  Undefined variable: linkup in <b>/home/audiodigz/public_html/THERAPIST/edit-linkup.php</b> on line <b>464</b><br />
<br />
<b>Notice</b>:  Trying to get property 'details' of non-object in <b>/home/audiodigz/public_html/THERAPIST/edit-linkup.php</b> on line <b>464</b><br />


Open in new window

Line 464: In Bold
<!--SSTATUS----------------------------------------------->   
            <div class="det"
               <h3>The following will help the Client decide whether to select you or not.  Your photo and you statement will be the only means of helping the Client decide whether its you or another Therapist.  Make it good! </h3><br><br>
         <!--The avatar is pulled from the tbl_client------------>            
         <?php
         $image_query = mysqli_query($conn,"SELECT therapist_avatar FROM tbl_therapist WHERE therapist_id = {$therapist_id} LIMIT 1");
         $therapist = mysqli_fetch_array($image_query);
         $img_src = $therapist['therapist_avatar'];
         ?>
          <div class="AVT">
         <img src="/AVATAR/images/<?php echo $img_src; ?>"  width="230" height="230" id="profileDisplay">
         </div>
               <br>
         <!--DETAILS START-->
            <label style="font-weight: bold" for="review">About You</label><br>
            <textarea id="review" name="review" rows="6" charswidth="25" cols="43" value=""><?php echo $linkup->details; ?></textarea>
            <!--DETAILS START-->      
            <!--At arise.plus you will have access to caring concerned therapist that will understand you.-->
               </div>
               <br>
         <!--COMPLETE START------------------------------------------>

Open in new window

Information in the tbl_answers_therapist

HTMLPHP

Avatar of undefined
Last Comment
David Schure

8/22/2022 - Mon
gr8gonzo

So where in your code are you defining $linkup?
David Schure

ASKER
attaching the page edit-linkup.php
edit-linkup.php
David H.H.Lee

This error means that within your code, there is a variable or constant which is not set. But you may be trying to use that variable.

Check if you have select the 'details' field from database in your select query statement.

The error can be avoided by using the isset() function.This function will check whether the variable is set or not.

<textarea id="review" name="review" rows="6" charswidth="25" cols="43">
<?php
echo isset($linkup->details)?$linkup->details:' ';
?>
</textarea>

Open in new window

Your help has saved me hundreds of hours of internet surfing.
fblack61
gr8gonzo

I don't see $linkup set anywhere in that additional page you provided. It is referenced several times but not actually assigned a value anywhere.
David Schure

ASKER
I did the change...it comes up blank...definitely data in the details field of tbl_answers_therapist

gr8gonzo

FYI - David's suggestion only circumvents the error message and shows a blank instead of the error. It does not resolve the underlying root cause, which is that $linkup is not set in your code. You need to define $linkup.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
gr8gonzo

My guess is that maybe processForm.php is supposed to define $linkup. Can you share that file's code?
David Schure

ASKER
Thank you. So how do I define $linkup and where?
David Schure

ASKER
Here you go..
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

//var_dump($client_id);
//var_dump($client);

$msg = "";
$msg_class = "";

$conn = mysqli_connect(DB_SERVER,DB_USER,DB_PASS,DB_NAME);
// Check connection
if (mysqli_connect_errno())
{
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
  if (isset($_POST['save_profile'])) {
    // for the database
    //$profileImageName = time() . '-' . $_FILES["profileImage"]["name"];
   $profileImageName = $_FILES["profileImage"]["name"];  
    // For image upload
    $target_dir = "../AVATAR/images/";
    $target_file = $target_dir . basename($profileImageName);
    // VALIDATION
    // validate image size. Size is calculated in Bytes
    if($_FILES['profileImage']['size'] > 2000) {
      $msg_class = "alert-danger";
     $msg = "Image size should not be greated than 2MB";
      
    }
    // check if file exists
    if(file_exists($target_file)) {
      $msg_class = "alert-danger";
     $msg = "Avatar already exists";
      
    }
    // Upload image only if no errors
    if (empty($error)) {
      if(move_uploaded_file($_FILES["profileImage"]["tmp_name"], $target_file)) {
        $sql = "UPDATE tbl_therapist SET therapist_avatar='$profileImageName' WHERE therapist_id = {$therapist_id} LIMIT 1";
      
      if(mysqli_query($conn, $sql)){
          $msg_class = "alert-success";
        $msg = "Avatar uploaded and saved";
          
        } else {
          $msg_class = "alert-danger";
        $msg = "There was an error in the database";
          
        }
      } else {
        $msg = "alert-danger";
      $error = "There was an error uploading your avatar";
      }
    }
  }
?>

Open in new window

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
gr8gonzo

That's your application's logic, none of us can tell you that. We can only guess.

I mean, based on usage, I would assume that you should probably have some code that queries the desired row from tbl_answers_therapist as an object and then assigns that value to a variable called $linkup but that's just a guess.

Again, my guess is that that code would be somewhere in processForm.php since it's included at the top but again, just an educated guess. I would have to know your architecture and application pretty well before I could tell you for sure (and that level of help would warrant a separate, paid consulting gig).
ASKER CERTIFIED SOLUTION
gr8gonzo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
David Schure

ASKER
Hi, No, I did not write the code a friend did.  Playing with it. Will update. Thank you.