lingo5 Posted June 21, 2011 Share Posted June 21, 2011 Hi, I need to echo the "Duplicate Entry Detected." inside a table in the html code of the page. At the moment it's echoing at the top of the page. I know it must be a simple thing to do....but I can't figure it out. <?php $colname_checkdup_RS = "-1"; if (isset($_POST['cliente_email'])) { $colname_checkdup_RS = $_POST['cliente_email']; } mysql_select_db($database_MySQLconnect, $MySQLconnect); $query_checkdup_RS = sprintf("SELECT * FROM t_clientes WHERE cliente_email = %s", GetSQLValueString($colname_checkdup_RS, "text")); $checkdup_RS = mysql_query($query_checkdup_RS, $MySQLconnect) or die(mysql_error()); $row_checkdup_RS = mysql_fetch_assoc($checkdup_RS); $totalRows_checkdup_RS = mysql_num_rows($checkdup_RS); if($totalRows_checkdup_RS==1) { echo "Duplicate Entry Detected."; } else{ $query = "INSERT INTO database.t_clientes (company_name,cliente_calle,cliente_numero,cliente_local,cliente_poblacion,cliente_cp,cliente_provincia,cliente_tel,cliente_fax,cliente_movil,cliente_personadecontacto,cliente_email,cliente_password,cliente_logo) ". "VALUES ('$company_name','$cliente_calle','$cliente_numero','$cliente_local','$cliente_poblacion','$cliente_cp','$cliente_provincia','$cliente_tel','$cliente_fax','$cliente_movil','$cliente_personadecontacto','$cliente_email','$cliente_password','$filePath')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); header("Location: PC_clientes_display.php"); } } ?> Link to comment https://forums.phpfreaks.com/topic/240015-help-with-echoing-a-message/ Share on other sites More sharing options...
TeNDoLLA Posted June 21, 2011 Share Posted June 21, 2011 Instead of echo it directly save the string into variable and echo that variable later elsewhere. $errorMsg = "Duplicate Entry Detected."; // Then echo it if the variable is set. echo isset($errorMsg) ? $errorMsg : ''; Link to comment https://forums.phpfreaks.com/topic/240015-help-with-echoing-a-message/#findComment-1232912 Share on other sites More sharing options...
lingo5 Posted June 21, 2011 Author Share Posted June 21, 2011 Thanks a lot Tendolla, but this is still a little cofusing for me. Could you please indicat how to do that using my code? Link to comment https://forums.phpfreaks.com/topic/240015-help-with-echoing-a-message/#findComment-1232913 Share on other sites More sharing options...
TeNDoLLA Posted June 21, 2011 Share Posted June 21, 2011 Well.. // You replace this echo "Duplicate Entry Detected."; // with this line $errorMsg = "Duplicate Entry Detected."; And then you put this somewhere in the page where you want the message to appear echo isset($errorMsg) ? $errorMsg : ''; Link to comment https://forums.phpfreaks.com/topic/240015-help-with-echoing-a-message/#findComment-1232918 Share on other sites More sharing options...
lingo5 Posted June 21, 2011 Author Share Posted June 21, 2011 Thanks a lot Tendolla, it works fine. Link to comment https://forums.phpfreaks.com/topic/240015-help-with-echoing-a-message/#findComment-1232933 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.