简体   繁体   English

PHP href 不起作用

[英]PHP href doesn't work

I have a href in my php code to edit or remove photos from the site.我的 php 代码中有一个 href 来编辑或删除网站上的照片。

echo("<a href='photohandling.php?action=1&file=".$iPictureNumber."'><img height='35' src='./pictures/delete.png' border='0' ></a>");

But the code only works sometimes.但该代码仅有时有效。 The photohandling.php isn't fired up everytime. photohandling.php 不是每次都启动。 I put an echo inside the photohandling.php to see if the file is used.我在 photohandling.php 中放了一个 echo 来查看是否使用了该文件。 And most of the times it doesn't.大多数时候它没有。 Why?为什么? Is the code not solled or is this a problem of the browser?是代码没有卖掉还是浏览器的问题?

Anyone an idea?任何人的想法? Thanks in advance.提前致谢。

Edit: None of the solutions worked thus far.编辑:到目前为止,没有一个解决方案有效。 Thanks for thinking along.谢谢你的思考。 But let me further clearify the problem:但让我进一步澄清问题:

href='photohandling.php?action=1&file=2'> then the photohandling.php fires up href='photohandling.php?action=1&file=2'> 然后 photohandling.php 启动

href='photohandling.php?action=1&file=3'> then the photohandling.php doesn't work href='photohandling.php?action=1&file=3'> 然后 photohandling.php 不起作用

href='photohandling.php?action=1&file=4'> the photohandling.php fires up href='photohandling.php?action=1&file=4'> photohandling.php 启动

href='photohandling.php?action=1&file=5'> the photohandling.php fires up href='photohandling.php?action=1&file=5'> photohandling.php 启动

The next time only 2 and 5 works, then only the first, then none of them, etc下一次只有 2 和 5 工作,然后只有第一个,然后没有,等等

They are generated by an FOR loop.它们由 FOR 循环生成。 Thats whats so puzzling about it, its just a parameter.这就是它令人费解的地方,它只是一个参数。

And if anyone has an alternative solution to this, please youre welcome.如果有人对此有替代解决方案,请欢迎您。 This project has to be done in a couple of weeks.这个项目必须在几周内完成。

Try this:尝试这个:

echo "<a href='photohandling.php?action=1&file={$IPictureNumber}'><img height='35'src='./pictures/delete.png' border='0' ></a>";

The single quotes mean $IPictureNumber isn't being treated as a variable, so t needs to be enclosed in curly brackets.单引号意味着 $IPictureNumber 不被视为变量,因此需要将 t 括在大括号中。 Also make sure you are poitning the photohandling.php in the right location.还要确保您将 photohandling.php 指向正确的位置。 If it's in a higher level use "../photohandling.php" etc如果它在更高级别使用“../photohandling.php”等

You need to provide the absolute URL to the file.您需要提供文件的绝对 URL。 If it's in your root, try this:如果它在您的根目录中,请尝试以下操作:

echo("<a href='/photohandling.php?action=1&file=".$iPictureNumber."'><img height='35' src='./pictures/delete.png' border='0' ></a>");

Otherwise it will append the file to the current URL, so if you're on http://example.com/test , it will try to reach http://example.com/test/photohandling.php .否则,它会将文件附加到当前 URL,因此如果您在http://example.com/test 上,它将尝试访问http://example.com/test/photohandling.php

echo '<a href="../photohandling.php?action=1&file='.$iPictureNumber.'"><img height="35" src="./pictures/delete.png" border="0" >Link Name</a>';  

尝试使用../ ( dot-dot-slash ) 进入父文件夹,然后包含文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM