Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

PHP API issue only using one API rather than all that is stored in DB

PHP API issue only using one API rather than all that is stored in DB

i spent hours working on this to release to public but this one issue has me confused it will only send to 1 API

PHP Code

<?php 
                                                $insertLogSQL 
= $odb -> prepare("INSERT INTO `logs` VALUES (NULL, :user, :ip, :port, :time, :method, UNIX_TIMESTAMP(), '0')");
                                        
$insertLogSQL -> execute(array(':user' => $_SESSION['username'], ':ip' => $host, ':port' => $port, ':time' => $time, ':method' => $method));
                                        
$SQLSelectAPI = $odb -> query("SELECT `api` FROM `api` ORDER BY RAND () LIMIT 1");
                                        
$SQLSelectAPI2 = $odb -> query("SELECT `api` FROM `api` ORDER BY RAND () LIMIT 2");
                                        while (
$show = $SQLSelectAPI -> fetch(PDO::FETCH_ASSOC))
                                        {
                                            
$arrayFind = array('[host]', '[port]', '[time]', '[method]');
                                            
$arrayReplace = array($host, $port, $time, $method);
                                            
$APILink = $show['api'];
                                            
$APILink = str_replace($arrayFind, $arrayReplace, $APILink);
                                            
$ch = curl_init();
                                            
curl_setopt($ch, CURLOPT_URL, $APILink);
                                            
curl_setopt($ch, CURLOPT_HEADER, 0);
                                            
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
                                            
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                                            
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
                                            
curl_exec($ch);
                                            
curl_close($ch);
                                        } 
It looks like you aren't calling $SQLSelectAPI2
[Image: 4YPLYme.gif]

(Aug 23, 2017 04:45 PM)Payload Wrote:  It looks like you aren't calling $SQLSelectAPI2

Can you help me i'm clueless at mysql i struggle alot at it.
(Aug 23, 2017 04:55 PM)Fiend Wrote:  Can you help me i'm clueless at mysql i struggle alot at it.

I don't want to steer you in the wrong direction as i'm still learning too, but from what I can tell the while loop is only being performed on $SQLSelectAPI , not $SQLSelectAPI2.

In other words you are only showing the results of the first query, not the second.
[Image: 4YPLYme.gif]



Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by Argonaut.exeSep 12, 2020 11:01 AM 20 534 Sep 12, 2020 11:01 AM
Last Post: Quad
[PHP] by JUSTINMay 13, 2019 03:25 AM 6 320 May 13, 2019 03:25 AM
Last Post: BTC
[PHP] by g1noxJan 20, 2017 03:15 PM 10 1,172 Jan 20, 2017 03:15 PM
Last Post: DataBuster