まず最初に、呼出されるdb.phpの一部
<?
class DBConn {
var $dbhost="でーたべーすのURL";
var $dbuser,$dbpasswd,$db,$connect;
function DBConn($db="データベース名",$dbuser="ユーザー名",$dbpasswd="パスワード"){
$this->dbuser=$dbuser;
$this->dbpasswd=$dbpasswd;
$this->db=$db;
$this->connect=mysql_connect($this->dbhost,$this->dbuser,$this->dbpasswd);
mysql_select_db($this->db,$this->connect);
}
function getResult($query){
$result[result]=mysql_query($query,$this->connect) or die(mysql_error());
$result[count]=@mysql_num_rows($result[result]);
return $result;
}
function getSelect($field,$table,$where){
$query="select $field from $table $where;";
$result=$this->getResult($query);
return $result;
}
ここからメインのPHP
<?php
$in = "";
if($_SERVER['REQUEST_METHOD'] == "POST") {
$in = $_POST;
}else{
$in = $_GET;
}
include "../base/db.php";
$db=new DBConn();
$temp_result=$db->getSelect("*","main","where username=$in[username]");
書き出しでこのようにしているのですが、
これを呼出す前ページで<input type="text" name="username">としてPOSTしてやると
Unknown column 'abcd' in 'where clause'
というエラーが出ます。(abcdは前ページで適当に入力した文字)
$temp_result=$db->getSelect("*","main","");
このように抽出条件無しの場合、問題なくデータは全て取得でき、
$temp_result=$db->getSelect("*","main","where username=$in[test]");
とか
$temp_result=$db->getSelect("*","main","where test=$in[test]");
のように、抽出条件部分を実際にフィールド名として存在する別の名前を入れると
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
このようなエラー表示になります
ネットで調べていたら、usernameが予約語だと書いてあるページがあったので`で括ってやったりもしましたが結果は同じです
データベースの呼出はできてますし、抽出条件がなければデータが取得できることも確認しています。
データベースの指定テーブル内に抽出条件となるフィールドがあることも間違いありません。
どこが悪くてこのようなエラーになっているのでしょうか?
基本的な形式そのものは過去に作った物をコピペしてからはじめているので、余計にエラーの理由が分かりません。
あれこれと何時間も試しましたがどうにも解決できません。
どなたかお助けください。
まず最初に、呼出されるdb.phpの一部
<?
class DBConn {
var $dbhost="でーたべーすのURL";
var $dbuser,$dbpasswd,$db,$connect;
function DBConn($db="データベース名",$dbuser="ユーザー名",$dbpasswd="パスワード"){
$this->dbuser=$dbuser;
$this->dbpasswd=$dbpasswd;
$this->db=$db;
$this->connect=mysql_connect($this->dbhost,$this->dbuser,$this->dbpasswd);
mysql_select_db($this->db,$this->connect);
}
function getResult($query){
$result[result]=mysql_query($query,$this->connect) or die(mysql_error());
$result[count]=@mysql_num_rows($result[result]);
return $result;
}
function getSelect($field,$table,$where){
$query="select $field from $table $where;";
$result=$this->getResult($query);
return $result;
}
ここからメインのPHP
<?php
$in = "";
if($_SERVER['REQUEST_METHOD'] == "POST") {
$in = $_POST;
}else{
$in = $_GET;
}
include "../base/db.php";
$db=new DBConn();
$temp_result=$db->getSelect("*","main","where username=$in[username]");
書き出しでこのようにしているのですが、
これを呼出す前ページで<input type="text" name="username">としてPOSTしてやると
Unknown column 'abcd' in 'where clause'
というエラーが出ます。(abcdは前ページで適当に入力した文字)
$temp_result=$db->getSelect("*","main","");
このように抽出条件無しの場合、問題なくデータは全て取得でき、
$temp_result=$db->getSelect("*","main","where username=$in[test]");
とか
$temp_result=$db->getSelect("*","main","where test=$in[test]");
のように、抽出条件部分を実際にフィールド名として存在する別の名前を入れると
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
このようなエラー表示になります
ネットで調べていたら、usernameが予約語だと書いてあるページがあったので`で括ってやったりもしましたが結果は同じです
データベースの呼出はできてますし、抽出条件がなければデータが取得できることも確認しています。
データベースの指定テーブル内に抽出条件となるフィールドがあることも間違いありません。
どこが悪くてこのようなエラーになっているのでしょうか?
基本的な形式そのものは過去に作った物をコピペしてからはじめているので、余計にエラーの理由が分かりません。
あれこれと何時間も試しましたがどうにも解決できません。
どなたかお助けください。
PHPのIDEにPleiadesを使用しようと思い、ダウンロードしました。XAMPP Control Panelでapacheを起動すると、今まで使用していたProgram Files配下のapacheが起動してしまいます。xampp配下のapacheを起動するにはどうすればいいのでしょうか?どこかに起動する設定ファイルがあるのでしょうか?