我在我的php脚本中找不到这个错误

编程入门 行业动态 更新时间:2024-10-14 00:26:11
本文介绍了我在我的php脚本中找不到这个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想用PHP编写一个脚本,使用该页面的当前URL,在数据库中搜索(phpMyAdmin和WAMP),并使用该URL打印该行的ID。我已经写了这个,并且就连接的角度而言,每个线程都起作用,与mysql的连接也可以正常工作,问题从这一行开始:

I want to write a script in PHP that takes the current URL of the page, searches it in the database (phpMyAdmin with WAMP) and prints the ID of the row with that URL. I have written this, and to the point of the connection, everythwing works, the connection with mysql also works fine, the problem starts on this line:

$query = "SELECT id FROM search WHERE link = '". $curPageURL . "'";

任何人都可以告诉我:我做错了什么?这是整个脚本:

Can anyone please tell me: what Am I doing wrong? this is the whole script:

<!DOCTYPE html> <html> <body> <?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } echo curPageURL(); //connection $con= mysql_connect("localhost","root","") or die ("Could not connect"); mysql_select_db("search") or die ("Could not select db"); echo "connection succesful"; $query = "SELECT id FROM search WHERE link = '". $curPageURL . "'"; while($row = mysql_fetch_array($query)) { echo $row; } ?> </body> </html>

推荐答案

您可能想尝试这样的事情。 p>

You might want to try something like this.

$query = "SELECT id FROM search WHERE link = '". curPageURL() . "'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo $row['id']; }

更多推荐

我在我的php脚本中找不到这个错误

本文发布于:2023-11-24 12:37:48,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:我在   脚本   中找   错误   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!