Jump to content
Larry Ullman's Book Forums

sandari

Members
  • Posts

    29
  • Joined

  • Last visited

Posts posted by sandari

  1. All fields are correct as are the data types.

    The code being sent is as follows:

    update tblClients

    SET

    GivenName1='Susanna',

    GivenName2='Anastasia',

    PreferredName='Susie',

    Surname='Barishnakov',

    DoB='1995-10-25',

    Gender='Female',

    PlaceOfBirth='',

    Address1='',

    Address2='',

    Suburb='8836',

    Phone='',

    Source='',

    ReferredBy='',

    email='',

    OptOut='0',

    WrongAddress='0',

    Campus='2',

    FirstContact='2012-10-25',

    Merde='0',

    Inactive='0',

    CRN='',

    AdmissionPack='0',

    AdmissionProcedure='0',

    AdmittedBy='',

    ResidencyContract='0',

    ContractSigned='0',

    ContractWitnessed='0,

    DateContractSigned='0000-00-00',

    KeyDepositReceived='0',

    KeyDepositRefunded='0',

    ReceiptDate='2012-10-25',

    RefundDate='0000-00-00',

    PreviousClient='0',

    PreviousCampus='2',

    PreviousAdmission='0000-00-00'

    where (ID='23');

     

    But still I get '> as a response.

  2. I have query in PHP as follows:

    <code>

                $query="update tblClients SET GivenName1='$GivenName1',
                                              GivenName2='$GivenName2',
                                              PreferredName='$PreferredName',
                                              Surname='$Surname',
                                              DoB='$DoB',
                                              Gender='$Gender',
                                              PlaceOfBirth='$PlaceOfBirth',
                                              Address1='$Address1',
                                              Address2='$Address2',
                                              Suburb='$Suburb_id',
                                              Phone='$Phone',
                                              Source='$Source',
                                              ReferredBy='$ReferredBy',
                                              email='$Email',
                                              OptOut='$OptOut',
                                              WrongAddress='$WrongAddress',
                                              Campus='$Campus',
                                              FirstContact='$FirstContact',
                                              Merde='$Merde',
                                              Inactive='$Inactive',
                                              CRN='$CRN',
                                              AdmissionPack='$AdmissionPack',
                                              AdmissionProcedure='$AdmissionProcedure',
                                              AdmittedBy='$AdmittedBy',
                                              ResidencyContract='$ResidencyContract',
                                              ContractSigned='$ContractSigned',
                                              ContractWitnessed='$ContractWitnessed,
                                              DateContractSigned='$DateContractSigned',
                                              KeyDepositReceived='$KeyDepositReceived',
                                              KeyDepositRefunded='$KeyDepositRefunded',
                                              ReceiptDate='$ReceiptDate',
                                              RefundDate='$RefundDate',
                                              PreviousClient='$PreviousClient',
                                              PreviousCampus='$PreviousCampus',
                                              PreviousAdmission='$PreviousAdmission'
                                       where (ID='$ClientID');";

    </code>

    The problem is that when I echo the query to the screen, copy it and paste it into the command line of MySQL it returns what looks like:

         '>

    Any suggestions?

  3. <code>

    CREATE TABLE IF NOT EXISTS `award` (
      `award_id` int(11) NOT NULL AUTO_INCREMENT,
      `show_year` varchar(6) NOT NULL,
      `category_id` varchar(10) DEFAULT NULL,
      `category` varchar(100) DEFAULT NULL,
      `FirstPrize` varchar(40) DEFAULT NULL,
      `SecondPrize` varchar(40) DEFAULT NULL,
      `ThirdPrize` varchar(40) DEFAULT NULL,
      `FourthPrize` varchar(40) DEFAULT NULL,
      `HighlyCommended` varchar(40) DEFAULT NULL,
      PRIMARY KEY (`award_id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=29 ;
    </code>

     

    When I run the above command I get the response:

     

    "#1050 - Table '`mwwg`.`award`' already exists"

     

    If I then run "show tables;" the table "award" does not show up.

     

    Any clues??

  4. I give up!!

     

    What is wrong with this code?

     

                while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){
                    echo "<tr class=\"data\" align=\"center\" width=\"100%\">
                        <form action=\"edit_other_medical_problem.php\" method=\"POST\">
                            <td align=\"center\">{$row['AssessmentDate']}</td>
                              <td align=\"center\">{$row['MedicalProblem']}</td>
                              <td align=\"center\">{$row['TreatmentPlan']}</td>
                              <td align=\"center\">{$row['OtherDetails']}</td>
                            <td align=\"center\">
                                <input type=\"submit\" name=\"submit\" value=\"Edit\">
                                  <input type=\"hidden\" name=\"MedicalProblemID\" value=\"{$row['ID']}\">   
                            </td>
                        </form>";
                        echo "<form action=\"delete_other_medical_problem.php\" method=\"POST\">
                                <td align=\"center\">
                                          <input type=\"submit\" name=\"submit\" value=\"Delete\">
                                          <input type=\"hidden\" name=\"MedicalProblemID\" value=\"{$row['ID']}\">
                                </td>
                              </form>";  
                        echo "</tr>";
                }
     
    

     

    The "Delete" button works beautifully but the "Edit" button remains on this page instead of opening "edit_other_medical_problem.php".

     

    I cannot see the difference.

  5. Table structure is:

    ID int(11) Auto Primary Key Not NULL

    DetoxUnit varchar(255)

    Address1 varchar(255)

    Address2 varchar(255)

    Suburb int(11)

    Phone varchar(255)

    Fax varchar(255)

    Contact varchar(255)

     

    Command is:

    insert into tblDetoxUnits (DetoxUnit, Address1, Address2, Suburb, Phone, Fax, Contact) values('Dr Gumley\'s Sanitorium', '21 Acidic way', '', '13', '3210 9999', '3210 8888,' 'Michelle');

     

    The error message is:

    Column count doesn't match value count at row 1 in
    C:\...\add_detox_unit.php
    on line
    87

     

    As far as I can see I am trying to insert 7 values into their 7 coresponding columns.

     

    What am I missing?

  6. My table structure is:

    ID int(11)

    ClientID int(11)

    ProgramType int(11)

    When varchar(255)

    Where varchar(255)

    HowLong varchar(255)

     

    The command is:

    insert into tblRehabilitationHistory (ClientID, ProgramType, When, Where, HowLong) values ('2', '1', '2009', 'Brisbane', '6 weeks');

     

    The error message is:

    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 'When, Where, HowLong) values ('2', '1', '2009', 'Brisbane', '6 weeks')' at line 1

     

    I am at a loss to see where I have gone wrong.

     

    Any and all help will be appreciated.

  7. OK, maybe I didn't get exactly what you and Larry were saying. However, the previous was resolved quite easily as indicated in my last post in that thread.

    I have pulled the date from the DB in a single query at the start of this script and exploded the date into $DayCommenced, $MonthCommenced & $YearCommenced.

    The values are all correct right up until the lines quoted above.

    I think my problem is that I do not fully understand how to evaluate the individual keys in the $day array to be able to compare them to $DayCommenced, if, in fact, $day is an array.

    Please explain in detail.

     

    Sorry to be so thick on this one.

  8. I must be dumb.

    Similar code worked previously when making another drop-down list, however it does not work in the format below.

     

    Any help will be appreciated.

     

    <?php
    $DayCommenced= 16;
    $day=range(01,31);
    
    echo"<label>Commenced</label><br />";
    echo"<select name=\"DayCommenced\">";
    foreach($day as $value){
    if($day==$DayCommenced){
    $selected = "selected";
    }else{
    $selected = "";
    }
    echo"<option value=\"$value\" $selected>$value</option>";
    }
    echo "</select>";
    ?>
    

  9. The problem turned out to be that the line:

    echo"<option value=\"{$row['suburb_id']}\" selected=$selected>{$row['suburb']}  {$row['state']} {$row['postcode']}</option>";
    
    

     

    Should have read:

    echo"<option value=\"{$row['suburb_id']}\" $selected>{$row['suburb']}  {$row['state']} {$row['postcode']}</option>";
    
    

    i.e. without the "selected="

     

    Thanks for your help. All is now good.

    • Upvote 1
  10. OK, I've taken oput the foreach loop so the code now looks like this:

    <?php
                            	 echo"<label>Suburb</label><br />";
                               echo"<select name=\"Suburb\">";
                                   $query="select suburb_id, suburb, state, postcode
                                           from tblPostcodes
                                           order by suburb,state, postcode asc;";
                                   $result=@mysqli_query($dbc,$query);
                                   while($row=mysqli_fetch_array($result,MYSQLI_ASSOC)){
                                       if($row['suburb_id']==$suburb_id){
                                           $selected="selected";                                            
                                       }else{
                                           $selected="";
                                       }
                                       echo"<option value=\"{$row['suburb_id']}\" selected=$selected>
                                                    {$row['suburb']}  {$row['state']} {$row['postcode']}</option>";
                                   }
                                   echo"</select>";
    ?>
    

     

    But it still goes straight to the last suburb in the list.

     

    Any help will be appreciated.

×
×
  • Create New...