laserdude45 Posted October 10, 2006 Share Posted October 10, 2006 Can someone tell me whats wrong with this sql statement andor function![code]function Get_Theme(){ $sql = "SELECT * FROM pm_theme WHERE current=1"; $res = mysql_query($sql); while ($row = mysql_fetch_object($res)); { $theme_name = $row->name; } $theme = $theme_name; return($theme);}[/code] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 10, 2006 Share Posted October 10, 2006 Are you seeing any errors? Why do you think it is wrong?Remove the semi-colon at the end of the while statement.If you're expecting multiple rows from the query, the code will only return the last value.If there is only one possible row, I would write the code something like:[code]<?phpfunction Get_Theme(){ $sql = "SELECT name FROM pm_theme WHERE current=1"; $res = mysql_query($sql); if(!$res) return(mysql_error()); // syntax error in the select statement $row = mysql_fetch_assoc($res); return($row['name']);}?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
laserdude45 Posted October 10, 2006 Author Share Posted October 10, 2006 Ok heres the problem, nothing shows up on the screen... A theme should come up but for some reason nothing shows up! Im getting mad because Ive been working on this one littile part of my script for over a week!Btw.. I tried the code but it didnt work... but thanks for helping :)So if anyone can think why it wouldnt work or would like to see the source code just post :)EDIT: lol as soon as I posted that I rember now that I forgot to change something in the DB lol... I'll fix this and see if it works!EDIT EDIT: Well after getting mysql to work lol(Error 2013) it still doesnt work... Nothing shows up, It retrives the file in theory but it doesnt work! So if anyone can figure out why or tell me that its not that function that's causing the problem please say, Im gonna try one more thing but I dont think it will make a differnece... Quote Link to comment Share on other sites More sharing options...
laserdude45 Posted October 10, 2006 Author Share Posted October 10, 2006 Heres the code, http://gtaa.exofire.net/phpmissile.zip if someone can tell me why its not working....BTW you need to edit config.php in includes folder to your mysql stuffAND you need to execute this code on a database,[code]CREATE TABLE `pm_admin` ( `user` text NOT NULL, `pass` text NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1;CREATE TABLE `pm_modules` ( `id` int(11) NOT NULL auto_increment, `title` text NOT NULL, `custom` text NOT NULL, `active` tinyint(4) NOT NULL, `onmenu` tinyint(4) NOT NULL, `Admin_des` text NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;INSERT INTO `pm_modules` VALUES (1, 'Test', 'Test', 1, 1, 'A test module for phpmissile');CREATE TABLE `pm_news` ( `id` int(11) NOT NULL auto_increment, `heading` tinytext NOT NULL, `content` longtext NOT NULL, `author` tinytext NOT NULL, `date` date NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;INSERT INTO `pm_news` VALUES (1, 'Your site has been setup', 'Welcome to the wonderful phpmissile Alpha 1!\r\n\r\nGoto admin/s.php .\r\n\r\nAfter you create the user, you must delete s.php.', 'Anthony Crognale', '2006-09-24');Post your resultsCREATE TABLE `pm_theme` ( `id` int(11) NOT NULL auto_increment, `name` text NOT NULL, `current` int(11) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;INSERT INTO `pm_theme` VALUES (1, 'pm', 1);[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.