codingbenn Posted November 2, 2012 Share Posted November 2, 2012 Im trying to connect to it with this code; <?php mysql_connect("localhost", "root", "root") or die("Error connecting to database: ".mysql_error()); mysql_select_db("playerSearch") or die(mysql_error()); ?> but i get this error; Unknown database 'playersearch' any help? Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/ Share on other sites More sharing options...
Psycho Posted November 2, 2012 Share Posted November 2, 2012 Why are you assuming the database is named playerSearch because of a file? In my local MySql installation each database has it's own folder and each table has several files. Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1389755 Share on other sites More sharing options...
codingbenn Posted November 2, 2012 Author Share Posted November 2, 2012 Why are you assuming the database is named playerSearch because of a file? In my local MySql installation each database has it's own folder and each table has several files. well I cant find it anywhere so.. Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1389762 Share on other sites More sharing options...
jcbones Posted November 2, 2012 Share Posted November 2, 2012 Do you have mysql installed? Should reside at C:\\wamp\bin\mysql Do you have phpmyadmin installed? Should reside at C:\\wamp\www\phpmyadmin Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1389796 Share on other sites More sharing options...
Psycho Posted November 2, 2012 Share Posted November 2, 2012 You should log into the database using PhpMyAdmin (or whatever management application you have) to verify what the actual database name is. Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1389797 Share on other sites More sharing options...
codingbenn Posted November 2, 2012 Author Share Posted November 2, 2012 You should log into the database using PhpMyAdmin (or whatever management application you have) to verify what the actual database name is. cant find it for some reason? i dont get why its not coming up Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1389801 Share on other sites More sharing options...
JohnTipperton Posted November 3, 2012 Share Posted November 3, 2012 try to check in phpmyadmin if the database exist. Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1389825 Share on other sites More sharing options...
Pikachu2000 Posted November 3, 2012 Share Posted November 3, 2012 try to check in phpmyadmin if the database exist. That was suggested here: You should log into the database using PhpMyAdmin (or whatever management application you have) to verify what the actual database name is. Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1389834 Share on other sites More sharing options...
JohnTipperton Posted November 3, 2012 Share Posted November 3, 2012 cant find it for some reason? i dont get why its not coming up i see what about checking the database name.. Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1389886 Share on other sites More sharing options...
codingbenn Posted November 3, 2012 Author Share Posted November 3, 2012 i see what about checking the database name.. I have :/ Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1389980 Share on other sites More sharing options...
Pikachu2000 Posted November 3, 2012 Share Posted November 3, 2012 HOW have you checked it? Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390000 Share on other sites More sharing options...
codingbenn Posted November 3, 2012 Author Share Posted November 3, 2012 HOW have you checked it? tried finding it on the phpMyAdmin and searched all the files and folders where it could be and just tried the database name and the table name :/ and both together Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390027 Share on other sites More sharing options...
Pikachu2000 Posted November 3, 2012 Share Posted November 3, 2012 Forgive me for sounding like Captain Obvious here, but if you didn't find it in phpMyAdmin, it doesn't likely exist. Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390028 Share on other sites More sharing options...
codingbenn Posted November 4, 2012 Author Share Posted November 4, 2012 Forgive me for sounding like Captain Obvious here, but if you didn't find it in phpMyAdmin, it doesn't likely exist. but I created it and saved it in sql browser? I can open it in that? argh Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390047 Share on other sites More sharing options...
Pikachu2000 Posted November 4, 2012 Share Posted November 4, 2012 You mean you created it in Microsoft SQL browser? The one for MSSQL databases? If so, there's your problem. Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390050 Share on other sites More sharing options...
codingbenn Posted November 4, 2012 Author Share Posted November 4, 2012 You mean you created it in Microsoft SQL browser? The one for MSSQL databases? If so, there's your problem. nope..in my SQL Browser; Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390097 Share on other sites More sharing options...
Pikachu2000 Posted November 4, 2012 Share Posted November 4, 2012 Ummmm . . . yeah. Same principle: SQLLite != MySQL. Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390103 Share on other sites More sharing options...
codingbenn Posted November 4, 2012 Author Share Posted November 4, 2012 Ummmm . . . yeah. Same principle: SQLLite != MySQL. huh? Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390107 Share on other sites More sharing options...
Pikachu2000 Posted November 4, 2012 Share Posted November 4, 2012 Your database is a SQLLite database. You can't use MySQL functions to connect to it. They're two completely different RDBMSs. Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390108 Share on other sites More sharing options...
codingbenn Posted November 4, 2012 Author Share Posted November 4, 2012 Your database is a SQLLite database. You can't use MySQL functions to connect to it. They're two completely different RDBMSs. oh thanks how do I connect to a SQLLite then? Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390109 Share on other sites More sharing options...
codingbenn Posted November 4, 2012 Author Share Posted November 4, 2012 This is working a treat atm and is only taking seconds to find players; <form method="post"> Enter Player Name: <input type="text" name="playername"> <input type="submit" value="Find ID!"> </form> <br><br><br><center> <?php $search = $_POST["playername"]; $lines = file('h:/cleanedfutplayers.txt'); // Store true when the text is found $found = false; foreach($lines as $line) { if(strpos($line, $search) !== false) { $found = true; echo $line, "<br>"; } } // If the text was not found, show a message if(!$found) { echo "<i>No match found"; } ?> But im getting the end result like this; I wish it would be this easy to seach a JSON file because you can filter that really easily :/ Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390115 Share on other sites More sharing options...
Pikachu2000 Posted November 4, 2012 Share Posted November 4, 2012 If it were me, I'd export it, then import it into MySQL. If you prefer to leave it as is, you'd need to use php's sqlite functions: http://php.net/manual/en/book.sqlite.php Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390116 Share on other sites More sharing options...
codingbenn Posted November 4, 2012 Author Share Posted November 4, 2012 If it were me, I'd export it, then import it into MySQL. If you prefer to leave it as is, you'd need to use php's sqlite functions: http://php.net/manua...book.sqlite.php My code above is alot simpler and shorter than using a database..is there no way to filter it using my code? its just spacing I need to do really I want it to end up like this RESULT 1; Player Name; OVRL: 90 PAC: 90 - DRIB: 90 SHOT: 90 - DEF: 90 PASS: 90 - HEAD: 90 RESULT 2; Player Name; OVRL: 90 PAC: 90 - DRIB: 90 SHOT: 90 - DEF: 90 PASS: 90 - HEAD: 90 RESULT 3; Player Name; OVRL: 90 PAC: 90 - DRIB: 90 SHOT: 90 - DEF: 90 PASS: 90 - HEAD: 90 Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390119 Share on other sites More sharing options...
Pikachu2000 Posted November 4, 2012 Share Posted November 4, 2012 It's already in a database; that's what SQLite is. What you say is now "only taking seconds" should be done in a matter of milliseconds using the correct method of accessing the data. Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390121 Share on other sites More sharing options...
codingbenn Posted November 4, 2012 Author Share Posted November 4, 2012 It's already in a database; that's what SQLite is. What you say is now "only taking seconds" should be done in a matter of milliseconds using the correct method of accessing the data. yes but as being very new to PHP myself working out how to connect to a database and then search it and then filter it and then display it is difficult Link to comment https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/#findComment-1390123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.