Jump to content

php/Mysql Insert refused


nisroc

Recommended Posts

I get this error when I try to scrap data and enter it  directly into a Mysql database. The error i get is:

 

Warning: mysql_connect(): No connection could be made because the target machine actively refused it. in D:\xampp\htdocs\scripts\index.php on line 7
Could not connect: No connection could be made because the target machine actively refused it.

 

It works just cannot get it to insert data, I am quite a rookie at php/mysql and my only guess is something to do with my query and table.

 

Can anyone help out here?

<?php

$dbhost = 'localhost:3036';
$dbuser = 'Name';
$dbpass = 'pass';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}

// Scrap
include('simple_html_dom.php');

$html = file_get_html('http://www.lottolore.com/lotto649.html');

$one = $html->find('table[width=480]', 0)->find('td', 0)->plaintext;
$two = $html->find('table[width=480]', 0)->find('td', 1)->plaintext;
$three = $html->find('table[width=480]', 0)->find('td', 2)->plaintext;
$four = $html->find('table[width=480]', 0)->find('td', 3)->plaintext;
$five = $html->find('table[width=480]', 0)->find('td', 4)->plaintext;
$six = $html->find('table[width=480]', 0)->find('td', 5)->plaintext;
$seven = $html->find('table[width=480]', 0)->find('td', 6)->plaintext;


$bonus = str_replace('Bonus ', '', $seven);
$today = date("Y-m-d");

//Scrap end

$sql = 'INSERT INTO draws '.
       '(Date, Number1, Number2, Number3, Number4, Number5, Number6, Bonus) '.
       'VALUES ( $today, $one, $two, $three, $four, $five, $six, $bonus )';


mysql_select_db('lotto');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";
mysql_close($conn);
?>
Link to comment
https://forums.phpfreaks.com/topic/287402-phpmysql-insert-refused/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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