mark103 Posted January 9, 2011 Share Posted January 9, 2011 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 https://forums.phpfreaks.com/topic/223831-how-to-hide-the-echo/ Share on other sites More sharing options...
inversesoft123 Posted January 9, 2011 Share Posted January 9, 2011 Assign it to variable $info = "The information have already been updated in the database"; Link to comment https://forums.phpfreaks.com/topic/223831-how-to-hide-the-echo/#findComment-1156921 Share on other sites More sharing options...
mark103 Posted January 9, 2011 Author Share Posted January 9, 2011 thanks so what do you mean by "Assign it to variable"? Link to comment https://forums.phpfreaks.com/topic/223831-how-to-hide-the-echo/#findComment-1156929 Share on other sites More sharing options...
yamipoli Posted January 9, 2011 Share Posted January 9, 2011 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 https://forums.phpfreaks.com/topic/223831-how-to-hide-the-echo/#findComment-1156946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.