Jump to content

eurob

Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.dotwebsolutions.com

Profile Information

  • Gender
    Not Telling
  • Location
    Ohio

eurob's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I tried all the solutions but without success. There is just no way of passing a real NULL value to mysql. If there is please give me a working example as I would be very interested in that. What I do now is construct the sql statement with fields that do have a value such as this: if(!empty($mydate))$sql.",startdate='$startdate"; That way the fields that are empty will be omitted. Also you cannot in mysql do something like this: insert into mytable(startdate) values(''); because the startdate is a datetime field you have to either omit it or do it like this insert into mytable(startdate) values(null);
  2. I can omit it indeed just like the value for id but then I have to make separate sql statements when NULL values are involved, which is really annoying. '' does not equate to NULL in mysql, when I use it, mysql throws an error.
  3. mytable in mysql create table mytable ( id int, topic, startdate datetime default NULL) ) A user can submit a form without filling out a value for the startdate. I am using a function to pull out a NULL, the NULL value in PHP, however, shows nothing, so I cannot use it directly in mysql function testfornull($tst){ if($tst=='')return NULL; return $tst; } -- > function returns ''" in case of a NULL In the case of a NULL value, my sql statement should look like this insert into mytable(id,topic,startdate) values('some topic',NULL) How should I go about with this?( I cannot put NULL between quotes, it will error in mysql)
  4. I notice I have to write different sql statements because when I would do this: if (empty($date))$date=NULL; and then do this: insert into mytable(id,date) values($id,$date) it will still errors with 'incorrect datetime value of ". So then I have to do it like this if (empty($date))insert into mytable(id,date) values($id,NULL) Is there a handier way to do this?
  5. I have a table in mySql with a NULL datetime field. In my form the date field can be empty so I want to do an insert as this: insert into mytable(id,date) values($id,$date) However, when I leave the $date empty (on the form) php complains that $date has an invalid value. In mySql however, I can do insert into mytable(id,date) values(1,NULL) How can I make PHP recognize my $date field as a NULL value? Thanks
  6. part of my html <form action="process.php" method="post"> Check box field: <input name="showit[]" type="checkbox" value="whatever"> <input type="submit"> //process.php <?php $showit = $_POST['showit'] ?> If I don't check the check box I get the error 'undefined index'. How can I still capture the check box value, regardless if I checked it or not? Thanks, robert
  7. Thank you so much for the explanation, I worked it out.
  8. [code] $date = '07012006'; $sql = "SELECT subject FROM cal where date='$date'"; $result=mysql_query($sql); $row = mysql_fetch_array($result); echo sizeof($row);              -------------> shows 2 rows echo $row[0]; echo $row[1];    -------> error:'Undefined offset: 1'  why ? [/code] When I execute this sql in mysql I get two records back. When I put in my php page echo $row[1] i get an error msg 'undefined offset'. Don't understand this because the array contains 2 rows. Anyone has an idea ?
×
×
  • 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.