0

I want to parse a log file into a table in my database using PHP, but I keep getting an error saying

php parse error, unexpected mysql_select_db command

any ideas??

Here's my code;

<?
$handle = @fopen("NeXposeResults.txt","r");
$conn = mysql_connect("localhost")
mysql_select_db("resultsdb.mwb",$conn);

$values=;

while (!feof($handle))
{
    $buffer = fgets($handle, 4096);
    list ($a,$b,$c)=explode("|",$buffer);
    values.=($a,$b,$c);

    INSERT INTO storage (Description, Severity, Risk Score,)
    VALUES ($a,$b,$c,)
}
?>
2
  • resultsdb.mwb you're sure that this is your db name? Commented Feb 26, 2013 at 20:53
  • - Dont' use mysql_, use mysqli_ or PDO phpmaster.com/avoid-the-original-mysql-extension-1 - .mwb is a mysql workbench file and not a database. Commented Feb 26, 2013 at 20:56

1 Answer 1

2

You're missing a semicolon on line 3.

$conn = mysql_connect("localhost") should be $conn = mysql_connect("localhost");

Sign up to request clarification or add additional context in comments.

1 Comment

No worries. You're also missing them inside of your while loop: INSERT INTO storage (Description, Severity, Risk Score,) VALUES ($a,$b,$c,) should read INSERT INTO storage (Description, Severity, Risk Score,); VALUES ($a,$b,$c,);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.