Jump to content

Recommended Posts

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'

 

c93d416cb65fcbbebb55f78fa7807926.png

 

 

 

any help?

Edited by codingbenn
Link to comment
https://forums.phpfreaks.com/topic/270216-trouble-connecting-to-my-sql-database/
Share on other sites

  On 11/2/2012 at 7:01 PM, Psycho said:

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..

  On 11/2/2012 at 10:04 PM, Psycho said:

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

  On 11/3/2012 at 1:10 AM, JohnTipperton said:

try to check in phpmyadmin if the database exist.

 

That was suggested here:

 

  On 11/2/2012 at 10:04 PM, Psycho said:

You should log into the database using PhpMyAdmin (or whatever management application you have) to verify what the actual database name is.

  On 11/3/2012 at 11:07 PM, Pikachu2000 said:

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

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;

210bf7984fa076d71b9ae826edfef282.png

I wish it would be this easy to seach a JSON file because you can filter that really easily :/

Edited by codingbenn
  On 11/4/2012 at 2:18 PM, Pikachu2000 said:

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

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.

  On 11/4/2012 at 2:38 PM, Pikachu2000 said:

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.