Link to home
Start Free TrialLog in
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
User generated image
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

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

ASKER

attaching the page edit-linkup.php
edit-linkup.php
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

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.
I did the change...it comes up blank...definitely data in the details field of tbl_answers_therapist
User generated image
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.
My guess is that maybe processForm.php is supposed to define $linkup. Can you share that file's code?
Thank you. So how do I define $linkup and where?
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

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
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, No, I did not write the code a friend did.  Playing with it. Will update. Thank you.