Jump to content

MadDawgX

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Everything posted by MadDawgX

  1. Hey there. I need a way of determining whether or not the current date is BEFORE, AFTER, or ON the date that is represented by: $TaskDue = date("F j, Y",strtotime(mysql_result($rTask,0,'due'))); How would I do this? - Thanx.
  2. Hey there. I'm stuck on how to get my page to redirect after posting a form. I'm using an include system for my layout and in one of the includes that goes into the body I have the following: [code]<?php // NEW REPLY // Connect to Database ******** // Get Current Forum/User $current_topic = $_GET['t']; $current_user = $_SESSION['username']; // Add New REply if(isset($_POST['post'])) { $pos_post = $_POST['post']; if ($pos_post != '') { $q_newpost = "INSERT INTO bd_posts (topic,user,content) VALUES('$current_topic','$current_user','$pos_post')"; $r_newpost = mysql_query($q_newpost) or die('Error, query failed'); header("Location:index.php?id=1&page=2&showtopic=$current_topic"); } } ?> HTML STUFF[/code] I'm getting the common [b]Warning: Cannot modify header information - headers already sent[/b] error. Help appreciated.
  3. Hey there. I've got a comment type of system made where users can submit a form and its added to a database, but it always comes out as one big paragraph. [b]Eg:[/b] This thing is Great. Awesome work! - So-and-So [b]Would come out as:[/b] This thing is Great. Awesome work! - So-and-So What do I need to do so it'll be in its paragraphs?
  4. I've got another problem, felt I could just post it here. I'm getting a MySQL error: [code]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'by) VALUES('a', '0cc175b9c0f1b6a831c399e269772661', 'a', '', 'Undisclosed', '', ' at line 1[/code] With this code: [code] $query = "INSERT INTO user (name, pass, email, loc, gender, home, bd, bm, by) VALUES('$username', '$password', '$email', '$location', '$gender', '$homepage', '$bd', '$bm', '$by' )"; mysql_query($query) or die(mysql_error());[/code]
  5. Wow. All that and it was a simple }. Thanx for your help.
  6. [quote author=hackerkts link=topic=103356.msg411495#msg411495 date=1155005271] Your elseif is wrong, its in a mess.. Also, [b]=[/b] and [b]==[/b] is totally different. [code]if($username==NULL||$password==NULL||$password2==NULL||$email==NULL||$email2==NULL) {[/code] [/quote] Yeah I changed that line with the == and || and still got the same error. As for the else/elseif I'll try that now. EDIT: Still no luck. This is what I have now, anything missing? [code]<?php $error = ""; $registered = 0; /* make database connection */ $db = mysql_connect ('*********','********','********'); mysql_select_db ('********',$db); if (isset($_POST["username"])) { // Get Values $username = $_POST["username"]; $password = $_POST["password"]; $password2 = $_POST["password2"]; $email = $_POST["email"]; $email2 = $_POST["email2"]; $location = $_POST["location"]; $bd = $_POST["bd"]; $bm = $_POST["bm"]; $by = $_POST["by"]; $gender = $_POST["gender"]; $homepage = $_POST["homepage"]; // Make sure fields are filled out if($username==NULL||$password==NULL||$password2==NULL||$email==NULL||$email2==NULL) { $error = 'A required field was left blank.'; // Passwords Match } elseif($password!=$password2) { $error = "Passwords don't Match."; // Emails Match } elseif ($email!=$email2) { $error = "Email's don't Match."; // Emails Match } else { $checkuser = mysql_query("SELECT name FROM user WHERE name='$username'"); $user_exists = mysql_num_rows($checkuser); if($user_exists>0) { $error = "Username already in use."; } else { $checkemail = mysql_query("SELECT email FROM user WHERE email='$email'"); $email_exists = mysql_num_rows($checkemail); if ($email_exists>0) { $error = "A user is already registered with that email."; } else { $password = md5($password); $query = "INSERT INTO user (name, pass, email, loc, gender, home, bd, bm, by) VALUES('$username','$password','$email'," .   "'$location', '$gender', '$homepage', '$bd', '$bm', '$by' )"; mysql_query($query) or die(mysql_error()); $registered = 1; } } } ?>[/code]
  7. Would that really make a difference though?
  8. Don't know why it pasted like that, but in the actual thing it's like this: [code]$query = "INSERT INTO user (name, pass, email, loc, gender, home, bd, bm, by) VALUES('$username','$password','$email'," .    "'$location', '$gender', '$homepage', '$bd', '$bm', '$by' )";[/code] I also changed | to ||, but no luck.
  9. Hey, I've got a problem with my code that I can't figure out. The following code is at the top of my php page before the <html> line. [code]<?php $error = ''; /* make database connection */ $db = mysql_connect ('*********','********','********'); mysql_select_db ('********',$db); if (isset($_POST["username"])) { // Get Values $username = $_POST["username"]; $password = $_POST["password"]; $password2 = $_POST["password2"]; $email = $_POST["email"]; $email2 = $_POST["email2"]; $location = $_POST["location"]; $bd = $_POST["bd"]; $bm = $_POST["bm"]; $by = $_POST["by"]; $gender = $_POST["gender"]; $homepage = $_POST["homepage"]; // Make sure fields are filled out if($username=NULL|$password=NULL|$password2=NULL|$email=NULL|$email2=NULL) { $error = 'A required field was left blank.'; } else { // Passwords Match if($password!=$password2) { $error = "Passwords don't Match."; } else { // Emails Match if ($email!=$email2) { $error = "Email's don't Match."; } else { // Has Username Been Used $checkuser = mysql_query("SELECT name FROM user WHERE name='$username'"); $user_exists = mysql_num_rows($checkuser); if($user_exists>0) { $error = "Username already in use."; } else { $checkemail = mysql_query("SELECT email FROM user WHERE email='$email'"); $email_exists = mysql_num_rows($checkemail); if ($email_exists>0) { $error = "A user is already registered with that email."; } else { $password = md5($password); $query = "INSERT INTO user (name, pass, email, loc, gender, home, bd, bm, by) VALUES('$username','$password','$email'," .    "'$location', '$gender', '$homepage', '$bd', '$bm', '$by' )"; mysql_query($query) or die(mysql_error()); $registered = 1; } } } ?>[/code] The error I get is "Parse error: parse error, unexpected $ in ****** on line 451" Line 451 is the </html> (end of document) - Thanx
  10. Hey there, Im getting the date from a MySQL database like follow: [code]DATE_FORMAT(date, '%Y-%m-%d %r') as comdate[/code] That returns the time in the MySQL datase which is the Greenwhich time. Later on down the line I display this time. My question is, Is it possible to display the time so that it is the same as the user's timezone. So for example EST would -5 from the hour. - Thanx
  11. Well, Im kinda new to PHP and MySQL in general, though I do have experience in other languages. Just wondering why the following code won't work. [code]    $query = "SELECT pass FROM User WHERE user='$user'";     $res = mysql_query($query) or die("Error Executing Query: ".mysql_error());     if ($res == $pass) {         $ans = "1";     }     else     {     $ans = "2";     }    [/code] $user and $pass are both test. And the values in the MySQL database User are (user=test and pass=test) EDIT: Oh and $ans is returning 2 when it should be 1. - Thanx
  12. Okay thanx, I got it to work.
  13. Hey there. Im fairly new to PHP and would like some help. Im trying to check for a variable in the address bar. eg. [code]http://www.twisterentertainment.org/news.php?page=1[/code] What im trying to do is make an if statement that checks if page = 1 then do a series of html code. I've tried but it doesn't work, here it is. [code]<?php if ($_GET['page'] = 1) { ?> // HTML CODE <?php } ?>[/code]
×
×
  • 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.