Jump to content

dropfaith

Members
  • Content Count

    1,141
  • Joined

  • Last visited

Community Reputation

0 Neutral

About dropfaith

  • Rank
    Prolific Member
  • Birthday 10/04/1980

Contact Methods

  • Website URL
    http://dropfaithproductions.com

Profile Information

  • Gender
    Male
  1. <?php /* Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'roguebro' with no password) */ // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } echo "<div class='innerleft'>"; // Attempt select query execution $id = $_GET['spotlight']; $sql = "SELECT * FROM champions WHERE id='$id'"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ $i = 0; while($row = mysqli_fetch_array($result)){ $i++; if ($i % 6 == 0) { } //dont loop this echo "<span>" . $row['Name'] . ""; echo "</span>"; echo "<img src=" . $row['image'] . ">"; echo "<span>Statistics</span>"; echo "<ul class='stats'>"; ?> <li><a href="javascript:PowerhouseShowHide('one=block','two=none','three=none')">Four Star</a></li> <li><a href="javascript:PowerhouseShowHide('one=none','two=block','three=none')">Five Star</a></li> <li><a href="javascript:PowerhouseShowHide('one=none','two=none','three=block')">Six Star</a></li> </ul> <div id="one" style="display:none;"> <ul class="data"> <?php echo $row['4stats'] ; ?> </ul> </div> <div id="two" style="display:none;"> <ul class="data"> <?php echo $row['5stats'] ; ?> </ul> </div> <div id="three" style="display:none;"> <ul class="data"> <?php echo $row['6stats'] ; ?> </ul> </div> </div> <div class='innerright'> <ul class='abilities'> <li><a href="javascript:PowerhouseShowHide('sone=block','stwo=none','sthree=none','sfour=none','sfive=none')">Bio</a></li> <li><a href="javascript:PowerhouseShowHide('sone=none','stwo=block','sthree=none','sfour=none','sfive=none')">Synergy</a></li> <li><a href="javascript:PowerhouseShowHide('sone=none','stwo=none','sthree=block','sfour=none','sfive=none')">Specials</a></li> <li><a href="javascript:PowerhouseShowHide('sone=none','stwo=none','sthree=none','sfour=block','sfive=none')">Strenghts</a></li> <li><a href="javascript:PowerhouseShowHide('sone=none','stwo=none','sthree=none','sfour=none','sfive=block')">Weaknesses</a></li> </ul> <div class='innerrightcontent'> <div id="sone" style="display:block;"> <?php echo $row['bio'] ; ?> </div> <div id="sthree" style="display:none;"> <?php echo $row['specials'] ; ?> </div> <div id="sfour" style="display:none;"> <?php echo $row['weaknesses'] ; ?> </div> <div id="sfive" style="display:none;"> <?php echo $row['strenghts'] ; ?> </div> </div> </div> <?php } // Free result set mysqli_free_result($result); } else{ /* echo "No records matching your query were found."; */ } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } // Close connection mysqli_close($link); ?> <div id="stwo" style="display:none;"> <h3>Out Going Synergys</h3> <table> <?php // Check connection if($link1 === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } // Attempt select query execution $id = $_GET['spotlight']; // loop all this $sql1 = "SELECT * FROM synergy WHERE idd='$id'"; if($result1 = mysqli_query($link1, $sql1)){ if(mysqli_num_rows($result1) > 0){ while($row = mysqli_fetch_array($result1)){ echo "<tr>"; echo "<td>" . $row['name'] . ""; echo "</td><td>" . $row['Synergy'] . ""; echo "</td></tr>"; } // Free result set mysqli_free_result($result1); } else{ /* echo "No records matching your query were found."; */ } } else{ echo "ERROR: Could not able to execute $sql1. " . mysqli_error($link1); } ?> </table> this does what i want this from the link i posted... but the join in theory was going to be better coded (learning as i go) so the table champions theres only 1 instance of Id (so no loop) the table Synergy can have up to 8 (needs to loop)
  2. 456 stats data uhmm trying to word <li>Health: 17,180</li> <li>Attack: 1,193</li> <li>Max PI:</li> <li>Without Signature: 3,774</li> <li>With Signature (99): 4,812</li> 5 is diff stats 6 diff as well those arent currently used as i compile that data tho
  3. the link is doing what i want it to do but im using 2 queries to do it and it loses the image which i really want from champion table only other thing i can think of is do a double query and merge the image into the other which should work but i figured 1 total query was better
  4. http://roguebrother.x10host.com/spotlight.php?spotlight=49 Click Synergy on that in the content pane and it displays more context i pretty much need all the stuff so * seemed most efficient? CREATE TABLE IF NOT EXISTS `synergy` ( `idd` int(125) NOT NULL, `name` varchar(500) NOT NULL, `Champ` varchar(50) NOT NULL, `sid` int(124) NOT NULL AUTO_INCREMENT, `Synergy` varchar(6000) NOT NULL, PRIMARY KEY (`sid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ; CREATE TABLE IF NOT EXISTS `champions` ( `Name` text NOT NULL, `image` text NOT NULL, `class` text NOT NULL, `id` int(125) NOT NULL AUTO_INCREMENT, `spotlight` varchar(125) NOT NULL, `4stats` text NOT NULL, `5stats` text NOT NULL, `6stats` text NOT NULL, `bio` text NOT NULL, `specials` text NOT NULL, `weaknesses` text NOT NULL, `strenghts` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=137 ; theres probably a ton of things wrong here as i learn stuff
  5. <?php // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } echo "<div class='innerleft'>"; // Attempt select query execution $id = $_GET['spotlight']; $sql = "SELECT champions.* , synergy.* ". "FROM champions, synergy ". "WHERE champions.id = $id AND synergy.idd = $id"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ while($row = mysqli_fetch_array($result)){ echo "<span>" . $row['Name'] . ""; echo "</span>"; echo "<img src=" . $row['image'] . ">"; echo "<span>Statistics</span>"; echo "<ul class='stats'>"; ?> <div id="stwo" style="display:none;"> <h3>Out Going Synergys</h3> <table> <?php echo "<tr>"; echo "<td><img class='small' src=" . $row['image'] . ">"; echo "</td><td>" . $row['Synergy'] . ""; echo "</td></tr>"; ?> </table> <h3>InComing Synergys</h3> <table> </table> </div> Im likely going to feel stupid once this is answered but im drawing a blank on how to manage this the top part needs not be displayed ones its table.champions the part in the hidden div has multiple rows that need to loop thru (table.synergy) right now its looping the top part but not the second part and if i limit 1 it prevents the second part from a loop as well. im basically teaching myself as i go here
  6. so i know this is an easy one i just cant recall how or what to search to make it work been a bit since ive coded php right now it does everything needed but im trying to clean up the display a bit the echo line just loops the tr and tds endlessly to the left and right What im going for would be more like this Current Result <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> <td>6</td> <td>7</td> <td>8</td> </tr> Result i need <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> <tr> <td>5</td> <td>6</td> <td>7</td> <td>8</td> </tr> and so on Code below $sql = "SELECT * FROM hashtag"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ while($row = mysqli_fetch_array($result)){ echo "<td><h1>" . $row['text'] . "</h1><img src=" . $row['link'] . "></td>"; } // Free result set mysqli_free_result($result); } else{ echo "No records matching your query were found."; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } right now
  7. that fixed that any way to reverse a foreach.. it displays from twitter so the loop is newest first and cycles thus replacing the newest of the tags otherwise i can just dump the foreach loop and have my bot look thru the script more often thus eliminating its need but adding server strain foreach ($user_timeline as $user_tweet) { if (isset($user_tweet->entities->media)) { $media_url = $user_tweet->entities->media[0]->media_url; $hashtag = preg_replace('^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-‌​\.\?\,\'\/\\\+&%\$#_]*)?$^',' ', $user_tweet->text); } /* Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password) */ $link = mysqli_connect("localhost", "roguebro", "eruditio2", "roguebro_tweet"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } // Attempt insert query execution $sql = "INSERT INTO hashtag (hashtag, link) VALUES ('$hashtag', '$media_url') ON DUPLICATE KEY UPDATE link='" . $media_url . "'"; if(mysqli_query($link, $sql)){ echo "Records inserted successfully."; echo ($sql); echo "<br>"; } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } }
  8. hrmm producing an error in this and i thought i had it ERROR: Could not able to execute (INSERT INTO hashtag (hashtag, link) VALUES ('arena ', 'http://pbs.twimg.com/media/C5QtXQEVUAAyk_-.jpg') ON DUPLICATE KEY UPDATE link='http://pbs.twimg.com/media/C5QtXQEVUAAyk_-.jpg'). You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO hashtag (hashtag, link) VALUES ('arena ', 'http://pbs.twimg.com/med' at line 1 /* Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password) */ $link = mysqli_connect("localhost", "roguebro", "", "roguebro_tweet"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } // Attempt insert query execution $sql = "(INSERT INTO hashtag (hashtag, link) VALUES ('$hashtag', '$media_url') ON DUPLICATE KEY UPDATE link='" . $media_url . "')"; if(mysqli_query($link, $sql)){ echo "Records inserted successfully."; } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } // Close connection mysqli_close($link);
  9. Sorry i did that on no sleep at 5 am basically right now it inserts a new row everytime the script runs which isnt ideal for the end game anymore i changed up my other side to fit it better theres 3 columns Id (auto inc) hashtags and link what i need is if hashtag exists edit link to the new link field there will never be more then 1 link in for each hashtag. i know it has something in here and an update instead of insert but im literally clueless on syntax for it function insertTweets($link,$hashtag){ $mysqli = new mysqli(DBHOST, DBUSERNAME, DBPASSWORD, DBNAME); if ($mysqli->connect_errno) { return 'Failed to connect to Database: (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error; } $prepareStmt='insert INTO '.DBNAME.'.'.TWEETTABLE.' (link,hashtag) VALUES (?,?)'; if ($insert_stmt = $mysqli->prepare($prepareStmt)){ $insert_stmt->bind_param('ss', $link,$hashtag); if (!$insert_stmt->execute()) { $insert_stmt->close(); return 'Tweet Creation cannot be done at this moment.'; }elseif($insert_stmt->affected_rows>0){ $insert_stmt->close(); return 'Tweet Added.<br><br>'; }else{ $insert_stmt->close(); return 'No Tweet were Added.'; } }else{ return 'Prepare failed: (' . $mysqli->errno . ') ' . $mysqli->error; } } ?> Not sure how to check the database to see if hashtag exists then update a different field and if not just insert the full query
  10. Sorry this ends this script i got it doing everything i need except its making too many rows for what i need so i figure an update to it if the hashtag field is already in no idea how to do that i am teaching myself this as i go <?php // Require J7mbo's TwitterAPIExchange library (used to retrive the tweets) // You can get this library from here: https://github.com/J7mbo/twitter-api-php require_once('TwitterAPIExchange.php'); /** database cred **/ define('DBHOST','localhost'); define('DBUSERNAME',''); define('DBPASSWORD',''); define('DBNAME','rogueweet'); define('TWEETTABLE','hashtags'); /** end database cred **/ // Set here your twitter application tokens $settings = array( 'oauth_access_token' => "831981818408677377-FeZYWt3TYwmodmx3gMmFIqx", 'oauth_access_token_secret' => "L1vwbaBjsUivKn56V1lSP5THvjBk3LiadHyOj", 'consumer_key' => "t31OianjdeBAjWPqj3", 'consumer_secret' => "zFZpwpaZl0K1CQPpsagBjVCMkTs2GtWHhRm" ); // Set here the Twitter account from where getting latest tweets $screen_name = 'Dropfaith21'; //username to mock twitter feed // Get timeline using TwitterAPIExchange $url = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; $getfield = "?screen_name={$screen_name}"; $requestMethod = 'GET'; $twitter = new TwitterAPIExchange($settings); $user_timeline = $twitter ->setGetfield($getfield) ->buildOauth($url, $requestMethod) ->performRequest(); $user_timeline = json_decode($user_timeline); foreach ($user_timeline as $user_tweet) { if (isset($user_tweet->entities->media)) { $media_url = $user_tweet->entities->media[0]->media_url; $hashtag = preg_replace('^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-‌​\.\?\,\'\/\\\+&%\$#_]*)?$^',' ', $user_tweet->text); // $hashtag = $user_tweet->text; echo "($hashtag)"; echo "<img src='{$media_url}' width='60%' />"; echo insertTweets($media_url,$hashtag); } } function insertTweets($link,$hashtag){ $mysqli = new mysqli(DBHOST, DBUSERNAME, DBPASSWORD, DBNAME); if ($mysqli->connect_errno) { return 'Failed to connect to Database: (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error; } $prepareStmt='insert INTO '.DBNAME.'.'.TWEETTABLE.' (link,hashtag) VALUES (?,?)'; if ($insert_stmt = $mysqli->prepare($prepareStmt)){ $insert_stmt->bind_param('ss', $link,$hashtag); if (!$insert_stmt->execute()) { $insert_stmt->close(); return 'Tweet Creation cannot be done at this moment.'; }elseif($insert_stmt->affected_rows>0){ $insert_stmt->close(); return 'Tweet Added.<br><br>'; }else{ $insert_stmt->close(); return 'No Tweet were Added.'; } }else{ return 'Prepare failed: (' . $mysqli->errno . ') ' . $mysqli->error; } } ?>
  11. if it helps it inserts a 1 to mysql
  12. so i have the array now but cant do anything database wise. i have 4 hashtag fields and a link one the system i need to use matches array(4) { [0]=> string(19) "#ContestOfChampions" [1]=> string(7) "#Cutoff" [2]=> string(9) "#Dormammu" [3]=> string(11) "#JaneFoster" } is a sample array i would love it if i could somehow insert each field into its own mysql column to make my next steps easier
  13. echo insertTweets($items['user']['name'],$items['user']['screen_name'],$items['text'],$items['created_at'],$items['id_str'],$items['user'] ['followers_count'],$hash); /** FInd hashtags build array **/ preg_match_all("/#(\\w+)/",$items['text'],$hashtags); //now $tags is an array of hashtags /** FInd hashtags build array **/ var_dump( $hashtags); } /** Insert to database **/ function insertTweets($name,$screen_name,$text,$created_at,$id_str,$followers_count,$hash){ $mysqli = new mysqli(DBHOST, DBUSERNAME, DBPASSWORD, DBNAME); if ($mysqli->connect_errno) { return 'Failed to connect to Database: (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error; } $prepareStmt='INSERT INTO '.DBNAME.'.'.TWEETTABLE.' (name, screen_name, text, created_at, id_str, followers_count, hashtags) VALUES (?,?,?,?,?,?,?)'; if ($insert_stmt = $mysqli->prepare($prepareStmt)){ $insert_stmt->bind_param('sssssid', $name,$screen_name,$text,$created_at,$id_str,$followers_count,$hash); if (!$insert_stmt->execute()) { $insert_stmt->close(); return 'Tweet Creation cannot be done at this moment.'; }elseif($insert_stmt->affected_rows>0){ $insert_stmt->close(); return 'Tweet Added.<br>'; }else{ $insert_stmt->close(); return 'No Tweet were Added.'; } }else{ return 'Prepare failed: (' . $mysqli->errno . ') ' . $mysqli->error; } }
  14. So i got this pulling twitter data raw i cant for the life of me figure out how to explode items $text(tweet body and seperate the hashtags and enter them into a database (database hase 3 fields for hashtags) <?php /** database cred **/ define('DBHOST','localhost'); define('DBUSERNAME','***'); define('DBPASSWORD','**'); define('DBNAME','roguebro_tweet'); define('TWEETTABLE','twitter'); /** end database cred **/ /** Set access tokens here - see: https://dev.twitter.com/apps/ **/ require_once('TwitterAPIExchange.php'); $settings = array( 'oauth_access_token' => "831981818408677377-FexWOmvCyaZYWt3TYwmodmx3gMmFIqx", 'oauth_access_token_secret' => "L1vwbaBjsUivKn5NYVmGgve6V1lSP5THvjBk3LiadHyOj", 'consumer_key' => "t31OianjtopHhDEdeBAjWPqj3", 'consumer_secret' => "zFZpwrMl31BShY6CluYapaZl0K1CQPpsagBjVCMkTs2GtWHhRm" ); /** end Twitter Credentials **/ $url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; $requestMethod = "GET"; $getfield = '?screen_name=MCoCTrucos&entities=on&count=20 -rt'; $twitter = new TwitterAPIExchange($settings); $string = json_decode($twitter->setGetfield($getfield) ->buildOauth($url, $requestMethod) ->performRequest(),$assoc = TRUE); if($string["errors"][0]["message"] != "") {echo "<h3>Sorry, there was a problem.</h3><p>Twitter returned the following error message:</p><p> <em>".$string[errors][0]["message"]."</em></p>";exit();} foreach($string as $items) { echo "Tweeted by: ". $items['user']['name']."<br />"; echo "Screen name: ". $items['user']['screen_name']."<br />"; echo "Tweet: ". $items['text']."<br />"; echo "Time and Date of Tweet: ".$items['created_at']."<br />"; echo "Tweet ID: ".$items['id_str']."<br />"; echo "Followers: ". $items['user']['followers_count']."<br /><hr />"; echo insertTweets($items['user']['name'],$items['user']['screen_name'],$items['text'],$items['created_at'],$items['id_str'],$items['user']['followers_count']); $tags = $items['text']; $hashtags = explode("#", $tags); } function insertTweets($name,$screen_name,$text,$created_at,$id_str,$followers_count){ $mysqli = new mysqli(DBHOST, DBUSERNAME, DBPASSWORD, DBNAME); if ($mysqli->connect_errno) { return 'Failed to connect to Database: (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error; } $prepareStmt='INSERT INTO '.DBNAME.'.'.TWEETTABLE.' (name, screen_name, text, created_at, id_str, followers_count) VALUES (?,?,?,?,?,?);'; if ($insert_stmt = $mysqli->prepare($prepareStmt)){ $insert_stmt->bind_param('ssssid', $name,$screen_name,$text,$created_at,$id_str,$followers_count); if (!$insert_stmt->execute()) { $insert_stmt->close(); return 'Tweet Creation cannot be done at this moment.'; }elseif($insert_stmt->affected_rows>0){ $insert_stmt->close(); return 'Tweet Added.<br><br>'; }else{ $insert_stmt->close(); return 'No Tweet were Added.'; } }else{ return 'Prepare failed: (' . $mysqli->errno . ') ' . $mysqli->error; } } ?>
  15. So i got the basis of this working here http://www.roguebrother.x10host.com/tweet.php what im trying to do is make it so it searches by not only username(complete) but also a certain hashtag (Duels) And get it to display any media (photos) in said tweet <?php require_once('TwitterAPIExchange.php'); /** Set access tokens here - see: https://dev.twitter.com/apps/ **/ $settings = array( 'oauth_access_token' => "831981818408677377-FexWOmvCyaZYWt3TYwmodmx3gMmFIqx", 'oauth_access_token_secret' => "L1vwbaBjsUivKn5NYVmGgve6V1lSP5THvjBk3LiadHyOj", 'consumer_key' => "t31OianjtopHhDEdeBAjWPqj3", 'consumer_secret' => "zFZpwrMl31BShY6CluYapaZl0K1CQPpsagBjVCMkTs2GtWHhRm" ); $url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; $requestMethod = "GET"; $getfield = 'screen_name=MCoCTrucos&count=1'; $twitter = new TwitterAPIExchange($settings); $string = json_decode($twitter->setGetfield($getfield) ->buildOauth($url, $requestMethod) ->performRequest(),$assoc = TRUE); if($string["errors"][0]["message"] != "") {echo "<h3>Sorry, there was a problem.</h3><p>Twitter returned the following error message:</p><p> <em>".$string[errors][0]["message"]."</em></p>";exit();} foreach($string as $items) { echo "Tweeted by: ". $items['user']['name']."<br />"; echo "Screen name: ". $items['user']['screen_name']."<br />"; echo "Tweet: ". $items['text']."<br />"; echo "Time and Date of Tweet: ".$items['created_at']."<br />"; echo "Tweet ID: ".$items['id_str']."<br />"; echo "Followers: ". $items['user']['followers_count']."<br /><hr />"; } { echo $url;} ?>
×
×
  • 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.