(转载)
调用mysql_query( ),当查询操作是update、insert、delete时,返回的是true或者false,而操作执行的结果可能有三种:查询的字符串有错误;执行成功;执行不成功。执行select成功时,无论查询结果是否为空时,返回值都是对象
查询字符串中有错误,或者不成功都返回false
错误在mysql_error()中成功返回truemysql_query($sql) or die("error:".mysql_error())
error的列表,或者是errno的对照表
ER_HASHCHK 1000ER_NISAMCHK 1001ER_NO 1002ER_YES 1003ER_CANT_CREATE_FILE 1004ER_CANT_CREATE_TABLE 1005ER_CANT_CREATE_DB 1006ER_DB_CREATE_EXISTS 1007ER_DB_DROP_EXISTS 1008ER_DB_DROP_DELETE 1009ER_DB_DROP_RMDIR 1010ER_CANT_DELETE_FILE 1011ER_CANT_FIND_SYSTEM_REC 1012ER_CANT_GET_STAT 1013ER_CANT_GET_WD 1014ER_CANT_LOCK 1015ER_CANT_OPEN_FILE 1016ER_FILE_NOT_FOUND 1017ER_CANT_READ_DIR 1018ER_CANT_SET_WD 1019ER_CHECKREAD 1020ER_DISK_FULL 1021ER_DUP_KEY 1022ER_ERROR_ON_CLOSE 1023ER_ERROR_ON_READ 1024ER_ERROR_ON_RENAME 1025ER_ERROR_ON_WRITE 1026ER_FILE_USED 1027ER_FILSORT_ABORT 1028ER_FORM_NOT_FOUND 1029ER_GET_ERRNO 1030ER_ILLEGAL_HA 1031ER_KEY_NOT_FOUND 1032ER_NOT_FORM_FILE 1033ER_NOT_KEYFILE 1034ER_OLD_KEYFILE 1035ER_OPEN_AS_READONLY 1036ER_OUTOFMEMORY 1037ER_OUT_OF_SORTMEMORY 1038ER_UNEXPECTED_EOF 1039ER_CON_COUNT_ERROR 1040ER_OUT_OF_RESOURCES 1041ER_BAD_HOST_ERROR 1042ER_HANDSHAKE_ERROR 1043ER_DBACCESS_DENIED_ERROR 1044ER_ACCESS_DENIED_ERROR 1045ER_NO_DB_ERROR 1046ER_UNKNOWN_COM_ERROR 1047ER_BAD_NULL_ERROR 1048ER_BAD_DB_ERROR 1049ER_TABLE_EXISTS_ERROR 1050ER_BAD_TABLE_ERROR 1051ER_NON_UNIQ_ERROR 1052ER_SERVER_SHUTDOWN 1053ER_BAD_FIELD_ERROR 1054ER_WRONG_FIELD_WITH_GROUP 1055ER_WRONG_GROUP_FIELD 1056ER_WRONG_SUM_SELECT 1057ER_WRONG_VALUE_COUNT 1058ER_TOO_LONG_IDENT 1059ER_DUP_FIELDNAME 1060ER_DUP_KEYNAME 1061ER_DUP_ENTRY 1062ER_WRONG_FIELD_SPEC 1063ER_PARSE_ERROR 1064ER_EMPTY_QUERY 1065ER_NONUNIQ_TABLE 1066ER_INVALID_DEFAULT 1067ER_MULTIPLE_PRI_KEY 1068ER_TOO_MANY_KEYS 1069ER_TOO_MANY_KEY_PARTS 1070ER_TOO_LONG_KEY 1071ER_KEY_COLUMN_DOES_NOT_EXITS 1072ER_BLOB_USED_AS_KEY 1073ER_TOO_BIG_FIELDLENGTH 1074ER_WRONG_AUTO_KEY 1075ER_READY 1076ER_NORMAL_SHUTDOWN 1077ER_GOT_SIGNAL 1078ER_SHUTDOWN_COMPLETE 1079ER_FORCING_CLOSE 1080ER_IPSOCK_ERROR 1081ER_NO_SUCH_INDEX 1082ER_WRONG_FIELD_TERMINATORS 1083ER_BLOBS_AND_NO_TERMINATED 1084ER_TEXTFILE_NOT_READABLE 1085ER_FILE_EXISTS_ERROR 1086ER_LOAD_INFO 1087ER_ALTER_INFO 1088ER_WRONG_SUB_KEY 1089ER_CANT_REMOVE_ALL_FIELDS 1090ER_CANT_DROP_FIELD_OR_KEY 1091ER_INSERT_INFO 1092ER_INSERT_TABLE_USED 1093ER_NO_SUCH_THREAD 1094ER_KILL_DENIED_ERROR 1095ER_NO_TABLES_USED 1096ER_TOO_BIG_SET 1097ER_NO_UNIQUE_LOGFILE 1098ER_TABLE_NOT_LOCKED_FOR_WRITE 1099ER_TABLE_NOT_LOCKED 1100ER_BLOB_CANT_HAVE_DEFAULT 1101ER_WRONG_DB_NAME 1102ER_WRONG_TABLE_NAME 1103ER_TOO_BIG_SELECT 1104ER_UNKNOWN_ERROR 1105ER_UNKNOWN_PROCEDURE 1106ER_WRONG_PARAMCOUNT_TO_PROCEDURE 1107ER_WRONG_PARAMETERS_TO_PROCEDURE 1108ER_UNKNOWN_TABLE 1109ER_FIELD_SPECIFIED_TWICE 1110ER_INVALID_GROUP_FUNC_USE 1111ER_UNSUPPORTED_EXTENSION 1112ER_TABLE_MUST_HAVE_COLUMNS 1113ER_RECORD_FILE_FULL 1114ER_UNKNOWN_CHARACTER_SET 1115ER_TOO_MANY_TABLES 1116ER_TOO_MANY_FIELDS 1117ER_TOO_BIG_ROWSIZE 1118ER_STACK_OVERRUN 1119ER_WRONG_OUTER_JOIN 1120ER_NULL_COLUMN_IN_INDEX 1121ER_CANT_FIND_UDF 1122ER_CANT_INITIALIZE_UDF 1123ER_UDF_NO_PATHS 1124ER_UDF_EXISTS 1125ER_CANT_OPEN_LIBRARY 1126ER_CANT_FIND_DL_ENTRY 1127ER_FUNCTION_NOT_DEFINED 1128ER_HOST_IS_BLOCKED 1129ER_HOST_NOT_PRIVILEGED 1130ER_PASSWORD_ANONYMOUS_USER 1131ER_PASSWORD_NOT_ALLOWED 1132ER_PASSWORD_NO_MATCH 1133ER_UPDATE_INFO 1134ER_CANT_CREATE_THREAD 1135ER_WRONG_VALUE_COUNT_ON_ROW 1136ER_CANT_REOPEN_TABLE 1137ER_INVALID_USE_OF_NULL 1138ER_REGEXP_ERROR 1139ER_MIX_OF_GROUP_FUNC_AND_FIELDS 1140ER_NONEXISTING_GRANT 1141ER_TABLEACCESS_DENIED_ERROR 1142ER_COLUMNACCESS_DENIED_ERROR 1143ER_ILLEGAL_GRANT_FOR_TABLE 1144ER_GRANT_WRONG_HOST_OR_USER 1145ER_NO_SUCH_TABLE 1146ER_NONEXISTING_TABLE_GRANT 1147ER_NOT_ALLOWED_COMMAND 1148ER_SYNTAX_ERROR 1149ER_DELAYED_CANT_CHANGE_LOCK 1150ER_TOO_MANY_DELAYED_THREADS 1151ER_ABORTING_CONNECTION 1152ER_NET_PACKET_TOO_LARGE 1153ER_NET_READ_ERROR_FROM_PIPE 1154ER_NET_FCNTL_ERROR 1155ER_NET_PACKETS_OUT_OF_ORDER 1156ER_NET_UNCOMPRESS_ERROR 1157ER_NET_READ_ERROR 1158ER_NET_READ_INTERRUPTED 1159ER_NET_ERROR_ON_WRITE 1160ER_NET_WRITE_INTERRUPTED 1161ER_TOO_LONG_STRING 1162ER_TABLE_CANT_HANDLE_BLOB 1163ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164ER_DELAYED_INSERT_TABLE_LOCKED 1165ER_WRONG_COLUMN_NAME 1166ER_WRONG_KEY_COLUMN 1167ER_WRONG_MRG_TABLE 1168ER_DUP_UNIQUE 1169ER_BLOB_KEY_WITHOUT_LENGTH 1170ER_PRIMARY_CANT_HAVE_NULL 1171ER_TOO_MANY_ROWS 1172ER_REQUIRES_PRIMARY_KEY 1173ER_NO_RAID_COMPILED 1174ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175ER_KEY_DOES_NOT_EXITS 1176ER_CHECK_NO_SUCH_TABLE 1177ER_CHECK_NOT_IMPLEMENTED 1178ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179ER_ERROR_DURING_COMMIT 1180ER_ERROR_DURING_ROLLBACK 1181ER_ERROR_DURING_FLUSH_LOGS 1182ER_ERROR_DURING_CHECKPOINT 1183ER_NEW_ABORTING_CONNECTION 1184ER_DUMP_NOT_IMPLEMENTED 1185ER_FLUSH_MASTER_BINLOG_CLOSED 1186ER_INDEX_REBUILD 1187ER_MASTER 1188ER_MASTER_NET_READ 1189ER_MASTER_NET_WRITE 1190ER_FT_MATCHING_KEY_NOT_FOUND 1191ER_LOCK_OR_ACTIVE_TRANSACTION 1192ER_UNKNOWN_SYSTEM_VARIABLE 1193ER_CRASHED_ON_USAGE 1194ER_CRASHED_ON_REPAIR 1195ER_WARNING_NOT_COMPLETE_ROLLBACK 1196ER_TRANS_CACHE_FULL 1197ER_SLAVE_MUST_STOP 1198ER_SLAVE_NOT_RUNNING 1199ER_BAD_SLAVE 1200ER_MASTER_INFO 1201ER_SLAVE_THREAD 1202ER_TOO_MANY_USER_CONNECTIONS 1203ER_SET_CONSTANTS_ONLY 1204ER_LOCK_WAIT_TIMEOUT 1205ER_LOCK_TABLE_FULL 1206ER_READ_ONLY_TRANSACTION 1207ER_DROP_DB_WITH_READ_LOCK 1208ER_CREATE_DB_WITH_READ_LOCK 1209ER_WRONG_ARGUMENTS 1210ER_NO_PERMISSION_TO_CREATE_USER 1211ER_UNION_TABLES_IN_DIFFERENT_DIR 1212ER_LOCK_DEADLOCK 1213ER_TABLE_CANT_HANDLE_FULLTEXT 1214ER_CANNOT_ADD_FOREIGN 1215ER_NO_REFERENCED_ROW 1216ER_ROW_IS_REFERENCED 1217ER_ERROR_MESSAGES 218