Jump to content

supplied argument is not vallid???


plodos

Recommended Posts

codes...


$total_id = mysql_query("SELECT * FROM 'PERSON'");
$num_rows = mysql_num_rows($total_id);
$num_rows++;

$sql = "select 'committee_id' from 'committee' where 'name'='$committee'";
$id = mysql_query($sql);
$result = mysql_fetch_assoc($id);
foreach ($result as $v) 
{
   $k=$v;
}
$count_commit = $k;  

errors

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/public_html/committees/add.php on line 19

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/public_html/committees/add.php on line 24

Warning: Invalid argument supplied for foreach() in /home/public_html/committees/add.php on line 25

How can I solve these errors?

Link to comment
Share on other sites

error is

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 ''PERSON'' at line 1

sql codes



CREATE TABLE `person` (
`person_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`title` VARCHAR(20) NOT NULL,
`fname` VARCHAR( 40 ) NOT NULL ,
`lname` VARCHAR( 40 ) NOT NULL ,
`email` VARCHAR( 128 ) NOT NULL ,
`country` VARCHAR( 128 ) NOT NULL ,
`university` TEXT NOT NULL,
`university_dept` TEXT NOT NULL,
`phone` VARCHAR(40) NOT NULL,
`fax` VARCHAR(40) NOT NULL,
`research_field` TEXT NOT NULL,
`address` TEXT NOT NULL,
`date` DATETIME
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE TABLE `committee` (
`committee_id` SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` TEXT NOT NULL
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE TABLE `join_person_committee` (
`person_id` INT NOT NULL ,
`committee_id` SMALLINT NOT NULL ,
PRIMARY KEY ( `person_id` , `committee_id` )
) ENGINE = MYISAM ;

 

What is wrong...?

Link to comment
Share on other sites

Just remove the quotes.  Don't use backticks, because not all SQL servers support them so if you had to switch...you'd be stuck.  Just remove the ' '.

 

How sure of that are you? I'm pretty sure that those specify literals in sql and are a safe measure and good practice...

Link to comment
Share on other sites

Just remove the quotes.  Don't use backticks, because not all SQL servers support them so if you had to switch...you'd be stuck.  Just remove the ' '.

 

and what if you have a column with the same name as a function?

 

You rename the column.

Link to comment
Share on other sites

Just remove the quotes.  Don't use backticks, because not all SQL servers support them so if you had to switch...you'd be stuck.  Just remove the ' '.

 

How sure of that are you? I'm pretty sure that those specify literals in sql and are a safe measure and good practice...

 

It's a MySQL only thing.  PostgreSQL throws some along the lines of:

ERROR:  operator does not exist: ` character
HINT:  No operator matches the given name and argument type(s). You may need to add explicit type casts.

 

>_>

Link to comment
Share on other sites

sql

CREATE TABLE `person` (
`person_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`title` VARCHAR(20) NOT NULL,
`fname` VARCHAR( 40 ) NOT NULL ,
`lname` VARCHAR( 40 ) NOT NULL ,
`email` VARCHAR( 128 ) NOT NULL ,
`country` VARCHAR( 128 ) NOT NULL ,
`university` TEXT NOT NULL,
`university_dept` TEXT NOT NULL,
`phone` VARCHAR(40) NOT NULL,
`fax` VARCHAR(40) NOT NULL,
`research_field` TEXT NOT NULL,
`address` TEXT NOT NULL,
`date` DATETIME
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE TABLE `committee` (
`committee_id` SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` TEXT NOT NULL
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE TABLE `join_person_committee` (
`person_id` INT NOT NULL ,
`committee_id` SMALLINT NOT NULL ,
PRIMARY KEY ( `person_id` , `committee_id` )
) ENGINE = MYISAM ;

insert into committee values('10','Electrical');
insert into committee values('9','Industrial');
insert into committee values('8','Engineering');
insert into committee values('7','Processing');
insert into committee values('6','Mathematics');
insert into committee values('5','Biological');
insert into committee values('4','Computer');
insert into committee values('3','Computational');
insert into committee values('2','Sciences');
insert into committee values('1','Technology');

query

SELECT committee_id
FROM committee
WHERE name = `Electrical`
LIMIT 0 , 30

MySQL 
#1054 - Unknown column 'Electrical' in 'where clause' 

 

query has a problem? dou you know why?

Link to comment
Share on other sites

sql

CREATE TABLE `person` (
`person_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`title` VARCHAR(20) NOT NULL,
`fname` VARCHAR( 40 ) NOT NULL ,
`lname` VARCHAR( 40 ) NOT NULL ,
`email` VARCHAR( 128 ) NOT NULL ,
`country` VARCHAR( 128 ) NOT NULL ,
`university` TEXT NOT NULL,
`university_dept` TEXT NOT NULL,
`phone` VARCHAR(40) NOT NULL,
`fax` VARCHAR(40) NOT NULL,
`research_field` TEXT NOT NULL,
`address` TEXT NOT NULL,
`date` DATETIME
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE TABLE `committee` (
`committee_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` TEXT NOT NULL
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE TABLE `join_person_committee` (
`person_id` INT NOT NULL ,
`committee_id` SMALLINT NOT NULL ,
PRIMARY KEY ( `person_id` , `committee_id` )
) ENGINE = MYISAM ;

insert into committee values(`10`,`Electrical`);
insert into committee values(`9`,`Industrial`);
insert into committee values(`8`,`Engineering`);
insert into committee values(`7`,`Processing`);
insert into committee values(`6`,`Mathematics`);
insert into committee values(`5`,`Biological`);
insert into committee values(`4`,`Computer`);
insert into committee values(`3`,`Computational`);
insert into committee values(`2`,`Sciences`);
insert into committee values(`1`,`Technology`);

error

SQL :

INSERT INTO committee
VALUES (
`10` , `Electrical`
);

MySQL :
#1054 - Unknown column '10' in 'field list' 

I changed all of them " ' " ,

 

still there is a problem?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.