Jump to content

Eggzorcist

Members
  • Posts

    214
  • Joined

  • Last visited

    Never

Posts posted by Eggzorcist

  1. So this is the current updated code. I'm not getting any sql error, but it hops to else statement when it really should pass the if statement...

     

    any ideas?

     

    $eid = $_GET['ID'];
    $euser = $_SESSION['USER'];
    
    $query = mysql_query("SELECT * FROM events WHERE id = '$eid' and user = '$euser'") or die(mysql_error());
    
    
    if (mysql_num_rows($query) == 1){
    
    $editinfo = mysql_fetch_assoc($query);
    
    }
    
    else {
    
    echo "You cannot edit that particular event, you may only edit events you've created.";
    }

     

    thanks,

  2. It seems like my sql command isn't correct as it's not obtaining the correct information. As it always outputs the else command when it should show the if statement.

    $_GET['ID'] = $eid;
    $_SESSION['USER'] = $euser;
    
    $query = mysql_query("SELECT * FROM events WHERE id = '{$eid}' and user = '{$euser}'");
    
    
    if (mysql_num_rows($query) >= 1){
    
    $editinfo = mysql_fetch_assoc($query);
    
    }
    
    else {
    
    echo "You cannot edit that particular event, you may only edit events you've created.";
    }
    

     

     

    Any idea of syntax or problematic things in this code?

     

    Any help will be greatly appreciated.

     

  3. I'm trying to create a query where it matches both the username and the date - so that if the date is 5 days away or shorter it doesn't show, but if it's 6 days or more away it will show it those queries.

     

    My sql field uses the date datatype and a example of that field is: "2009-08-12"

     

    Here's my function and query...

    $filtertime = date("Y-m-d",mktime(0, 0, 0, date("m") , date("d")+5, date("Y")));
    
    $query = "SELECT * FROM events WHERE user = '".$user."' and fromslashes > '.$filtertime.'"

     

    The problem is that it shows all where the user = $user and disregards the fromslahes > than $filtertime...

     

    Any ideas?

  4. I am currently using the dates datatype for that field.

     

    I don't really understand this query, why are we addslahes between? and I don't see how we are comparing the field "fromslahes" to the current date + 5.

     

    shoudn't it be some like:

     

     

    fromslahes > ".date("Y-m-d H:i:s", strtotime("+ 5 days"))."' or something alike?

     

    I'm a bit confused...

  5. I've always had extreme trouble comparing dates or times. For the application I'm currently building I need to be able to make a sql query which will compare the date and time.

     

    So with this query

    "SELECT * FROM events WHERE user = '".$_SESSION['USER']."'";

     

    I want to add a AND statement which will check the sql field "fromslashes" (which for eg. is set like "08/03/2009" format) and will make sure that that date is 5 days later than the current date that it is now.  So it only displays if that day is 5 days later than todays date or earlier.

     

    How would I be going about to form this statement?

     

    Thanks!

  6. I'm not sure what's causing this, but I'm getting this error:

     

    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 'JPFoster','Club name ID' ,Tester', '08/06/2009', 'Thursday, 6 August, 2009', '22' at line 3

     

    Here's my query

     

    "INSERT INTO events

    (user, clubname, name, fromslashes, fromdisplay, fromtime, toslashes, todisplay, totime, quickdescription, pagedescription, status) VALUES

    (''".$_GET['USER']."','".$_GET['clubname']."' ,".$data['eventTitle']."', '".$data['from1']."', '".$data['from2']."', '".$data['fromtime']."', '".$data['to1']."', '".$data['to2']."', '".$data['totime']."', '".$data['quickDesc']."', '".$data['description']."', '".$status."')"

  7. I'm trying to make an application which would need the user to stay logged in for a long period of time. As there are a long fields to fill out and I'm wondering wether $_SESSIONS is what I should be using or should I be using $_COOKIES or something that I'm not aware of... I just don't want a user to type a long piece of data and try to submit it but their sessions timed-out any solutions?

     

    Thanks

     

  8. mysql_query("INSERT INTO events 
    				(name, fromslashes, fromdisplay, fromtime, toslashes, todisplay, totime, quickdescription, pagedescription, sameday, status) VALUES 
    				('".$data['eventTitle']."', '".$data['from1']."', '".$data['from2']."', '".$data['fromtime']."', '".$data['to1']."', '".$data['to2']."', '".$data['totime']."', '".$data['quickDesc']."', '".$data['description'].", '".$sameday."', '".$status."')")

  9. Oh I forgot to post it the entire area. the function calling is done by:

     

     if($_POST){
    
    $inputFieldNamesToDb = array('eventTitle' => 'title', 'from1' => 'datepicker1', 'from2'	=> 'alternative1', 'fromtime' => 'timestart', 'to1'	=> 'datepicker1', 'to2'	=> 'alternative2', 'totime'	=> 'timefinish', 'quickDesc' => 'Qdescription', 'description'	=> 'elm1');
    foreach($inputFieldNamesToDb as $dbField => $postField) {
    $data[$dbField] = $_POST[$postField];
    }
    
    
    addeventToPending($_POST['title'], $_POST['datepicker1'], $_POST['alternative1'], $_POST['timestart'], $_POST['datepicker1'], $_POST['alternative2'], $_POST['timefinish'], $_POST['Qdescription'], $_POST['elm1']);
    
    } 

  10. function

     

    function addeventToPending($data){
    
    foreach($data as $key => $value) {
    	$data[$key] = mysql_real_escape_string($value);
    }
    if(!mysql_query("INSERT INTO events 
    				(name, fromslashes, fromdisplay, fromtime, toslashes, todisplay, totime, quickdescription, pagedescription, sameday, status) VALUES 
    				('".$data['eventTitle']."', '".$data['from1']."', '".$data['from2']."', '".$data['fromtime']."', '".$data['to1']."', '".$data['to2']."', '".$data['totime']."', '".$data['quickDesc']."', '".$data['description']."')")) {
    	die(mysql_error());
    }
    echo "Your event was put up for approval.";
    
    }

     

    Form Area:

    if($_POST){
    
    $inputFieldNamesToDb = array('eventTitle' => 'title', 'from1' => 'datepicker1', 'from2'	=> 'alternative1', 'fromtime' => 'timestart', 'to1'	=> 'datepicker1', 'to2'	=> 'alternative2', 'totime'	=> 'timefinish', 'quickDesc' => 'Qdescription', 'description'	=> 'elm1');
    foreach($inputFieldNamesToDb as $dbField => $postField) {
    $data[$dbField] = $_POST[$postField];
    }

×
×
  • 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.