Jump to content

shadrxninga

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

shadrxninga's Achievements

Member

Member (2/5)

0

Reputation

  1. I've got this string from an rss feed "2011-11-16T06:05:15Z" , I'm not good a regex at all... I would love to be but I don't have time to learn it at the moment. What I was hoping someone good do was give me some regular expressions that would separate the date out, So I would be able to make 4 variables that contained the following: $year = "2011" $month = "11" $date = "16" $time = "06:05:15" This is so I can then return the string as "16 Nov, 2011 06:05:15" If you know a better way to change the first date to the second one that would also be fantastic, or though I think this will have to require regex. Which is why I am posting it here. Thanks a bunch shadrxninga
  2. I'm not sure how to put in a tab when editing php with php $fh = fopen(MYBB_ROOT.'/member.php', "r") or cperror("Could not open file!"); //OPEN FILE $data = fread($fh, filesize(MYBB_ROOT.'/member.php')) or cperror("Could not read file!"); //MAKE TEMPORARY STRING fclose($fh); //CLOSE FILE AGAIN $newdata = preg_replace('#'.preg_quote('eval("\$online_status = \"".$templates->get("member_profile_online")."\";"); if(is_super_admin($memprofile[\'uid\'])){ eval("\$online_status = \"".$templates->get("unknownlocation")."\";"); }').'#','\t\teval("\\\\$online_status = \"".$templates->get("member_profile_online")."\";");',$data); //REPLACE IN STRING $fw = fopen(MYBB_ROOT.'/member.php', "w") or cperror('Could not open file!'); //OPEN FILE AGAIN $fb = fwrite($fw, $newdata) or cperror('Could not write to file'); //WRITE STRING TO FILE fclose($fw); //CLOSE FILE AGAIN } I need to tab that line twice so it lines up in the file, i've tried putting \t in twice but that doesn't work and just gives this error Fatal error: Call to undefined function teval() in /Applications/XAMPP/xamppfiles/htdocs/member.php on line 1621 So, how to you put tabs in? Thanks
  3. There's only one problem with that. It may sound strange but... If the $nickname variable is blank - I want it to return the $user variable from the url. That code will only return the username value in the database.
  4. I'm trying to get a nickname system working for a little project, but I've run into a problem. This code that I wrote here gets the users nickname from their username: $user = $_GET['user']; @mysql_select_db("db") or die( "Unable to select database"); $query = mysql_query("SELECT `nickname` FROM `info` WHERE `username`='$user'"); WHILE($rows = mysql_fetch_array($query)): $nickname = $rows['nickname']; echo $nickname; endwhile; ?> But the problem is, if the user doesn't have a nickname then it just turns up blank. How can I check if the output of $nickname is blank and if it is then just return their normal name ($user) Thanks Oh, and how to you format php code to look like php code on these forums?
  5. I've made a user online list for my server. I got the list working well - as seen here http://novacraftonline.com/connect.php But I wanted to add a player count as well - Here http://novacraftonline.com/count.php But it only displays the Count and not the player list Here is the code for the one without the player count: <?PHP // Conect to the Mysql Server $connect = mysql_connect("localhost","********","*********"); //connect to the database mysql_select_db("**********"); //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 1"); echo "Online: "; WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "<font color='black'><font color='green'>$users</font></font>, "; endwhile; ?> Here is the one with the player count <?PHP // Conect to the Mysql Server $connect = mysql_connect("localhost","*****","*****"); //connect to the database mysql_select_db("******"); //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 1"); //count $x = 0; WHILE($l = mysql_fetch_array($query)): $n = $l['name']; $x++; endwhile; echo "Online: "; WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "<font color='black'><font color='green'>$users</font></font>, "; endwhile; ?> I'm not sure why it only displays "Online($x)" Instead of "Online($x): $users" Thanks for your help
  6. echo "<img src="logo.gif" alt="Angry face" width="32" height="32" />"; This is giving an error like this Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/scswc188/public_html/admin.php on line 21 I think it is because of the "" in the html but I don't know how do fix it. Thanks
  7. I wanted to make it so both usernames were in one border but 'shadrxninga' was red
  8. At the moment with this code I have a border around each name but I wanted to get a border around all of the names and if the username is equal to shadrxninga make it red. // Conect to the Mysql Server $connect = mysql_connect("localhost","user","pass") or die(mysql_error()); //connect to the database mysql_select_db("db"); //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 1"); // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; if ( $users == shadrxninga ) { echo "<p><div style='width:200px;height:20px;border:2px outset red'><center>$users</center></div></p>"; } else { echo "<div style='width:200px;height:px;border:2px outset blue'><center>$users</center></div>"; } endwhile; ?> But I have no idea how? I have tried a few things but the have all ended in errors If you want to see what it looks like go to http://www.scswc.com Thanks
  9. Well I tried adding a border to my online users box... But there are some problems.. echo "<div style="width:200px;height:100px;border:2px outset blue>$users</div>"; the ; and " in the css stuff up the php - so I get errors like this Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/scswc188/public_html/index.php on line 23 Is there a way to do this? any tutorials? Thanks
  10. I have been getting that error and I cannot figure out why it is happening Here is the error: Parse error: syntax error, unexpected T_ENDWHILE, expecting ',' or ';' in /home/scswc188/public_html/index.php on line 23 Here is my Code (Database Credentials removed for obvious reasons) <?PHP // Conect to the Mysql Server $connect = mysql_connect("IP","USER","PASS"); //connect to the database mysql_select_db("TABLE"); //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 1"); // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "'<font color='black'>Online:<font color='green'>$users, </font></font>;" endwhile; ?> or here http://pastebin.com/ZYh4t2pD Thanks Edit: Found the php tag
  11. How would i exclude data from a query if it was = to something query = mysql_query("SELECT player, count(player) AS num FROM bbdata WHERE action='0' AND type IN (15, 14, 56) AND rbacked = '0' GROUP BY player ORDER BY num DESC ;"); What I want to do is exclude "shadrxninga"(Which is under player in the table)from the query so something like this query = mysql_query("SELECT player, count(player) AS num FROM bbdata WHERE action='0' AND type IN (15, 14, 56) AND rbacked = '0' EXCLUDE player = 'shadrxninga' GROUP BY player ORDER BY num DESC ;"); So how would I do that?
  12. Ok... I need some help - I want to show a players balance in a game beside there name (Balance is in mysql database)I can do that but... - I also want to show if there online or offline at the same time( This is stored in a different database) I have the code which says whether they are online or offline <?PHP // Conect to the Mysql Server $connect = mysql_connect("localhost","scswccla_bukkit","********"); //connect to the database mysql_select_db("scswccla_bukkit"); //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 1"); //title echo "<font size='100'>NovaCraft Users</font><br>"; // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "<font color='black'>|Online|<br><font color='green'>$users</font></font><br>"; endwhile; //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 0"); //title echo "<font color='black'>|Offline|</font><br>"; // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "<font color='red'>$users</font><br>"; endwhile; ?> Here is the page: www.scswc.com/Offline_Users.php displaying that But I want to Create something like this: Nocvacraft Players |Online| Name:Player Balance:$20 |Offline| Name:Player Balance:$15 Here is what I have tried: <?PHP // Conect to the Mysql Server $connect = mysql_connect("localhost","scswccla_bukkit","**********"); //connect to the database mysql_select_db("scswccla_bukkit"); //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 1"); $query2 =mysql_query("SELECT * FROM iBalances WHERE player = $users"); //title echo "<font size='100'>NovaCraft Users</font><br>"; // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query) $rows2 = mysql_fetch_array($query2)): $users = $rows['name']; $balance = $rows2['balance']; echo "<font color='black'>|Online|<br><font color='green'>Name:$usersBalance:$balance</font></font><br>"; endwhile; //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 0"); //title echo "<font color='black'>|Offline|</font><br>"; // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "<font color='red'>$users</font><br>"; endwhile; ?> I know I am trying to use a variable before it is been set - but if I don't how I have tried this as well... <?PHP // Conect to the Mysql Server $connect = mysql_connect("localhost","scswccla_bukkit","**********"); //connect to the database mysql_select_db("scswccla_bukkit"); //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 1"); //title echo "<font size='100'>NovaCraft Users</font><br>"; // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "<font color='black'>|Online|<br><font color='green'>Name:$users</font></font><br>"; endwhile; //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 0"); //title echo "<font color='black'>|Offline|</font><br>"; // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "<font color='red'>$users</font><br>"; endwhile; $query = mysql_query("SELECT * FROM iBalances WHERE player = $users"); WHILE($rows = mysql_fetch_array($query)): $balance = $rows['balance']; echo "<font color='red'>$users $balance</font><br>"; endwhile; // ?> Can you use variables in mysql_query()?Is that why it isn't working? This is my first php script so if I need to give you more information for you to help me just tell me Thanks Here is database pictures iBalances users_online
  13. So how would i fix that? - This is the first time I have Used php Do I need to Move mysql_real_escape_string() to after the database settings or move the database settings before mysql_real_escape_string() Or do I need to do something else? Thanks again.
  14. I have a problem where I am getting these errors after a form has been submitted from join.html Here are the errors: Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'scswccla'@'localhost' (using password: NO) in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'scswccla'@'localhost' (using password: NO) in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/scswccla/public_html/insert.php on line 9 Here is the insert.php file http://pastebin.com/EVtgidQC And the join.html file - http://pastebin.com/hqDtGLe5 How would I fix those errors - I got the code from http://forum.hey0.net/showthread.php?tid=2509 The form is at scswc.com/join.html if you want to look at it. I really want to get this working so if you need any more info to help fix it just ask thanks!
×
×
  • 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.