Jump to content


Photo

why is my echo '<script>alert("Cannot be deleted!")</script>'; is not working?


  • Please log in to reply
14 replies to this topic

#1 phpbigenner

phpbigenner

    Member

  • Members
  • PipPip
  • 19 posts

Posted 11 July 2013 - 03:29 PM

<?php
$act = $rs['actorID'];
$m=mysql_query("SELECT * FROM movie_actor where actorID = '$act'");
$ma = mysql_num_rows($m);
if($ma!=0){
 
echo '<script>alert("Cannot be deleted!")</script>';
 
  }else{
 
echo '<td style="text-align:center"><a href="delete_actor.php?ID='.$row['actorID'].'" onclick="confirmation();return false"> <img height="40" width="40" src="icons/xx.png" /></a>
</td> ';
}
?>


#2 fastsol

fastsol

    Advanced Member

  • Members
  • PipPipPip
  • 235 posts
  • LocationMinnesota

Posted 11 July 2013 - 03:46 PM

Does <script>alert("Cannot be deleted!")</script> actually get echoed if you view the page source after the page loads?  If it is there, what doctype are you using?  I am no pro javascript guy by any stretch of the meaning but I believe that in most doctypes besides html5 you need to specifiy type="text/javascript" in the <script>, not sure if not having that will make it not work but worth a try.


You never know everything, I learn everday!

http://amecms.com

http://amewebdesigns.com


#3 Irate

Irate

    Advanced Member

  • Members
  • PipPipPip
  • 358 posts
  • LocationHamburg, Germany
  • Age:17

Posted 11 July 2013 - 04:36 PM

Try putting in a <meta name="content-script-type" content="text/javascript"> in your head section before the scripts, otherwise do as fastsol said.
Quod placet mihi non placeat tibi. - What I think to be good must not always equal your perception of it.

I am not perfect. I try a lot with the code I provide and I don't guarantee for it to work as I have mostly no option to test it on my mobile phone. I do apologize for any inconvenience I caused, but if I do happen to have helped, liking my posts or marking them as to have solved or answered your question would be nice.

#4 phpbigenner

phpbigenner

    Member

  • Members
  • PipPip
  • 19 posts

Posted 11 July 2013 - 05:05 PM

still not working.



#5 phpbigenner

phpbigenner

    Member

  • Members
  • PipPip
  • 19 posts

Posted 11 July 2013 - 05:06 PM

<?php session_start();?>
<?php require_once("connect.php");?>
<?php 
if(isset($_COOKIE["header"])){
if($_COOKIE["header"]=="admin")
{
include("header_admin.php");
}
else
{
include("header_logout.php");
}






}
elseif($_COOKIE["header"]==NULL){
if($_SESSION['header']=="user"){
include("header_logout.php");
echo "<meta http-equiv='refresh' content='0;url=home.php'>";
}
elseif($_SESSION['header']=="admin"){


include("header_admin.php");


}
else{
include("header_login.php");
echo "<meta http-equiv='refresh' content='0;url=home.php'>";


}
}


?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="content-script-type" content="text/javascript"/>
<title>Star Theater</title>
<link rel="shortcut icon" href="images/favicon.ico" />
<link rel="stylesheet" media="screen" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/table.css"/>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
<!--
function confirmation() {


var msg = "Are you sure you want to delete this lead actor/actress?";
var answer = confirm(msg);
if (answer){
alert('Record successfully deleted!')
document.frm.submit();
}
}
   
</script>
<script>
function myFunction()
{
alert("ayus");
}
</script>
<style>
.highlighted { background:#090; }
</style>


</head>
     <body>


        <div id="content">
        
    
  <div align="right"><a href="f.actor_add.php" > <img src="icons/ad.png" width="70px" height="70px" title="Add new actor" /></a>
</div>




<table class="filterable" id="bordered">
    <thead>
              <tr>
        
          
        <th style="text-align:center">Lastname</th>
        <th style="text-align:center">Firstname</th>  
        <th style="text-align:center">Date of birth</th>      
        <th style="text-align:center">Contact number</th>
        <th style="text-align:center">Address</th>
         <th style="text-align:center">VIEW</th>
        <th style="text-align:center">EDIT</th>
        <th style="text-align:center">DELETE</th>
    </tr>
            </thead>
            <tbody>
<?php
include('conn.php');


        $result = mysql_query("SELECT * FROM actor order by lname")or die(mysql_error());  
        while($row = mysql_fetch_array( $result )) {
                
                echo "<tr>";
                echo '<td>' . $row['lname'] . '</td>';
echo '<td>' . $row['fname'] .'</td>';
echo '<td style="text-align:right">' . $row['dob'] . '</td>';
echo '<td style="text-align:right">' . $row['contact_no'] . '</td>';
echo '<td>' . $row['address'] . '</td>';
echo '<td style="text-align:center"><a href="view_actor.php?ID='.$row['actorID'].'"><img height="40" width="40" src="icons/view.png"/></a>
        </td> ';
echo '<td style="text-align:center"><a href="f.actor_edit.php?ID='.$row['actorID'].'"><img height="40" width="40" src="icons/ed.png" /></a>
        </td> ';


$act = $rs['actorID'];
$m=mysql_query("SELECT * FROM movie_actor where actorID = '$act'");
$ma = mysql_num_rows($m);
if($ma!=0){


echo '<script type="text/javascript">alert("Cannot be deleted!")</script>';


  }else{


echo '<td style="text-align:center"><a href="delete_actor.php?ID='.$row['actorID'].'" onclick="confirmation();return false"> <img height="40" width="40" src="icons/xx.png" /></a>
</td> ';
}
                echo "</tr>";}?>
                
 </tbody>
        </table>
 <script type="text/javascript" src="js/tablesearch.js"></script> 
     </div><!-- /content -->
     
     
        <div id="footer">
           <label>&copy; <a href="https://www.facebook.com/CodeWEBB.Design?fref=ts">CodeWEBB Design</a></label> |<a href="developers.php">&nbsp;Developers</a>
           
        </div><!-- /footer -->
   
    </body>
</html>

Edited by Maq, 11 July 2013 - 05:20 PM.


#6 phpbigenner

phpbigenner

    Member

  • Members
  • PipPip
  • 19 posts

Posted 11 July 2013 - 05:06 PM

my whole code now.



#7 Maq

Maq

    Advanced Member

  • Moderators
  • 9,315 posts
  • LocationPennsylvania, USA

Posted 11 July 2013 - 05:20 PM

Please use code tags in the future.


Electronic Cigarette Reviews - Smoking alternatives, find YOUR ecig! | tjmothy
ini_set ("display_errors", "1");
error_reporting(E_ALL);

#8 fastsol

fastsol

    Advanced Member

  • Members
  • PipPipPip
  • 235 posts
  • LocationMinnesota

Posted 12 July 2013 - 08:05 AM

I don't see anything that stands out as an issue in your code.  Again, are you sure that <script> tags are actually being echoed to the page?  Run your page in the browser and then do a view page source and see if they are in there.  You could also post the view source result here and we can take a look.


You never know everything, I learn everday!

http://amecms.com

http://amewebdesigns.com


#9 phpbigenner

phpbigenner

    Member

  • Members
  • PipPip
  • 19 posts

Posted 12 July 2013 - 09:08 AM

the script didn't echoed.


Edited by phpbigenner, 12 July 2013 - 09:14 AM.


#10 phpbigenner

phpbigenner

    Member

  • Members
  • PipPip
  • 19 posts

Posted 12 July 2013 - 09:09 AM

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">   <head>   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   <title>Star Theater</title>   <link rel="shortcut icon" href="images/favicon.ico" />   <link rel="stylesheet" media="screen" href="css/demo.css" />   </head>   <body>   <div id="demo-header">   <a id="login-link" href="logout_process.php" title="Logout">Logout</a>   <div id="login-panel">       </div><!-- /login-panel -->   </div><!-- /demoheader -->   <br class="clear" /><br /><br /><br />   <div id="content">       <h1 class="pagehead"></h1>               <ul id="menu">   <li><a href="home.php">Home</a></li>   <li><a href="#">Maintenance</a>   <ul>   <li><a href="theater.php">Theater</a></li>   <li><a href="director.php">Director</a></li>   <li><a href="actor.php">Lead Actor/Actress</a></li>   <li><a href="genre.php">Genre</a></li>   <li><a href="schedule.php">Time Scheduling</a></li>   <li><a href="price.php">Price</a></li>   <li><a href="movie.php">Movie</a></li>   <li><a href="viewer.php">Viewer</a></li>   <li><a href="slideshow.php">Slide Show</a></li>   </ul>   </li>   <li><a href="#">Transactions</a>   <ul>   <li><a href="reservation.php">Reservation</a></li>   <li><a href="billing.php">Billing</a></li>   <li><a href="waitlist.php">Wait list</a></li>   </ul>   </li>   <li><a href="#">Utility</a>   <ul>   <li><a href="user.php">User</a></li>   <li><a href="discount.php">Discount</a></li>   </ul>   </li>   <li><a href="#">Reports</a>   <ul>   <li><a href="sale.php">Sales</a></li>   </ul>   </li>   <li><a href="faq">Frequently Ask Questions</a></li>   <li><a href="about.php">About Us</a></li>           </ul>   </div><!-- /content -->   <!--</div>    </div>    -->       </body>   </html>       <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   <html xmlns="http://www.w3.org/1999/xhtml">   <head>   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   <title>Star Theater</title>   <link rel="shortcut icon" href="images/favicon.ico" />   <link rel="stylesheet" media="screen" href="css/demo.css" />   <link rel="stylesheet" type="text/css" href="css/table.css"/>   <script type="text/javascript" src="js/jquery.js"></script>   <script type="text/javascript">   <!--   function confirmation() {       var msg = "Are you sure you want to delete this lead actor/actress?";   var answer = confirm(msg);   if (answer){   alert('Record successfully deleted!')   document.frm.submit();   }   }       </script>   <style>   .highlighted { background:#090; }   </style>       </head>   <body>       <div id="content">           <div align="right"><a href="f.actor_add.php" > <img src="icons/ad.png" width="70px" height="70px" title="Add new actor" /></a>   </div>           <table class="filterable" id="bordered">   <thead>   <tr>           <th style="text-align:center">Lastname</th>   <th style="text-align:center">Firstname</th>   <th style="text-align:center">Date of birth</th>   <th style="text-align:center">Contact number</th>   <th style="text-align:center">Address</th>   <th style="text-align:center">VIEW</th>   <th style="text-align:center">EDIT</th>   <th style="text-align:center">DELETE</th>   </tr>   </thead>   <tbody>   <tr><td>adf</td><td>jake</td><td style="text-align:right">07/11/2013</td><td style="text-align:right">321</td><td>das</td><td style="text-align:center"><a href="view_actor.php?ID=4"><img height="40" width="40" src="icons/view.png"/></a>   </td> <td style="text-align:center"><a href="f.actor_edit.php?ID=4"><img height="40" width="40" src="icons/ed.png" /></a>   </td> <td style="text-align:center"><a href="delete_actor.php?ID=4" onclick="confirmation();return false"> <img height="40" width="40" src="icons/xx.png" /></a>   </td> </tr>   </tbody>   </table>   <script type="text/javascript" src="js/tablesearch.js"></script>   </div><!-- /content -->           <div id="footer">   <label>&copy; <a href="https://www.facebook.com/CodeWEBB.Design?fref=ts">CodeWEBB Design</a></label> |<a href="developers.php">&nbsp;Developers</a>       </div><!-- /footer -->       </body>   </html>
 

Edited by phpbigenner, 12 July 2013 - 09:21 AM.


#11 trq

trq

    Advanced Member

  • Administrators
  • 30,723 posts
  • LocationSydney, Australia.

Posted 12 July 2013 - 09:11 AM

Use [code][/code] tags when posting code.

http://thorpesystems.com | http://proemframework.org | http://github.com/trq

SmtpCatcher - A very simple mock sendmail useful for testing PHP mail scripts.
OPM - My Linux package manager.


#12 fastsol

fastsol

    Advanced Member

  • Members
  • PipPipPip
  • 235 posts
  • LocationMinnesota

Posted 12 July 2013 - 09:20 AM

the script didn't echoed.

Well there ya go, you need to figure out why it's not echoing the tag.  You have something wrong in your php logic.


You never know everything, I learn everday!

http://amecms.com

http://amewebdesigns.com


#13 phpbigenner

phpbigenner

    Member

  • Members
  • PipPip
  • 19 posts

Posted 12 July 2013 - 09:37 AM

okay. i'll try to figured it out.



#14 phpbigenner

phpbigenner

    Member

  • Members
  • PipPip
  • 19 posts

Posted 12 July 2013 - 11:01 AM

I got it men. thankyou. @ fastsol



#15 fastsol

fastsol

    Advanced Member

  • Members
  • PipPipPip
  • 235 posts
  • LocationMinnesota

Posted 12 July 2013 - 12:26 PM

Glad you got it working!  You just have to remember to start with the baiscs of diagnostics to figure out a problem.


You never know everything, I learn everday!

http://amecms.com

http://amewebdesigns.com





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com