Hey guys, so I'm having some issues putting my script together.. Basically, I'm trying to loop through my database and send each entry username to a url, and once through all entries, send 'done'.
Using PHPStorm and getting an "Expecting statement' error. Here's what I have so far:
<?php
define('DB_NAME', '');
define('DB_USER', '');
define('DB_PASS', '');
define('DB_HOST', '');
$action=$_POST['action'];
$targeturl=$_POST['url'];
$avatarname = $_POST['avatarname'];
$database_link = mysql_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if(!isset($database_link))
{
die('Connection Failure: '.mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $database_link);
if(!isset($db_selected))
{
die('Can\'t use '.DB_NAME.': '.mysql_error());
}
if($action == 'download')
{
$loop = mysql_query("SELECT * FROM accesslist") or die (mysql_error());
while ($row = mysql_fetch_array($loop))
{
$myvars = 'myvar1='.$row['avatarname'];
$ch = curl_init( $targeturl );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
}
else
{
$myvars = 'myvar1='.'done';
$ch = curl_init( $targeturl );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
}
}
?>
Thanks!