nisroc Posted March 30, 2014 Share Posted March 30, 2014 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 7Could 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 More sharing options...
boompa Posted March 30, 2014 Share Posted March 30, 2014 The standard port for mysql is 3306, not 3036. Link to comment https://forums.phpfreaks.com/topic/287402-phpmysql-insert-refused/#findComment-1474459 Share on other sites More sharing options...
nisroc Posted March 30, 2014 Author Share Posted March 30, 2014 oh doh, that worked when changed but got another error to work on. thank you Link to comment https://forums.phpfreaks.com/topic/287402-phpmysql-insert-refused/#findComment-1474460 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.