Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. Sorry about that, I was incorrect about what he wanted when I wrote that, I edited my post.
  2. Just do this: $check_sql = "SELECT `username` FROM `members` WHERE username='$username'"; $check_query = mysql_query($check_sql); echo (mysql_num_rows($check_query)==0) ? 'yes' : 'no';
  3. I tested my example, and it worked for the limited examples I fed into it. But I'm a Regex amateur.
  4. Oh, that's because you're using mysql_fetch_object, and not like mysql_fetch_assoc, or mysql_fetch_array.. Still if $row->music isn't working then there's something wrong with your query.
  5. You still have to have it like.. <TEXTAREA name="music", ROWS="5", COLS="45", wrap=virtual>' . $row['music'] . '</TEXTAREA>
  6. im sorry to sound ignorant but im not sure what you mean mate Don't you want the stuff inside the text area to be taken from the database? If your query is right, and there's a row in the table called 'music' replace $music with $row['music'] inside of your textarea.
  7. $music the a $_GET variable, I thought you wanted it to get it from your query? Change it from $music to $row['music']
  8. That's fine as long as $music has the value you want..
  9. Would that be the exact string? More specifically: Would it contain anything after it? How about before?
  10. Are they for the same thing? If so just use $_REQUEST which is like a hybrid of the two.
  11. $text = preg_replace('/<img(.*)>/' , "<img $1 />", $text);
  12. Just loop through the directory and display all the files with a link. $path = 'some path here'; $dir = dir($path); while($file = $dir->read()) { echo $file . ' - <a href="' . $path . $file . '">' . $file . '</a>'; }
  13. Efficiency, the second example is easier, so I'd go with that one.
  14. $msg = str_replace("%fname%", $fname, $msg); $msg = str_replace("%lname%", $lname, $msg); $msg = str_replace("%pname%", $poker_name, $msg);
  15. Use: mysql_query('UPDATE players SET leader="yes" WHERE username="' . $_POST['username'] . '"'); Also, remember if your database isn't setup like this.. then it won't work. That query is made assuming that there's a colunm called 'leader' and when set to 'yes' it signifies that he/she is a leader.
  16. Are updates so infrequent to the database that every time they're made it won't be annoying to rerun the file that will be creating the html file? If not.. $fp = fopen("somefile.html","w"); if(!$fp) { echo 'File could not be opened.'; exit; } fwrite("Stuff that's being written to the file"); fclose($fp); That's a basic example on how to write to a file.
  17. Whoops, I also just noticed: It should be: $msg = "FROM: $name \n \n"; $msg .= "ISSUE, COMMENT OR CONCERN: $other \n \n"; If you're including the variable in the string you should use double quotes.
  18. if(isset($_POST['change_leader'])) { $result = mysql_query("SELECT gang_id FROM players WHERE username=" . mysql_real_escape_string($_POST['username']) . "' LIMIT 1"); $row = mysql_fetch_assoc($result); if($row['gang_id'] == $_POST['gang_id']) // Make sure he's a member of that gang { mysql_query('UPDATE players SET leader="yes" WHERE username="{$_POST['username']}"'); } } You should add a hidden field to your form which has the value of the gang id. So that you can confirm that the person they're choosing is actually a member of that gang (in case someone trys to hack it) I'm not exactly sure how your tables are setup, so it might be a little different.
  19. Well first off: $msg = 'FROM: $name \n \n'; $msg = 'ISSUE, COMMENT OR CONCERN: $other \n \n'; You basically removed the FROM:, Change it to: $msg = 'FROM: $name \n \n'; $msg .= 'ISSUE, COMMENT OR CONCERN: $other \n \n';
  20. Are you sure you want to write it to a file? If you write it to a file then it will only be up-to-date every time you run that file again. Instead you can just run the query and echo out the results every time the page is run. That way everything that displays is always up-to-date. If you still want to write it to a file, you can look into fopen() and fwrite()
  21. Whoops, I misnamed a variable on my last example. Still there was no problems.. <?php $other = 'something'; $thread_PostID = 550; $name_char = 'Alex'; $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: $other \n \n"; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: $thread_PostID \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; echo $msg; ISSUE, COMMENT OR CONCERN: something THREAD/POST: 550 CHARACTER(S): Alex
  22. That shouldn't cause a problem. I even tested it, it worked fine: $other = 'something'; $thread_postID = 550; $name_char = 'Alex'; $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: $other \n \n"; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: $thread_PostID \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; Output: ISSUE, COMMENT OR CONCERN: something CHARACTER(S): Alex I even tested for a syntax error when they're all null, no errors then either.
  23. That shouldn't be causing your errors. I didn't see anything that should. It's just that if you have a variable within single quotes, it won't output the variables value. It'll evaluate it like a string. $variable = 'Some value'; echo "This variable has the value of $variable"; //Some value echo 'This variable has the value of $variable'; //$variable
×
×
  • 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.