rain13 Posted October 5, 2011 Share Posted October 5, 2011 I can't come up with any possible problems/solutions.mysql_connect returns me resource which means that server, username, and password are correct. for some reason mysql_select_db() returns me false. I checked that database name is right. I can see base with that name when I connect with phpmyadmin. $connection = mysql_connect($DatabaseServer, $DatabaseUser, $DatabasePassword); $sel = mysql_select_db($DatabaseName,$connection) dbg($connection,$DatabaseName,$sel); output of dbg function call: DEBUG: RESOURCE => "Resource id #5"DEBUG: STR => "g"DEBUG: BOOL => "false" If anyone hav ideas about what might cause mysql_select_db failure, let me know. Link to comment Share on other sites More sharing options...
Ingolme Posted October 5, 2011 Share Posted October 5, 2011 Maybe mysql_error() might show something. I'm not sure if it only works for queries. Link to comment Share on other sites More sharing options...
rain13 Posted October 5, 2011 Author Share Posted October 5, 2011 it doesn't show anything. Maybe there's problem in my table creation? for($i = 0;$i < count($keys);$i++) {$ThisTable = "";eval('$ThisTable = '.$DBTables[$keys[$i]].';');$TmpKeys = array_keys($ThisTable);$TableName = $ThisTable[this];$TableColumns = TableListColumns($TableName);if($TableColumns == -1) { $RET_DATA .= "Creating table: <b>".$TableName."</b> "; $Query = 'CREATE TABLE '.$TableName."(\n"; for($n = 1;$n < count($TmpKeys) -1 ;$n++) { // 0th is this $Query .= $ThisTable[$TmpKeys[$n]]["Name"] ." ". $ThisTable[$TmpKeys[$n]]["Properties"].",\n"; } $Query .= $ThisTable[$TmpKeys[$n]]["Name"] ." ". $ThisTable[$TmpKeys[$n]]["Properties"]."\n"; $Query .= ");"; $result = @mysql_query($Query);}} or maybe in table? <?php//TABLESdefine("this","this");//general$General[this] = "general";$General["UserID"]["Name"] = "UserID";$General["views"]["Name"] = "Views";$General["lastupdate"]["Name"] = "LastUpdate";$General["comments"]["Name"]= "comments";$General["AllowBBCode"]["Name"]= "AllowBBCode";$General["AllowSmiles"]["Name"]= "AllowSmiles";$General["SignatureMaxLen"]["Name"]= "SignatureMaxLen";$General["lastcomment"]["Name"] = "LastComment";$General["DefaultGroup"]["Name"] = "DefaultGroup";$General["DefaultGroupList"]["Name"] = "DefaultGroupList";$General["TimeFormat"]["Name"] = "TimeFormat";$General["DefaultStyle"]["Name"] = "DefaultStyle";$General["SiteName"]["Name"] = "SiteName";$General["SiteDescription"]["Name"] = "SiteDescription";$General["SiteMOD"]["Name"] = "SiteMOD"; $General["UserID"]["Properties"] = "int(11)";$General["views"]["Properties"] = "int(11)";$General["lastupdate"]["Properties"] = "int(11)";$General["comments"]["Properties"]= "int(11)";$General["AllowBBCode"]["Properties"]= "int(1)";$General["AllowSmiles"]["Properties"]= "int(1)";$General["SignatureMaxLen"]["Properties"]= "int(11)";$General["lastcomment"]["Properties"] = "varchar(512)";$General["DefaultGroup"]["Properties"] = "int(11)";$General["DefaultGroupList"]["Properties"] = "int(11)";$General["TimeFormat"]["Properties"] = "varchar(60)";$General["DefaultStyle"]["Properties"] = "varchar(60)";$General["SiteName"]["Properties"] = "varchar(200)";$General["SiteDescription"]["Properties"] = "varchar(512)";$General["SiteMOD"]["Properties"] = "varchar(1024)"; //Images$Images[this] = "Images";$Images["ID"]["Name"] = "ID";$Images["FileName"]["Name"] = "FileName";$Images["Title"]["Name"] = "Title";$Images["Hits"]["Name"] = "Hits";$Images["RatingSum"]["Name"] = "RatingSum";$Images["RatingCount"]["Name"] = "RatingCount";$Images["Year"]["Name"] = "Year";$Images["Month"]["Name"] = "Month";$Images["MonthDay"]["Name"] = "MonthDay";$Images["MetaKeyWords"]["Name"] = "MetaKeyWords";$Images["MetaDescription"]["Name"] = "MetaDescription";$Images["MetaTitle"]["Name"] = "MetaTitle";$Images["Description"]["Name"] = "Description";$Images["TopicID"]["Name"] = "TopicID";$Images["DownloadCount"]["Name"] = "DownloadCount";$Images["AltText"]["Name"] = "AltText";$Images["Raters"]["Name"] = "Raters"; $Images["ID"]["Properties"] = "int(11) primary key AUTO_INCREMENT";$Images["FileName"]["Properties"] = "varchar(260)";$Images["Title"]["Properties"] = "varchar(512)";$Images["Hits"]["Properties"] = "int(11)";$Images["RatingSum"]["Properties"] = "int(11)";$Images["RatingCount"]["Properties"] = "int(11)";$Images["Year"]["Properties"] = "int(11)";$Images["Month"]["Properties"] = "int(11)";$Images["MonthDay"]["Properties"] = "int(11)";$Images["MetaKeyWords"]["Properties"] = "varchar(1024)";$Images["MetaDescription"]["Properties"] = "varchar(1024)";$Images["MetaTitle"]["Properties"] = "varchar(1024)";$Images["Description"]["Properties"] = "varchar(1024)";$Images["TopicID"]["Properties"] = "INT(10)";$Images["DownloadCount"]["Properties"] = "int(11)";$Images["AltText"]["Properties"] = "int(11)";$Images["Raters"]["Properties"] = "longtext"; //Ratings$Ratings[this] = "Ratings";$Ratings["IP"]["Name"] = "IP";$Ratings["ImageID"]["Name"] = "ImageID";$Ratings["Stamp"]["Name"] = "Stamp";$Ratings["Rating"]["Name"] = "Rating";$Ratings["UserID"]["Name"] = "UserID"; $Ratings["IP"]["Properties"] = "varchar(30)";$Ratings["ImageID"]["Properties"] = "int(11)";$Ratings["Stamp"]["Properties"] = "int(11)";$Ratings["Rating"]["Properties"] = "int(11)";$Ratings["UserID"]["Properties"] = "int(11)"; //Users$Users[this] = "Users";$Users["UserID"]["Name"] = "UserID";$Users["UserName"]["Name"] = "UserName";$Users["UserPassword"]["Name"] = "UserPassword";$Users["UserEmail"]["Name"] = "UserEmail";$Users["UserMSN"]["Name"] = "UserMSN";$Users["UserAvatar"]["Name"] = "UserAvatar";$Users["UserJoinDate"]["Name"] = "UserJoinDate";$Users["UserPostCount"]["Name"] = "UserPostCount";$Users["UserGroup"]["Name"] = "UserGroup";$Users["UserDefaultGroup"]["Name"] = "UserDefaultGroup";$Users["UserShowMSN"]["Name"] = "UserShowMSN";$Users["UserShowMail"]["Name"] = "UserShowMail";$Users["UserWarn"]["Name"] = "UserWarn";$Users["UserFounder"]["Name"] = "UserFounder";$Users["UserRank"]["Name"] = "UserRank";$Users["UserIsBanned"]["Name"] = "UserIsBanned";$Users["UserBanExpire"]["Name"] = "UserBanExpire";$Users["UserBanReason"]["Name"] = "UserBanReason";$Users["UserSignature"]["Name"] = "UserSignature"; $Users["UserID"]["Properties"] = "INT(11) primary key AUTO_INCREMENT";$Users["UserName"]["Properties"] = "VARCHAR(255)";$Users["UserPassword"]["Properties"] = "VARCHAR(255)";$Users["UserEmail"]["Properties"] = "VARCHAR(255)";$Users["UserMSN"]["Properties"] = "VARCHAR(255)";$Users["UserAvatar"]["Properties"] = "VARCHAR(255)";$Users["UserJoinDate"]["Properties"] = "INT(11)";$Users["UserPostCount"]["Properties"] = "int(11)";$Users["UserGroup"]["Properties"] = "int(11)";$Users["UserDefaultGroup"]["Properties"] = "int(11)";$Users["UserShowMSN"]["Properties"] = "INT(1)";$Users["UserShowMail"]["Properties"] = "INT(1)";$Users["UserWarn"]["Properties"] = "int(1)";$Users["UserFounder"]["Properties"] = "int(1)";$Users["UserRank"]["Properties"] = "VARCHAR(255)";$Users["UserIsBanned"]["Properties"] = "longtext";$Users["UserBanExpire"]["Properties"] = "int(10)";$Users["UserBanReason"]["Properties"] = "VARCHAR(255)";$Users["UserSignature"]["Properties"] = "VARCHAR(255)"; //Groups$GROUPS[this] = "Groups";$GROUPS["ID"]["Name"] = "ID";$GROUPS["Permissions"]["Name"] = "Permissions";$GROUPS["Color"]["Name"] = "Color";$GROUPS["Rank"]["Name"] = "Rank";$GROUPS["Name"]["Name"] = "Name"; $GROUPS["ID"]["Properties"] = "int(16)";$GROUPS["Permissions"]["Properties"] = "int(16)";$GROUPS["Color"]["Properties"] = "varchar(20)";$GROUPS["Rank"]["Properties"] = "varchar(260)";$GROUPS["Name"]["Properties"] = "varchar(260)"; //TOPICS$TOPIC[this] = "Topic";$TOPIC["TopicID"]["Name"] = "TopicID";$TOPIC["ForumID"]["Name"] = "ForumID";$TOPIC["Time"]["Name"] = "Time";$TOPIC["Poster"]["Name"] = "Poster";$TOPIC["Views"]["Name"] = "Views";$TOPIC["Replies"]["Name"] = "Replies";$TOPIC["Type"]["Name"] = "Type";$TOPIC["Title"]["Name"] = "Title";$TOPIC["LastPostTime"]["Name"] = "LastPostTime";$TOPIC["LastPostID"]["Name"] = "LastPostID";$TOPIC["FirstPostID"]["Name"] = "FirstPostID"; $TOPIC["TopicID"]["Properties"] = "INT(11) primary key AUTO_INCREMENT";$TOPIC["ForumID"]["Properties"] = "INT(11)";$TOPIC["Time"]["Properties"] = "INT(11)";$TOPIC["Poster"]["Properties"] = "INT(11)";$TOPIC["Views"]["Properties"] = "INT(11)";$TOPIC["Replies"]["Properties"] = "INT(11)";$TOPIC["Type"]["Properties"] = "INT(2)";$TOPIC["Title"]["Properties"] = "varchar(260)";$TOPIC["LastPostTime"]["Properties"] = "INT(11)";$TOPIC["LastPostID"]["Properties"] = "INT(11)";$TOPIC["FirstPostID"]["Properties"] = "INT(11)"; //POSTS$POST[this] = "Post";$POST["ID"]["Name"] = "ID";$POST["TopicID"]["Name"] = "TopicID";$POST["ForumID"]["Name"] = "ForumID";$POST["IP"]["Name"] = "IP";$POST["Time"]["Name"] = "Time";$POST["Reported"]["Name"] = "Reported";$POST["BBCode"]["Name"] = "BBCode";$POST["UserName"]["Name"] = "UserName";$POST["UserID"]["Name"] = "UserID";$POST["EditTime"]["Name"] = "EditTime";$POST["EditUserID"]["Name"] = "EditUserID";$POST["EditReason"]["Name"] = "EditReason";$POST["EditCount"]["Name"] = "EditCount";$POST["EditLocked"]["Name"] = "EditLocked"; $POST["ID"]["Properties"] = "INT(11) primary key AUTO_INCREMENT";$POST["TopicID"]["Properties"] = "INT(11)";$POST["ForumID"]["Properties"] = "INT(11)";$POST["IP"]["Properties"] = "varchar(30)";$POST["Time"]["Properties"] = "INT(11)";$POST["Reported"]["Properties"] = "INT(1)";$POST["BBCode"]["Properties"] = "INT(1)";$POST["UserName"]["Properties"] = "varchar(260)";$POST["UserID"]["Properties"] = "INT(11)";$POST["EditTime"]["Properties"] = "INT(11)";$POST["EditUserID"]["Properties"] = "INT(11)";$POST["EditReason"]["Properties"] = "varchar(260)";$POST["EditCount"]["Properties"] = "INT(3)";$POST["EditLocked"]["Properties"] = "INT(1)"; //FORUMS$FORUM[this] = "Forum";$FORUM["ForumID"]["Name"] = "ForumID";$FORUM["ForumName"]["Name"] = "ForumName";$FORUM["ForumType"]["Name"] = "ForumType";$FORUM["ForumID"]["Properties"] = "INT(11) primary key AUTO_INCREMENT";$FORUM["ForumName"]["Properties"] = "varchar(260)";$FORUM["ForumType"]["Properties"] = "INT(1)"; //TABLE HEADER$DBTables["general"] = '$General';$DBTables["Images"] = '$Images';$DBTables["Ratings"] = '$Ratings';$DBTables["Users"] = '$Users';$DBTables["Groups"] = '$GROUPS';$DBTables["TOPIC"] = '$TOPIC';$DBTables["POST"] = '$POST';$DBTables["FORUM"] = '$FORUM';?> Link to comment Share on other sites More sharing options...
justsomeguy Posted October 6, 2011 Share Posted October 6, 2011 mysql_select_db returns false if there was an error selecting the database. If there's an error selecting the database, then mysql_error will return the error message from MySQL. If mysql_error doesn't return an error message, then there wasn't an error. http://www.php.net/manual/en/function.mysql-select-db.php Returns TRUE on success or FALSE on failure. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.