wamp服务器没有在javascript语句中运行PHP代码

时间:2013-06-30 14:36:38

标签: php javascript wamp wampserver

javascript代码中的php回来了,因为php statememnt而不是$ _GET值是否需要更改配置中的某些内容?这适用于大学apache服务器,但似乎在这种情况下,PHP和JavaScript正在其他页面上正常工作。删除工作正常。

<SCRIPT LANGUAGE="JavaScript">
  setTimeout(function(){
  alert("<?echo $_GET['deletename']?> Deleted, you will now return to the Artist Search...")
    window.location = "http://www.aaaaa.tk/CI/index.php/about?deletedartist=<?echo $_GET['deletename']?>";
  }, 100);

 </script>
 <link rel="stylesheet" type="text/css" href="main.css">
 </head>
 <?php

 $artistid = $_GET['deleteid'];

$username="X";
$password="X";
$database="X";
mysql_connect(localhost,$username,$password) or die("Could not connect : " . mysql_error()); 
@mysql_select_db($database) or die( "Unable to select database");
/* Performing SQL query */ 
$query = "DELETE FROM fbartist WHERE id =$artistid"; 
$query2 = "ALTER TABLE fbartist AUTO_INCREMENT=1;"; 
$result = mysql_query($query) or die("Delete Query failed :".$query."" . mysql_error()); 
$result2 = mysql_query($query2) or die("Auto Increment Query failed : " . mysql_error()); 

mysql_close(); 
?>

感谢您给予的任何帮助。

1 个答案:

答案 0 :(得分:2)

尝试

alert("<?php echo ....

检查php.ini short_open_tag = on,查看here