i have a simple function, which should query the USGN number from the table and insert it into CURL request, but its giving white page...
For my bad luck i cannot provide error, its just blank page.
here is the script:
function getUSGNavatar($id) {
$usgn = mysql_query("SELECT * FROM cm_users WHERE USGN = '$usgn' AND ID = '$id'") or die(mysql_error());
return mysql_fetch_assoc($usgn);
// CURL
$ch = curl_init('http://www.unrealsoftware.de/getuserdata.php?id='$usgn'&data=avatar');
curl_exec($ch);
if(!curl_errno($ch))
{
$info = curl_getinfo($ch);
}
curl_close($ch);
// CLOSE function
}
Thanks for help
Something messed up with the query part i am sure, curl works okay, when ididn't used mysql worked fine.
I will rewrite Mysql into PDO, or MySQLI please dont mention it.
You are returning i.e. return mysql_fetch_assoc($usgn);
and you should not be as this will finish the function at that point.
Oh and your string building in $ch = curl_init('http://www.unrealsoftware.de/getuserdata.php?id='$usgn'&data=avatar');
also had a problem.
function getUSGNavatar($id) {
$usgn = mysql_query("SELECT *
FROM cm_users
WHERE ID = '$id'");
if ( ! $usgn ) {
echo mysql_error();
}
$row = mysql_fetch_assoc($usgn);
// CURL
$ch = curl_init('http://www.unrealsoftware.de/getuserdata.php?id=' .
$row['USGN'] . '&data=avatar');
curl_exec($ch);
if(!curl_errno($ch)) {
$info = curl_getinfo($ch);
}
curl_close($ch);
// now you probably want to return something from the function
return $info;
}
Oh and as per your request I will not nag you about the use of the deprecated
mysql_
database extension, because we believe you that you will rewrite this code once its working, dont we?
you're getting the blank page because of this:
id='$usgn'&data
change this to:
id='.$usgn.'&data
you're missing the "."