Jump to content

how to hide the echo?


mark103

Recommended Posts

Hi guys

 

I would like one of you to help me. I have a bit of trouble with the echo, where I don't want to print out on the php page. The echo that I don't want to print out on my page is "The information have already been updated in the database". I don't want to get rid of them, but I want to hide them in the php unless I update some information using with the methods through $username and $name.

 

Here's the code:

 

<?php
session_start();
    define('DB_HOST', 'localhost');
    define('DB_USER', 'myuser');
    define('DB_PASSWORD', 'mypass');
    define('DB_DATABASE', 'mydbname');
       
    $errmsg_arr = array();
    $errflag = false;

    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
    if(!$link) {
  die('Failed to connect to server: ' . mysql_error());
    }

    $db = mysql_select_db(DB_DATABASE);
    if(!$db) {
  die("Unable to select database");
    }

   function clean($var){

return mysql_real_escape_string(strip_tags($var));
    }
    $username = clean($_GET['user']);
    $password = clean($_GET['pass']);
    $user = clean($_GET['user']);
    $image = clean($_GET['image']);
    $name = clean($_GET['name']);
    if($username == '') {
  $errmsg_arr[] = 'username ID missing';
  $errflag = true;
    }
    if($password == '') {
  $errmsg_arr[] = 'PASSWORD ID missing';
  $errflag = true;
    }

    if($errflag) {
  $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
  echo implode('<br />',$errmsg_arr);
   }
   else {
  $qry="SELECT * FROM members WHERE username='$username' AND passwd='$password'";
  $result=mysql_query($qry) or die('Error:<br />' . $qry . '<br />' . mysql_error());


if(mysql_num_rows($result) > 0) {
  $qrytable1="SELECT id, image, name FROM favorites WHERE username='$username'";
  $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error());
  $row = mysql_fetch_row($result);
  echo "The information have already been updated in the database";
   }
  else {

if(isset($_GET['user'])) {
    $insert[] = 'username = \'' . clean($_GET['user']) .'\'';    
   }
  if(isset($_GET['image'])) {
    $insert[] = 'image = \'' . clean($_GET['image']) . '\'';
   }
  if(isset($_GET['name'])) {
    $insert[] = 'name = \'' . clean($_GET['name']) . '\'';
   }
   $names = implode(',',$insert);
   $sql = "INSERT INTO favorites (username, image, name) VALUES ('$user','$image','$name')";

if (!mysql_query($sql,$link))
  {
  die('<br>Error: ' . mysql_error() . "<br>Query: $sql" );
  }
echo "The information have been updated.";
  }

while ($row = mysql_fetch_array($result1)) {
  echo "<p id='image'>";
  echo $row['image'] . "</p>";
  echo "<p id='name'>";
  echo $row['name'] . "</p>";
  echo '<p id="delete"> <a href="delete.php?id='.$row['id'].'">Delete</a></td>';
  }
}
?> 

 

 

Any advise would be much appreicate.

 

Thanks,

Mark

Link to comment
Share on other sites

He means to change the line

echo "The information have been updated.";

 

into

$info="The information have been updated.";

 

Without the echo in front it won't display until you put

echo $info;

somewhere else

 

(feel free to change $info into anything else you want, the more obscure name the better if you are working on someone else's script)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.