找到你要的答案

Q:How to Query Cookie Variables

Q:如何查询cookie变量

I'm trying to create a mysql/php chat (private message) for my site using the "WHERE" clause in PHP.

SELECT * FROM (tablename) WHERE (columnname) = $_SESSION('MM_USERNAME')

However, I seem to only be able to search for plain text or my table "users.username" which brings up all results in table (not what I want). Is it possible to search from the username cookie variable?

我想创建一个MySQL和PHP聊天(私人信息)我的网站使用的“哪里”条款在PHP。

SELECT * FROM (tablename) WHERE (columnname) = $_SESSION('MM_USERNAME')

然而,我似乎只能搜索纯文本或我的表“用户名”,它在表中显示所有结果(不是我想要的)。是否可以从用户名cookie变量中搜索?

answer1: 回答1:

Since $_SESSION('MM_USERNAME') is a string it needs to be in quotes.

$query_chat = "SELECT * FROM (tablename) WHERE (columnname) = '" . $_SESSION['MM_USERNAME'] . "'";

Using the error reporting of which ever driver you are using should return this to you. You also should be sure you sanatize that value or use a prepared statement.

由于_session美元('mm_username”)是一个字符串,它需要在报价。

$query_chat = "SELECT * FROM (tablename) WHERE (columnname) = '" . $_SESSION['MM_USERNAME'] . "'";

使用您所使用的驱动程序的错误报告,应将此返回给您。你也应该相信你sanatize价值或使用事先准备好的声明。

php  mysql  phpmyadmin  dreamweaver