Jump to content

babygurl

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

babygurl's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. WISH CODING WAS THIS EASY!!! LOL <?php //get cookie do step1,step2,step3 if (isset($_COOKIE["user"])) //step1 mysql_connect("localhost", "root", ""); mysql_select_db("register_db"); $result = mysql_query("SELECT * FROM register_vote WHERE name = '{$_COOKIE["user"]}'"); //step2 if ($result) while($row = mysql_fetch_array($result)){ //step3 echo $row['name'] . "|gtop100:" . $row['gtop100'] . "|mcservers:" . $row['mcservers'] . "|xtremetop100:" . $row['xtremetop100']; //if user has not inserted usernmae just echo false user else echo "false|gtop100:false|mcservers:false|xtremetop100:false"; //if user submited username set cookie and start at step 1 ?>
  2. so would something like this work or is this just completely wrong <?php //get cookie and query user else echo false user if (isset($_COOKIE["user"])) $user = $_COOKIE['user']; } else if (isset($_POST['user'])) { $user = $_POST['user']; mysql_connect("localhost", "root", ""); mysql_select_db("register_db"); $result = mysql_query("SELECT * FROM register_vote WHERE name = '{$_COOKIE["user"]}'"); while($row = mysql_fetch_array($result)){ echo $row['name'] . "|gtop100:" . $row['gtop100'] . "|mcservers:" . $row['mcservers'] . "|xtremetop100:" . $row['xtremetop100']; else echo "false|gtop100:false|mcservers:false|xtremetop100:false"; //and somehow "setcookie" when user submits $_POST['user'] from interface.php setcookie("DWcookie", $_POST[user], time()+3600); ?> <?php mysql_connect("localhost", "root", ""); mysql_select_db("register_db"); $result = mysql_query("SELECT * FROM register_vote WHERE name = '{$_COOKIE["user"]}'"); if ($result) while($row = mysql_fetch_array($result)){ echo $row['name'] . "|gtop100:" . $row['gtop100'] . "|mcservers:" . $row['mcservers'] . "|xtremetop100:" . $row['xtremetop100']; else $sql="INSERT INTO register_vote (id, user) VALUES ('','$_COOKIE["user"')"; $result = mysql_query("SELECT * FROM register_vote WHERE name = '{$_COOKIE["user"]}'"); echo $row['name'] . "|gtop100:" . $row['gtop100'] . "|mcservers:" . $row['mcservers'] . "|xtremetop100:" . $row['xtremetop100']; ?>
  3. Got some of the coding but I think my issues are with the syntax:( any help would be amazing thank you in advance:) can i make the code query the sql from the cookie only? instead of &_post[user]??? so maybe $sql="INSERT INTO register_vote (id, user) VALUES (''isset($_COOKIE["user"]')";?? http://pastebin.com/BuRVSbG3 <?php //get cookie and query user else echo false user if (isset($_COOKIE["user"])) //if user exist query sql for user and echo table below echo "false|gtop100:false|mcservers:false|xtremetop100:false"; else echo "false|gtop100:false|mcservers:false|xtremetop100:false"; //and somehow "setcookie" when user submits $_POST['user'] from interface.php ?> <?php mysql_connect("localhost", "root", ""); mysql_select_db("register_db"); $result = mysql_query("SELECT * FROM register_vote WHERE name = '{$_POST['user']}'"); if ($result) while($row = mysql_fetch_array($result)){ echo $row['name'] . "|gtop100:" . $row['gtop100'] . "|mcservers:" . $row['mcservers'] . "|xtremetop100:" . $row['xtremetop100']; else $sql="INSERT INTO register_vote (id, user) VALUES ('','$_POST[user]')"; $result = mysql_query("SELECT * FROM register_vote WHERE name = '{$_POST['user']}'"); echo $row['name'] . "|gtop100:" . $row['gtop100'] . "|mcservers:" . $row['mcservers'] . "|xtremetop100:" . $row['xtremetop100']; ?>
  4. i have a script that calls to my php every 1 min and its sending this (action, query) scource (action=query) what is this and can i get it to return a value like "data:data:data:data" ???
  5. I get to errors below and cannot figure out what im doign wrong i've tryed diffrent ways and have even rewritten this couple times (#1error) not sure how to re query and echo out the array?? (#2error) gives me error on line 14 if i echo anything past HERE echo $row['name']."|gtop100:". $row['gtop100']. "|mcservers:". $row['mcservers']. !!!!ANTHING PAST THIS!!!"|xtremetop100:". $row['xtremetop100']; ok let me explain the project better, this is a voting interface used for a game server. the interface.php contains values such as $_POST['user'] when the user logs in it goes to the vote.php and does this process( check if $_POST['user'] exist if not insert into register_vote, the sql auto genrates 3 values gtop100,mcserver,xtremetop and sets defualts @ false. then it querys the register_vote for if $_POST['user']=username and echos out while($row = mysql_fetch_array($result)){ echo $row['name']."|gtop100:". $row['gtop100']. "|mcservers:". $row['mcservers']. "|xtremetop100:". $row['xtremetop100']; and and respnds to the interface.php with these values (test=username for the example) test|gtop100:false|mcservers:false|xtremetop100:false <?php $conn = mysql_connect("localhost", "root", ""); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); } if (!mysql_select_db("register_db")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $result = mysql_query("SELECT * FROM register_vote WHERE name = '{$_POST['user']}'"); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } =========================(#1error)========================================== //THIS IS THE CODE I'M HAVING ISSUES WITH if (mysql_num_rows($result) == 0) { mysql_query("INSERT INTO register_vote (name) VALUES ('$_POST[user]')"); //need it to the query new results after insert //then //echo $row['name']."|gtop100:". $row['gtop100']. "|mcservers:". $row['mcservers']. "|xtremetop100:". $row['xtremetop100']; }================================================= (#2error)=================================== while ($row = mysql_fetch_array($result)) { echo $row['name']."|gtop100:". $row['gtop100']. "|mcservers:". $row['mcservers']; } //when I put anything past $row['mcservers'] it gives me error on line 14 and then on page load it automatically send this error Notice: Undefined index: user in C:\wamp blah blah line 14 mysql_free_result($result); ?>
  6. I get to errors below and cannot figure out what im doign wrong i've tryed diffrent ways and have even rewritten this couple times (#1error) not sure how to re query and echo out the array?? (#2error) gives me error on line 14 if i echo anything past (echo $row['name']."|user1:". $row['user1']. "|user2:". $row['user2']. ->this <?php $conn = mysql_connect("localhost", "root", ""); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); } if (!mysql_select_db("register_db")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $result = mysql_query("SELECT * FROM register_vote WHERE name = '{$_POST['user']}'"); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } =========================(#1error)========================================== //THIS IS THE CODE I'M HAVING ISSUES WITH if (mysql_num_rows($result) == 0) { mysql_query("INSERT INTO register_vote (name) VALUES ('$_POST[user]')"); //need it to the query new results after insert //then // echo $row['name']."|user1:". $row['user1']. "|user2:". $row['user2']. "|user3:". $row['user3']; }================================================= (#2error)=================================== while ($row = mysql_fetch_array($result)) { echo $row['name']."|user1:". $row['user1']. "|user2:". $row['user2']. "|user3:". $row['user3']; } //when I put anything past $row['user2']. it gives me error on line 14 mysql_free_result($result); ?>
  7. ooops, sorry i thought the title gave it away...? lol well i figured it out:) it is a mysql error display:)
  8. Hello i have an issue i cant figure out i'm looking for little help on this one <br /><font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'><tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: user in C:\wamp\www\localhost\Minecraft\vote_interface.php on line <i>8</i></th></tr><tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr><tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr><tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0008</td><td bgcolor='#eeeeec' align='right'>675696</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\localhost\Minecraft\vote_interface.php' bgcolor='#eeeeec'>..\vote_interface.php<b>:</b>0</td></tr></table></font>
  9. so ive read up on some ajax and some php/mysql and understand a little better however this style of coding is nothing like what i've seen on the net a lot of values are flopped and split.. im also confused on another part: <a id="link1" target='_blank' href="vote.php?site=gtop100" onclick="trackVote("Gtop100")"><button id="gtop100_vote_button" width="108"> is the link to the site stored in MYsql and when it ?site=gtop100 is their something in the vote.php and what does onlick="trackvote do is that custom function? ..so i guess i'm trying to figure out the order< html sends $user and ID=link1 to vote.php and post info into the tables?
  10. Hello, i'm new to the scene and started a project 4 months back and have learned a lot along the way i originally had help with this project but over time have lost team members, so i'm having to learn a lot more then anticipated. I've been stuck on this problem for about month now and am seeking some help please:) the following code is a voting interface for a website, most this code was done by a user that has left the team and cannot help anymore:( i have to figure out how to write two .php scripts Vote.interface.php and do_vote.php, however i cannot figure out how what to write and how the values are carried to the sql and returned $(function(){$("#accordion").accordion({header:"h4"});$("#dialog").dialog({autoOpen:!1,width:600,buttons:{Ok:function(){$(this).dialog("close")},Cancel:function(){$(this).dialog("close")}}});$("#dialog_link").click(function(){$("#dialog").dialog("open");return!1});$("#dialog_link, ul#icons li").hover(function(){$(this).addClass("ui-state-hover")},function(){$(this).removeClass("ui-state-hover")})}); $(document).ready(function(){$("#loginButton").click(function(){document.getElementById("userInput");return!1});$("#logoutButton").click(function(){$("#logoutPane").slideToggle("medium");$("#loginPane").slideToggle("medium");return!1})}); function dryQuery(){var a;a=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");a.onreadystatechange=function(){4==a.readyState&&200==a.status&&processResponce(!0,a.responseText)};a.open("POST","vote_interface.php",!0);a.setRequestHeader("Content-type","application/x-www-form-urlencoded");a.send("action=query")} function loginUser(a){if("Minecraft Username"!=a){document.getElementById("displayUser1").innerHTML=a;document.getElementById("displayUser2").innerHTML=a;var b;b=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");b.onreadystatechange=function(){4==b.readyState&&200==b.status&&processResponce(!0,b.responseText)};"Bot"==a||3<=a.split(".").length?b.open("POST","vote_interface.php",!1):b.open("POST","vote_interface.php",!0);b.setRequestHeader("Content-type","application/x-www-form-urlencoded"); b.send("action=login&user="+a)}} function logoutUser(){document.getElementById("displayUser1").innerHTML="<a color='red'>Logged Out!</a>";document.getElementById("displayUser2").innerHTML="<a color='red'>Logged Out!</a>";document.getElementById("userInput").value="Minecraft Username";var a;a=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");a.onreadystatechange=function(){};a.open("POST","vote_interface.php",!1);a.setRequestHeader("Content-type","application/x-www-form-urlencoded");a.send("action=logout"); location.reload(!0)}function updateQuery(){var a;a=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");a.onreadystatechange=function(){4==a.readyState&&200==a.status&&processResponce(!1,a.responseText)};a.open("POST","vote_interface.php",!0);a.setRequestHeader("Content-type","application/x-www-form-urlencoded");a.send("action=query")} function processResponce(a,b){var c=b.split("|");if("false"!=c[0]){$user=c[0];document.getElementById("displayUser1").innerHTML=$user;document.getElementById("displayUser2").innerHTML=$user;document.getElementById("userInput").value=$user;if(3<=$user.split(".").length||"Override"==$user)document.getElementById("link1").target="_self",document.getElementById("link2").target="_self",document.getElementById("link3").target="_self";$gtop100_secsLeft=c[1].split(":")[1];$mcservers_secsLeft=c[2].split(":")[1]; xtremetop100_secsLeft=c[3].split(":")[1];"false"!=$gtop100_secsLeft?(document.getElementById("gtop100_vote_button").disabled=!0,document.getElementById("gtop100_handIcon").style.visibility="hidden",$("#gtop100_countdown").countdown({until:+$gtop100_secsLeft,compact:!0,layout:"{hnn}{sep}{mnn}{sep}{snn}",onExpiry:updateQuery})):document.getElementById("gtop100_vote_button").disabled=!1;"false"!=$mcservers_secsLeft?(document.getElementById("mcservers_vote_button").disabled=!0,document.getElementById("mcservers_handIcon").style.visibility= "hidden",$("#mcservers_countdown").countdown({until:+$mcservers_secsLeft,compact:!0,layout:"{hnn}{sep}{mnn}{sep}{snn}",onExpiry:updateQuery})):document.getElementById("mcservers_vote_button").disabled=!1;"false"!=xtremetop100_secsLeft?(document.getElementById("xtremetop100_vote_button").disabled=!0,document.getElementById("xtremetop100_handIcon").style.visibility="hidden",$("#xtremetop100_countdown").countdown({until:+xtremetop100_secsLeft,compact:!0,layout:"{hnn}{sep}{mnn}{sep}{snn}",onExpiry:updateQuery})): document.getElementById("xtremetop100_vote_button").disabled=!1;a&&($("#loginPane").slideToggle("medium"),$("#logoutPane").slideToggle("medium"),$("#step2").click())}}function checkSubmit(){if(window.event&&13==window.event.keyCode)document.getElementById("loginButton").click();else return!0}dryQuery();setInterval("updateQuery()",3E4);
×
×
  • 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.