curtis Posted November 15, 2003 Posted November 15, 2003 I am trying to setup a php script called PHP Script Index. I have setup a database and assigned a user. I edited the config.php file for correct info but the script will not create the tables. I did a query on the config file with this result: There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem ERROR: Unknown Punctuation String @ 1 STR: SQL-query : MySQL said: 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 '<? $sqlhost = "localhost"' at line 1 This is the config file:<?################################ # MySQL Variables - Must be configured first! $sqlhost = "localhost"; $sqllogin = "curtismg_user1"; $sqlpass = "xxxxxx"; $sqldb = "curtismg_scriptsindex"; $tablecats = "scriptcats"; $tablescripts = "scripts"; ################################ $sitetitle = "CMGWebmasters"; $main_site_url = "http://www.cmg02.com/webmasters/"; $script_index_url = "http://www.cmg02.com/webmasters/phpscriptsindex/"; $adminemail = "webmaster@cmg02.com"; $emailnotify = "1"; $max_search_results = "30"; $adminpass = "xxxxxx"; $headerfile = ""; $footerfile = ""; $table_width = "98%"; $table_border = "1"; $cellspacing = "3"; $cellpadding = "2"; $table_head_color = "#507ca0"; $table_head_textcolor = "#FFFFFF"; $table_bgcolor = "#EEEEEE"; $table_border_color = "#000000"; $table_textcolor = "#000000"; $fontname = "Verdana, Arial, Helvetica, sans-serif"; $cat_link_color = "#FF0000"; $empty_cat_link_color = "#000000"; $db = mysql_connect($sqlhost, $sqllogin, $sqlpass) or die("OOps!"); mysql_select_db($sqldb, $db); function getcategoriesascombo($selectcat){ global $tablecats; $sql = "select * from $tablecats"; $result = mysql_query($sql) or die("Failed: $sql"); $numrows = mysql_num_rows($result); for ($x=0;$x<$numrows;$x++){ $resrow = mysql_fetch_row($result); $id = $resrow[0]; $cat = $resrow[1]; $selected = ""; if ($id==$selectcat) $selected = " selected"; $cmbcats .= "<option value='$id'$selected>$cat</option>\n"; } return $cmbcats; } ?> Thanks for any help Quote
Lianna Posted November 15, 2003 Posted November 15, 2003 (edited) Curtis, It doesn't appear that the config file actually MAKES the tables. Did this script come with a sql dump file of some kind? Edited November 15, 2003 by TCH-Lianna Quote
curtis Posted November 15, 2003 Author Posted November 15, 2003 Lianna, Yes it has a file call Create Table. After editing the config file you run the Create Tables file. This file: <?include "./config.php"; if ($create){ $sql = "CREATE TABLE $tablescripts ( id int(11) NOT NULL auto_increment, subcat int(11) NOT NULL default '0', email varchar(255) NOT NULL default '', password varchar(255) NOT NULL default '', title varchar(255) NOT NULL default '', homeurl varchar(255) NOT NULL default '', dlurl varchar(255) NOT NULL default '', demourl varchar(255) NOT NULL default '', descr text NOT NULL, price varchar(50) NOT NULL default '', version varchar(10) NOT NULL default '', hitsin int(11) NOT NULL default '0', hitsout int(11) NOT NULL default '0', added datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (id), UNIQUE KEY title (title) ) TYPE=MyISAM;"; $result = mysql_query($sql) or die("Failed: $sql - ".mysql_error()); $sql = "CREATE TABLE $tablecats ( id int(11) NOT NULL auto_increment, cat varchar(255) NOT NULL default '', ct int(11) NOT NULL default '0', PRIMARY KEY (id) ) TYPE=MyISAM;"; $result = mysql_query($sql) or die("Failed: $sql - ".mysql_error()); $catsblob = "INSERT INTO $tablecats VALUES (1, 'Ad Management', 0); INSERT INTO $tablecats VALUES (2, 'Affiliate Programs', 0); INSERT INTO $tablecats VALUES (3, 'Auctions', 0); INSERT INTO $tablecats VALUES (4, 'Banner Exchange', 0); INSERT INTO $tablecats VALUES (5, 'Bookmark Management', 0); INSERT INTO $tablecats VALUES (6, 'Calculators', 0); INSERT INTO $tablecats VALUES (7, 'Calendars', 0); INSERT INTO $tablecats VALUES (8, 'Chat Scripts', 0); INSERT INTO $tablecats VALUES (9, 'Classified Ads', 0); INSERT INTO $tablecats VALUES (10, 'Click Tracking', 0); INSERT INTO $tablecats VALUES (11, 'Communication Tools', 0); INSERT INTO $tablecats VALUES (12, 'Content Management', 0); INSERT INTO $tablecats VALUES (13, 'Contests and Awards', 0); INSERT INTO $tablecats VALUES (14, 'Countdowns', 0); INSERT INTO $tablecats VALUES (15, 'Counters', 0); INSERT INTO $tablecats VALUES (16, 'Customer Support', 0); INSERT INTO $tablecats VALUES (17, 'Database Tools', 0); INSERT INTO $tablecats VALUES (18, 'Date and Time', 0); INSERT INTO $tablecats VALUES (19, 'Development Tools', 0); INSERT INTO $tablecats VALUES (20, 'Discussion Boards', 0); INSERT INTO $tablecats VALUES (21, 'E-Commerce', 0); INSERT INTO $tablecats VALUES (22, 'Education', 0); INSERT INTO $tablecats VALUES (23, 'Email Systems', 0); INSERT INTO $tablecats VALUES (24, 'Error Handling', 0); INSERT INTO $tablecats VALUES (25, 'FAQ and Knowledgebase', 0); INSERT INTO $tablecats VALUES (26, 'File Manipulation', 0); INSERT INTO $tablecats VALUES (27, 'Financial Tools', 0); INSERT INTO $tablecats VALUES (28, 'Flash', 0); INSERT INTO $tablecats VALUES (29, 'Form Processors', 0); INSERT INTO $tablecats VALUES (30, 'Games and Entertainment', 0); INSERT INTO $tablecats VALUES (31, 'Graphs and Charts', 0); INSERT INTO $tablecats VALUES (32, 'Groupware Tools', 0); INSERT INTO $tablecats VALUES (33, 'Guestbooks', 0); INSERT INTO $tablecats VALUES (34, 'Image Galleries', 0); INSERT INTO $tablecats VALUES (35, 'Image Manipulation', 0); INSERT INTO $tablecats VALUES (36, 'Interactive Stories', 0); INSERT INTO $tablecats VALUES (37, 'Link Checking', 0); INSERT INTO $tablecats VALUES (38, 'Link Indexing', 0); INSERT INTO $tablecats VALUES (39, 'Mailing List Managers', 0); INSERT INTO $tablecats VALUES (40, 'Miscellaneous', 0); INSERT INTO $tablecats VALUES (41, 'Multi-Level Marketing', 0); INSERT INTO $tablecats VALUES (42, 'Multimedia', 0); INSERT INTO $tablecats VALUES (43, 'Music Libraries', 0); INSERT INTO $tablecats VALUES (44, 'Networking Tools', 0); INSERT INTO $tablecats VALUES (45, 'News Publishing', 0); INSERT INTO $tablecats VALUES (46, 'Open Directory Project', 0); INSERT INTO $tablecats VALUES (47, 'Organizers', 0); INSERT INTO $tablecats VALUES (48, 'Polls and Voting', 0); INSERT INTO $tablecats VALUES (49, 'Portal Systems', 0); INSERT INTO $tablecats VALUES (50, 'Postcards', 0); INSERT INTO $tablecats VALUES (51, 'Quote Display', 0); INSERT INTO $tablecats VALUES (52, 'Randomizing', 0); INSERT INTO $tablecats VALUES (53, 'Redirection', 0); INSERT INTO $tablecats VALUES (54, 'Reviews and Ratings', 0); INSERT INTO $tablecats VALUES (55, 'Search Engines', 0); INSERT INTO $tablecats VALUES (56, 'Security Systems', 0); INSERT INTO $tablecats VALUES (57, 'Server Management', 0); INSERT INTO $tablecats VALUES (58, 'Site Mapping', 0); INSERT INTO $tablecats VALUES (59, 'Site Navigation', 0); INSERT INTO $tablecats VALUES (60, 'Site Recommendation', 0); INSERT INTO $tablecats VALUES (61, 'Software Repository', 0); INSERT INTO $tablecats VALUES (62, 'Tests and Quizzes', 0); INSERT INTO $tablecats VALUES (63, 'Top Sites', 0); INSERT INTO $tablecats VALUES (64, 'URL Submitters', 0); INSERT INTO $tablecats VALUES (65, 'Usenet Gateway', 0); INSERT INTO $tablecats VALUES (66, 'User Authentication', 0); INSERT INTO $tablecats VALUES (67, 'User Management', 0); INSERT INTO $tablecats VALUES (68, 'Vertical Markets', 0); INSERT INTO $tablecats VALUES (69, 'Virtual Communities', 0); INSERT INTO $tablecats VALUES (70, 'WAP and WML', 0); INSERT INTO $tablecats VALUES (71, 'Web Fetching', 0); INSERT INTO $tablecats VALUES (72, 'Web Hosting Tools', 0); INSERT INTO $tablecats VALUES (73, 'Web Rings', 0); INSERT INTO $tablecats VALUES (74, 'Web Search', 0); INSERT INTO $tablecats VALUES (75, 'Web Traffic Analysis', 0); INSERT INTO $tablecats VALUES (76, 'XML', 0);"; $arsql = explode("\n", $catsblob); $ctcnt = count($arsql); for($x=0;$x<$ctcnt;$x++){ $sql = $arsql[$x]; $sql = str_replace("\n", "", $sql); $result = mysql_query($sql) or die("Failed: $sql - ".mysql_error()); } print "The MySQL tables <b>$tablecats</b> and <b>$tablescripts</b> have been created and are ready for use! I highly suggest that you now delete <b>create_tables.php</b> before you continue."; exit; } ?> <p>This script will automatically create the MySQL table for PHP Script Index. You MUST edit config.php before this script can be run. The 'Create Table' button will appear below if you've successfully given all the info needed to do this. Please review the info below just to be sure:</p> <p>Database Host: <? print $sqlhost; ?><br> Database Login: <? print $sqllogin; ?><br> Database Password: <? print $sqlpass; ?><br> Database Name: <? print $sqldb; ?><br> Scripts Table Name: <? print $tablescripts; ?><br> Categories Table Name: <? print $tablecats; ?><br> <br> <br> If this is all correct, click the 'Create Table' button below. If the button does not show below, it's because one of these fields are empty.</p> <? if ($sqlhost && $sqllogin && $sqldb && $tablescripts && $tablecats) print "<form name='form1' method='post' action='create_tables.php'> <div align='center'> <input type='hidden' name='create' value='1'> <input type='submit' value='Create Table!'> </div><br><br><b>Note: This script will not create the \"$sqldb\" database. It only creates the tables in the database. You may need to create the database yourself if \"$sqldb\" does not exist.</b> </form>"; ?> The create button doesn't show and no info is listed in any of the database spaces. This is why I ran the query on the config file,thinking maybe some error in config. Thanks for your time on this. Quote
Lianna Posted November 16, 2003 Posted November 16, 2003 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 '<?$sqlhost = "localhost"' at line 1 Ok, that looks like MySQL doesn't know that <? isn't a part of the MySQL line. Since I don't know beans about PHP, anything I say right now will sound very dumb. Tell ya what, give me a bit and I'll try it out myself. BRB Quote
Lianna Posted November 16, 2003 Posted November 16, 2003 Dude, mine worked fine. what the hay? Steps I took: Downloaded the zip file and extracted it to local drive Opened the config.php file in Notepad and edited the stuff I needed to <?################################ # MySQL Variables - Must be configured first! $sqlhost = "localhost"; $sqllogin = "stoverld_user1"; $sqlpass = "*******"; $sqldb = "stoverld_scriptsindex"; $tablecats = "scriptcats"; $tablescripts = "scripts"; ################################ $sitetitle = "Stover test"; $main_site_url = "http://www.stoverdatasystems.us/"; $script_index_url = "http://www.stoverdatasystems.us/php/"; $adminemail = "root@localhost"; $emailnotify = "1"; $max_search_results = "30"; $adminpass = "*******"; Saved it and closed it. Opened FTP and created directory /php in public_html FTP'd all the unzipped files to the /php directory Opened web browser and went to stoverdatasystems.us/php/create_tables.php All appeared fine and I clicked the button to create the tables. Tables created fine. Quote
Lianna Posted November 16, 2003 Posted November 16, 2003 (edited) I just pm'd you. Edited November 16, 2003 by TCH-Lianna Quote
vendlus Posted November 16, 2003 Posted November 16, 2003 Assuming this is not resolved by now.... Not sure exactly how it's all setup here (are you hosting this here?), but I've had times where I had to specify the php on my inline code..... <?php echo $sql ?> Also, is the code listed the exact code from the original or an exact copy of what is actually on your server? I'm asking because that error makes it look like a semi colon was left out or deleted somewhere and the parser is trying to read past the end of a statement. But I didn't see any error in the code on first glance. If Lianna hasn't fixed it all up yet, hollar and I'll help you guys look into it. *edit* I just realized that you said that the database info doesn't list. Sounds like the config file isn't being found. Are both of these files in the same folder? Quote
Lianna Posted November 16, 2003 Posted November 16, 2003 Resolved. It was a misunderstanding of the install instructions. Nothing wrong with the script. vendlus, thanks for jumping in with offer to help. Quote
curtis Posted November 16, 2003 Author Posted November 16, 2003 Thanks Lianna. Its working fine now. Sometime you can't see the forest for the trees or in my case you don't read the docs. vendlus, thanks for your help also. Quote
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.