Mysql Recordset help

Can anyone help me sort this out.
This code should spit out only the records that match a URK parameter $courscode but whatever I do it returns every record. I just can't figure out why?
$query_rs_dates = sprintf("SELECT * FROM dates09 UNION SELECT * FROM dates10 WHERE coursecode = '$coursecode' ORDER BY id", GetSQLValueString($colname_rs_dates, "text"));
$rs_dates = mysql_query($query_rs_dates, $con_tyf) or die(mysql_error());
$row_rs_dates = mysql_fetch_assoc($rs_dates);
$totalRows_rs_dates = mysql_num_rows($rs_dates);
Can anyone tell me where I am going wrong.
Cheers
Dave

Don't worry, I have fixed it.
Seems you have to have the WHERE bit first for each table. Like this:
SELECT * FROM dates09 WHERE coursecode = '$coursecode') UNION (SELECT * FROM dates10 WHERE coursecode = '$coursecode')
Sorry if I put anyone to any trouble. But maybe this will help someone with the same problem in the future
Cheers
Dave

Similar Messages

  • MX / PHP / MySQL results_page help

    Desperately seeking help. I am using dreamweaver, php and
    MySql. I am building my first dynamic web page (so be easy on me, I
    am green:) and I am having troubles with a results page. I got the
    simple SearchString working just fine – but I can't get an
    advanced search page to work.
    On the search page, I have several list boxes (for simplicity
    I will only refer to two of these list boxes). The list boxes are
    in a form named form2. The list boxes allow a user to select one or
    many. Rather than listing the menu structure, I have this set up
    dynamically (pulls the info from the database).
    In the returned_results page, I have a recordset with the SQL
    e.g.: (keep in mind that form2 doesn't appear in the query anywhere
    – this might be the problem?)
    SELECT blah blah
    FROM blah blah
    WHERE RESTAURANTPRICE_ID like 'value1' AND CUISINE_ID like
    'value2'
    ORDER BY REST_NAME ASC
    Variables:
    Name; default value; runtime value
    value1 % $_GET['PRICE_Price']
    value2 % $_GET['CUISINE_Name']
    Now if I test this from the search page, the returned_results
    returns ALL columns of data, regardless of what I selected from the
    list boxes. Tested it again by changing the default variable value1
    and value2 to 1 and it will return ALL columns that meet this
    criteria, but again, this is regardless of what I selected from the
    list box.
    Somehow my returned_results query works fine on its own, but
    its not making the connection from the search page where a user
    would select their criteria.
    I can upload code if needed. What the heck am I doing wrong?

    $query_Recordset1 = sprintf("SELECT * FROM images2 WHERE key_words LIKE '%$keyword%' ORDER BY id DESC", GetSQLValueString($colname_Recordset1, "text")); 
    Why are you using the $keyword variable rather than the sprintf parameter? I don't know php, but it seems like that is your problem. Maybe try something like this:
    $query_Recordset1 = sprintf("SELECT * FROM images2 WHERE key_words LIKE %s ORDER BY id DESC", GetSQLValueString("%" . $colname_Recordset1 . "%",  "text"));

  • Complex mySQL recordset

    Hoping one of you mySQL gurus can help me with a bit of a pickle.
    I have two tables:
    1: Dogs
    2: Litters
    What I need to do is pull the male and female dog from the list of dogs.
    Example in brief form:
    Table One (Litters)
    litters_id
    litters_male
    litters_female
    Table two (Dogs)
    parent_id
    parent_name
    parent_picture
    parent_notes
    etc ....
    My input form would have two drop down fields listing the dogs ..
    Male: (Dropdown Menu 1)
    Famale (Dropdown Menu 2)
    Each of these drops successfully put the parent_id value into the litters_male and litters_female respectively.
    What I need to do is to display on a page from the litters recordest the dog names and other info related to each dog within the same recordset.
    So I need to write a JOIN to join both the litters_male and litters_female to the parent_id field.
    Is this possible?
    Thanks in advance
    Brad

    Maybe if you see the actuall data structure ... ?
    CREATE TABLE `litters` (
      `litter_id` tinyint(3) NOT NULL auto_increment,
      `litter_breed` tinyint(2) default NULL,
      `litter_male` tinyint(3) default NULL,
      `litter_female` tinyint(3) default NULL,
      `litter_bred` varchar(32) collate latin1_german2_ci default NULL,
      `litter_due` varchar(32) collate latin1_german2_ci default NULL,
      `litter_notes` varchar(255) collate latin1_german2_ci default NULL,
      PRIMARY KEY  (`litter_id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci AUTO_INCREMENT=5 ;
    -- Dumping data for table `litters`
    INSERT INTO `litters` VALUES (1, 1, 11, 9, 'December 4, 2009', 'February 5, 2010', '');
    INSERT INTO `litters` VALUES (2, 1, 12, 7, 'January 2010', 'March 2010', '');
    INSERT INTO `litters` VALUES (3, 1, 12, 5, 'January 2010', 'March 2010', '');
    INSERT INTO `litters` VALUES (4, 2, 1, 2, 'January 2010', 'March 2010', '');
    -- Table structure for table `parents`
    CREATE TABLE `parents` (
      `parents_id` tinyint(3) NOT NULL auto_increment,
      `parents_name` varchar(32) collate latin1_german2_ci default NULL,
      `parents_sex` varchar(10) collate latin1_german2_ci default NULL,
      `parents_breed` tinyint(2) default NULL,
      `parents_notes` text collate latin1_german2_ci,
      `parents_picture` varchar(64) collate latin1_german2_ci default NULL,
      `parents_thumb` varchar(64) collate latin1_german2_ci default NULL,
      PRIMARY KEY  (`parents_id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=19 DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci COMMENT='parent profiles' AUTO_INCREMENT=19 ;
    -- Dumping data for table `parents`
    INSERT INTO `parents` VALUES (1, 'Kremlin', 'Male', 2, '<p><span class="bodytext"><p>Where do I start...Kremlin has got to be one of the most georgeous Dogue De Bordeaux''s you will ever lay eyes on!&#160; He has the pedigree to match as well!!&#160; Kremlin is 2 years old, was born at Riverbend Bordeaux Kennel in Kettle Falls Washington.&#160; Thanks you so much Jody for allowing us to make him part of our family as well as&#160;the&#160;foundation&#160;of our breeding program.&#160; We are extremely lucky!!&#160;</p> <p>Kremlin''s father was the famous Champion Riverbend''s Beefsteak.&#160; He weighed 166 pounds of solid male Dogue De Bordeaux!&#160; He is also world famous for his offspring producing many champions.&#160;&#160;Beefsteak''s&#160;father&#160;was&#160;Champion&#160;Beefy&#160;T.&#160;Bad&#160;Boy.&#160; Kremlin''s mother is Ella Van De Paterhoek who came straight from the world famous Van De Paterhoek Kennel in Belgium!&#160; She was out of their most famous breeding pair International Champion Emberez Apollo and Bintje De Paterhoek.&#160; His mother is also full sister to Champion Dillen Van De Paterhoek,&#160;Champion Effje&#160;Van&#160;De&#160;Paterhoek&#160;and the famous Champion Enferno Van De Paterhoek!!</p></span></p>', 'kremlin.jpg', NULL);
    INSERT INTO `parents` VALUES (2, 'Sako', 'Female', 2, '<p><span class="bodytext">Sako is a Dogue De Bordeaux a.k.a French Mastiff.&#160; She was born in Washington on December 8, 2008.&#160; She has a very impressive background!! <br></span></p>', 'sako.jpg', NULL);
    INSERT INTO `parents` VALUES (3, 'Anna Belle', 'Female', 1, '<p>"The Paw Palace Anna Supreme"<br><br>&#160;Anna is a beautiful and outstanding black and tan merle female! She was born in Louisiana on September 7, 2007. She weighs 4 lbs. Anna is a loving, playful and beautiful little girl with a very soft and vivid colored coat! <br><br>Anna is AKC and CKC registered!!</p>', 'annabelle.jpg', NULL);
    INSERT INTO `parents` VALUES (4, 'Daisy', 'Female', 1, '<p>"Oneway Back From Iraq"<br><br>&#160;Daisy is white with cream colored markings. She was born in Wisconsin on July 27, 2006 . Daisy has the coby style body and weighs approx. 6 lbs. She is small but stocky! She also has a perfect little apple head and very loving personality! Daisy likes to mother and has taken on the responsibility of mothering all my other chi''s! <br><br>&#160;Daisy is Akc and CKC registered.<br><br>ONEWAY BACK FROM IRAQ Champions include<br><br>(4 generation): CH MT View''s Lil'' General</p>', 'daisy.jpg', NULL);
    INSERT INTO `parents` VALUES (5, 'Journey', 'Female', 1, '<p><span class="bodytext"><p style="text-align: left;">"Journey Reins Supreme"</p> <p style="text-align: left;">This little sweetie comes to us from Missouri, She is AKC and CKC Registered.&#160; Her Father is AKC Champion Rebound Black Russian.&#160; He has 47 Champions out of 62 in his 5 generation pedigree!!!&#160; Amazing!!&#160; Her Mother is Davishall Lamars Wild Rose and almost every dog in her pedigree is Davishall bred so she is mostly stong Davishall foundation bloodlines.&#160; She should be show quality and should turn out to be a dream!!! ...</p></span></p>', 'journey.jpg', NULL);
    INSERT INTO `parents` VALUES (7, 'Oakie', 'Female', 1, '<p><span class="bodytext"><p style="text-align: left;"><em>"Felina''s Oakie Supreme"</em></p> <p style="text-align: left;">Oakie is a blue and tan female. Her Birthday is January 16, 2007 and she was born in Oklahoma. She is approx 8 lbs, she looks irredescant in the sun! She is a short coat and has the cutest little deerhead. She is so laid back and easy going, loves letting the pups chew on her!</p> <p style="text-align: left;">She is AKC and CKC registered.&#160;</p></span></p>', 'oakie.jpg', NULL);
    INSERT INTO `parents` VALUES (8, 'Tikka', 'Female', 2, '<p><span class="bodytext">Tikka is our newest addition...thanks again to Jody of Riverbend Bordeaux for this georgeous girl!! She was born July 8,2009 in Washington. Her mother is Mitzi and her father is Kid. Kid''s mother is Junior Champion Amy and his father is Champion/Junior Champion Debonaire. They are from Kennel Z Orisku from the Czech Republic.&#160; </span></p>', 'tikka.jpg', NULL);
    INSERT INTO `parents` VALUES (9, 'Wistie', 'Female', 1, '', 'wistie.jpg', NULL);
    INSERT INTO `parents` VALUES (10, 'Chico', 'Male', 1, '', 'chico.jpg', NULL);
    INSERT INTO `parents` VALUES (11, 'Timber', 'Male', 1, '<p><span class="bodytext"><p style="text-align: left;">"Journey''s Supreme Tiny Timber Wolf"</p> <p style="text-align: left;">This tiny little man comes from Missouri and is AKC and CKC Registered! His Father is AKC Champion Rebound Black Russian.He has 47 Champions out of 62 in his 5 generation pedigree!!! Amazing!! His Mother is Ka-Lynn''s Pixie Dust at Lamar and has 5 champions out of 14 in her 3 generation pedigree.&#160; He is super TINY and should do a tremendous job as our next stud!!</p></span></p>', 'timber.jpg', NULL);
    INSERT INTO `parents` VALUES (12, 'Yogi', 'Male', 1, '<p style="text-align: left;"><em>"JK Littlesbugs Yogi Nobody Did Nothin"</em><strong><span class="bodytext"> </span></strong><span class="bodytext"><p style="text-align: left;">We at Supreme Chihuahua proudly present to you our newest addition Yogi! He was born in Pennsylvania on June 18, 2006, and later moved to Orlando, Florida. From there he came to make his permanent home here with us at Supreme Chihuahua! We consider ourselves very fortunate to have aquired this beautiful and tiny one of a kind extreme applehead chihuahua stud! Yogi is a 2 lb 6 oz teeny tiny blue fawn with white markings.<span style="font-style: italic;"> </span><em>He has 55 CHAMPIONS in his 6 generation pedigree...WOW!! </em>We are very excited to see what he will produce here at Supreme Chihuahua...I know his pups will be tiny and awesome! You will have a hard time finding these perfect qualities anywhere else!</p><p style="text-align: left;">Yogi is AKC and CKC registered.</p><p style="text-align: left;"></p><p style="text-align: left;"><em>JK LITTLESBUGS YOGI NOBODY DID NOTHIN</em></p> <p style="text-align: left;"></p><p style="text-align: left;"><em>CHAMPIONS INCLUDE (4 GENERATION):</em></p> <p style="text-align: left;"></p><p style="text-align: left;"><em>CH Ostreet Twenty-Four Seven</em><br><em>CH Cam''s Buttontop Beau</em><br><em>CH Durbin''s Atom</em><br><em>CH Davishall Black Bark O''BK</em></p>   </span></p>', 'yogi.jpg', NULL);

  • Mysql recordset inconsistent returns

    I am developing a php site using mysql and apache.
    I have finally managed to get a database connection and am
    trying now to create some recordsets.
    This is where the difficulties lie.....
    I have 14 tables, the majority of which are for drop down
    menus. - All these (Single columns) return recordsets with no
    problems.
    The two main relational tables have multiple columns.
    If I select a the majority of single selected columns, I have
    no problem but there are two columns where no recordset is
    returned. I have tried renaming these columns with no effect. The
    sql query seems fine and does work with all but two columns.
    Can ayone explain this inconsistency?
    Is it something to do with field definition?
    I am really dying for any help here.

    Show us some that work and some that don't, please. And tell
    us what the
    result of each is.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "RichardOMarketing" <[email protected]>
    wrote in message
    news:ejfclu$q4e$[email protected]..
    > DW has made this relatively easy as it provides the
    column names in a drop
    > down
    > menu once you have connected successfully to the Mysql
    database.
    >
    > I did try a general query with * but this didn't work so
    I tried a more
    > specific query with the relevant column name.
    >
    > As I have mentioned, some select queries work and some
    don't.
    >

  • Dreamweaver MySQL recordset connection problem

    Hi,
    I'm trying to create a recordset for the first time in
    Dreamweaver MX but am having problems getting the connection with
    the database to work.
    I have set up a MySQL database on my server (which I have
    checked and is OK), checked that PHP is running and have connected
    Dreamweaver to the server successfully ( in "Edit Sites" the
    "remote info" & "testing server" tests show a successful
    connection).
    When I try to connect to the database I get this sequence of
    events:
    1. Dialigue box: "Retrieving information from public_html"
    2. Dialigue box: "Waiting for server" (with progress bar)
    3. Dialigue box: "Dreamweaver cannot determine the remote
    server time. The Select Newer and Synchronise commands will not be
    available."
    4. Spinning ball for a few minutes (I'm using Mac OSX)
    5. back to "Waiting for server" dialogue box which remains
    for ages, eventually I click "cancel"
    6. "An unexpected error occurred"
    If anyone can shed any light on what I might be missing I
    would appreciate it greatly.
    Thanks - Zaphodz

    I am a newby to databases and am having a similar problem
    with asp and my remote sql database. My hosting provider told me to
    use this script:
    <%
    Dim DBName,DBUser,DBPass,objRS,objConn
    DBName="cham_members"
    DBUser="cham_member"
    DBPass="mypassword"
    Set objConn=Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString="DRIVER={MySQL ODBC 3.51
    Driver};Server=localhost;Database="&DBName&";UID="&DBUser&";pwd="&DBPass&";"
    objConn.Open
    Set objRS=Server.CreateObject("ADODB.Recordset")
    %>
    Since that code doesn't work with DreamWeaver's Databases
    panel Custom Connection String dialogue box I came up with this
    one:
    DRIVER={MySQL ODBC 3.51
    Driver};Server=localhost;Database=cham_members;UID=cham_member;PWD=mypassword;objConn.Ope n
    Set objRS=Server.CreateObject(ADODB.Recordset)
    It connected but doesn't show my tables. I followed all the
    advice I found here;
    1. Connect using the "Use passive FTP"
    2. Corrected a few illegal hyphens in my database.
    3. Tried MySQL 127.0.0.1:3306 which would not connect at all
    4. Remove Connection Scripts. No change.
    5. I have been running DreamWeaver 7.01 update.
    I noticed the database connection names come up in the
    "Connections" folder so I opened the file it had just created and
    pasted in the script my hosting company gave me. Still no luck. I
    am determined to learn to create dynamic websites so I really
    appreciate your help.
    Thanks, Ann Y.

  • PHP/mySQL code help please

    Hi all,
    Thanks to David Powers fab tutorial I am now well on my way to competeing my first dynamique website using PHP/mySQL, (thanks David ), however I am stuck on one particular area....can anyone please help?
    I know that the mySQL database uses the format YYYY/MM/DD for dates, and that is fine. I've sorted out how to display in a more regular format (eg. 1st September 2011) for my application, but I am stuck on how to convert a more regular formatted date entered by the site user into the mySQL format.
    Ideally I would like for the users entry or say either 1/9/11 or 1-9-11 (or something along those lines, to be recognised and displayed on the entry form, but to have a backend function that converts the data to mySQL format. I seem to be reading plenty of forum posts which say this can be done, but unfortunately I can't quite seem to fathom how, or where the code should sit. Would someone mind taking a look at my code page to actually identify what I need to insert, and equally as importantly...where!!!
    Along these lines...is it possible to have a mini-calendar date picker that could be embedded next to the date entry field to ensure that a valid date is entered and in the correct format? Where could this be sourced?
    Thanks in advance of some much needed help
    Mark

    This is becoming really frustrating for me (so god knows how I am to you!!!!), but I usually pick things up so fast and yet this whole PHP/SQL thing is eluding me!!
    I can see (I think) how the code would work, but am struggling to see where it fits into place with my own Dreamweaver 'Update Record' code, as follows. I have spent a couple of days trawling through PHP.net and various other sites and forums before bringing my stupidity to the public domain, but I just can't seem to crack it.
    This one last time then i'll leave you in peace??????
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
        $updateSQL = sprintf("UPDATE gig_guide SET `date`=%s, town=%s, venue=%s, private_or_public=%s, start_time=%s WHERE `index`=%s",
                           GetSQLValueString($_POST['date'], "date"),
                           GetSQLValueString($_POST['town'], "text"),
                           GetSQLValueString($_POST['venue'], "text"),
                           GetSQLValueString($_POST['type'], "text"),
                           GetSQLValueString($_POST['start_time'], "text"),
                           GetSQLValueString($_POST['index'], "int"));
      mysql_select_db($database_online, $online);
      $Result1 = mysql_query($updateSQL, $online) or die(mysql_error());
      $updateGoTo = "index.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $updateGoTo));
    $colname_updatePost = "-1";
    if (isset($_GET['index'])) {
      $colname_updatePost = $_GET['index'];

  • MySQL & PHP -- Help!

    Hi guys,
    Long time, no see! ;-)
    Anyway, I've got a question for someone who is pretty darn
    good with PHP,
    forms, and MySQL. This is ultimately what I need to achieve:
    I'm creating a webpage for my university that will allow the
    professors in
    the IST department to select their preferences in course
    choices. I want to
    list out each IST course and then give them two different
    things to do with
    each course. The first thing is they need to select if
    they've taught that
    IST course before. Secondly, they need to say whether they
    "don't want to
    teach" the course, are "willing to teach" the course, or
    "really want to
    teach" the course. OK, hope this makes sense so far. What I
    need help with
    is figuring out how to put all the choices for each categorey
    into one field
    in a MySQL database. For example, if they selected the "don't
    want to teach"
    option (I'm not sure if a drop-box or radio button would work
    best...) for
    IST 215, IST 110 and IST 230. How can I have those courses
    entered into the
    single database field called "dontwant?"
    This is my code so far:
    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or
    die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");
    // Get values from form
    $name=$_POST['name'];
    $thedate=date('m-j-y');
    $taughtbefore=;
    $dontwant=;
    $willing=;
    $reallywant=;
    $comments=!trim($_POST['comments']);
    // Insert data into mysql
    $sql="INSERT INTO $tbl_name(name, thedate, taughtbefore,
    dontwant,
    willing, reallywant, comments)VALUES('$name', '$thedate',
    '$taughtbefore',
    '$dontwant', '$willing', '$reallywant', '$comments')";
    $result=mysql_query($sql);
    // close connection
    mysql_close();
    Is there a way I can like...append all these values into one
    string to pass
    into the single database field...? As you can see, I really
    don't know how
    or what values to assign to those empty strings up there...
    I'm really
    unsure of how to go about doing this. I hope this makes
    sense...
    Thanks for any and all of your time!
    Shane H
    [email protected]
    http://www.avenuedesigners.com
    =============================================
    Blog:
    http://avenuedesigners.com/blog/
    Web dev articles, photography, and more:
    http://sourtea.com
    =============================================
    Proud GAWDS member
    http://www.gawds.org/showmember.php?memberid=1495
    Delivering accessible websites to all ...
    =============================================

    Hi Murray,
    Allow me to clarify. I ultimately need to display something
    like this...and
    this would be reading from the MySQL database, and output in
    a table on the
    webpage:
    | No Teach | Want to Teach | Really want |
    | IST 250 | IST 420 | IST 330 |
    | IST 110 | IST 101 | IST 311 |
    | IST 332 | | IST 120 |
    | | | IST 440
    |
    I understand your approach and think it's a good idea. I
    guess I should have
    a table for each, like: NoTeach, WantToTeach, and ReallyWant.
    My question is
    how I would put the right IST course into the right table.
    Like if they
    selected "I don't want to teach" would I have some type of if
    statement to
    sort them into the right tables? If so, can you give me some
    code on how it
    would work?
    Thanks!
    Shane H
    [email protected]
    http://www.avenuedesigners.com
    =============================================
    Blog:
    http://avenuedesigners.com/blog/
    Web dev articles, photography, and more:
    http://sourtea.com
    =============================================
    Proud GAWDS member
    http://www.gawds.org/showmember.php?memberid=1495
    Delivering accessible websites to all ...
    =============================================
    "Murray *ACE*" <[email protected]> wrote
    in message
    news:[email protected]...
    > Why would you want to put all of that into a single
    field? Sounds like
    > the wrong approach to me....
    >
    > I'd have a NoTeach table, containing at least three
    fields -
    >
    > termDate
    > profID
    > classID
    >
    > Each professor's "noteach" selection would then be a
    separate record in
    > that table, which could all be collated for display....
    >
    > --
    > Murray --- ICQ 71997575
    > Adobe Community Expert
    > (If you *MUST* email me, don't LAUGH when you do so!)
    > ==================
    >
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    >
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    > ==================
    >
    >
    > "Shane H" <[email protected]> wrote
    in message
    > news:[email protected]...
    >> Hi guys,
    >>
    >> Long time, no see! ;-)
    >>
    >> Anyway, I've got a question for someone who is
    pretty darn good with PHP,
    >> forms, and MySQL. This is ultimately what I need to
    achieve:
    >>
    >> I'm creating a webpage for my university that will
    allow the professors
    >> in the IST department to select their preferences in
    course choices. I
    >> want to list out each IST course and then give them
    two different things
    >> to do with each course. The first thing is they need
    to select if they've
    >> taught that IST course before. Secondly, they need
    to say whether they
    >> "don't want to teach" the course, are "willing to
    teach" the course, or
    >> "really want to teach" the course. OK, hope this
    makes sense so far. What
    >> I need help with is figuring out how to put all the
    choices for each
    >> categorey into one field in a MySQL database. For
    example, if they
    >> selected the "don't want to teach" option (I'm not
    sure if a drop-box or
    >> radio button would work best...) for IST 215, IST
    110 and IST 230. How
    >> can I have those courses entered into the single
    database field called
    >> "dontwant?"
    >>
    >> This is my code so far:
    >>
    >> // Connect to server and select database.
    >> mysql_connect("$host", "$username", "$password")or
    die("cannot
    >> connect");
    >> mysql_select_db("$db_name")or die("cannot select
    DB");
    >>
    >> // Get values from form
    >> $name=$_POST['name'];
    >> $thedate=date('m-j-y');
    >> $taughtbefore=;
    >> $dontwant=;
    >> $willing=;
    >> $reallywant=;
    >> $comments=!trim($_POST['comments']);
    >>
    >> // Insert data into mysql
    >> $sql="INSERT INTO $tbl_name(name, thedate,
    taughtbefore, dontwant,
    >> willing, reallywant, comments)VALUES('$name',
    '$thedate',
    >> '$taughtbefore', '$dontwant', '$willing',
    '$reallywant', '$comments')";
    >> $result=mysql_query($sql);
    >>
    >> // close connection
    >> mysql_close();
    >>
    >>
    >> Is there a way I can like...append all these values
    into one string to
    >> pass into the single database field...? As you can
    see, I really don't
    >> know how or what values to assign to those empty
    strings up there... I'm
    >> really unsure of how to go about doing this. I hope
    this makes sense...
    >>
    >> Thanks for any and all of your time!
    >>
    >>
    >> --
    >> Shane H
    >> [email protected]
    >>
    http://www.avenuedesigners.com
    >>
    >> =============================================
    >> Blog:
    >>
    http://avenuedesigners.com/blog/
    >>
    >> Web dev articles, photography, and more:
    >>
    http://sourtea.com
    >> =============================================
    >> Proud GAWDS member
    >>
    http://www.gawds.org/showmember.php?memberid=1495
    >>
    >> Delivering accessible websites to all ...
    >> =============================================
    >

  • [php+mysql] recordsets inside recordset?

    Hi all,
    is there a way to use a recordset result inside the SELECT
    statement of
    another recordset?
    Something similar to:
    SELECT myotherrecordsetresult FROM mytable WHERE
    myfield=mycondition ORDER
    BY mysortfield ASC
    The variable "myotherrecordsetresult" would be text similar
    to this:
    "myotherrecordsetresult"="mycolumn1, mycolumn2, mycolumn...n"
    I'm searching a way to display only columns specified by
    another recordset.
    Is this possible in dreamweaver or only by hand?
    Thanks in advance.
    tony

    Look into the subquery syntax:
    http://dev.mysql.com/doc/refman/5.0/en/subqueries.html
    It lets you do things like this:
    SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2);
    Sonjay
    On 9/11/08 3:42 AM, "sweetman" wrote:
    > Hi all,
    > is there a way to use a recordset result inside the
    SELECT statement of
    > another recordset?
    >
    > Something similar to:
    >
    > SELECT myotherrecordsetresult FROM mytable WHERE
    myfield=mycondition ORDER
    > BY mysortfield ASC
    >
    > ?
    >
    > The variable "myotherrecordsetresult" would be text
    similar to this:
    >
    > "myotherrecordsetresult"="mycolumn1, mycolumn2,
    mycolumn...n"
    >
    > I'm searching a way to display only columns specified by
    another recordset.
    >
    > Is this possible in dreamweaver or only by hand?
    >
    > Thanks in advance.
    >
    > tony

  • Recordset Help

    Hi
    On my access database i created a query, i then open
    dreamweaver and create a recordset based on that query.
    Basically all i am doing is pulling data from two tables in
    the query, if i test the recordset all works fine, as soon as i add
    a statement saying only return results that are equal to MMCParam
    which is a form input field on the page, i get the error
    Syntax error in query expression, any idears why this is.
    I have tested the query on a recordset just pulling from one
    table and all works fine it just seems to happen when i build the
    recorset on the query.
    Please help
    John

    Dim Recordset1__MMColParam
    Recordset1__MMColParam = "advanced"
    If (Request.Form("search") <> "") Then
    Recordset1__MMColParam = Request.Form("search")
    End If
    %>
    <%
    Dim Recordset1
    Dim Recordset1_cmd
    Dim Recordset1_numRows
    Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
    Recordset1_cmd.ActiveConnection = MM_linkmicrotek_STRING
    Recordset1_cmd.CommandText = "SELECT Supplier, Product_Type,
    Part_No, Frequency, Connector_Type, Average_Power_Handling,
    Switch_Type, Package, Gain, Pout, P1dB_Output, Output_IP3,
    Attenuation, Reverse_Voltage, name FROM Category WHERE Product_Type
    Like ?"
    Recordset1_cmd.Prepared = true
    Recordset1_cmd.Parameters.Append
    Recordset1_cmd.CreateParameter("param1", 5, 1, 1073741823, "%" +
    Recordset1__MMColParam + "%") ' adDouble
    Set Recordset1 = Recordset1_cmd.Execute
    Recordset1_numRows = 0
    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index
    Repeat1__numRows = -1
    Repeat1__index = 0
    Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
    This is the results page from a keyword search, the form
    variable is called search. As soon as i add the sql to say if like
    MMColParam thats when it does not work.
    Please help
    John

  • JDBC Java- mysql problem help!

    Hi, I wnat to connect to mySQL fromo Java, I followed all the instructions from the mySql web page, yet I havent been able to do it, when I compile the java progrm I keep getting class not found exceptions, I am using Fedora Core and Java was already installed-well I chose to install it when I installed the operating system, the point is that the paths are all assigned by he system not by me.
    WHat can I do?, Ive been trying over andover again with no results, hopefully somebody can help, I tried to include all the configuration in this email,
    thank you
    my java program is the following:
    t.java
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class t {
    public static void main (String[] args) {
    System.out.println("Hello, world!\n");
    Class.forName("com.mysql.jdbc.Driver");
    when I javac t.java
    I have the following error
    4. ERROR in t.java
    (at line 11)
    Class.forName("com.mysql.jdbc.Driver");
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Unhandled exception type ClassNotFoundException
    when I comment out the Class.forName the hello world rogram runs fine
    when I vi /etc/java java.conf this is the result
    # System-wide Java configuration file -- sh --
    # JPackage Project [www.jpackage.org]
    # Location of jar files on the system
    JAVA_LIBDIR=/usr/share/java
    # Location of arch-specific jar files on the system
    JNI_LIBDIR=/usr/lib/java
    # Root of all JVM installations
    JVM_ROOT=/usr/lib/jvm
    # You can define a system-wide JVM root here if you're not using the default one#JAVA_HOME=$JVM_ROOT/java-gcj
    # Options to pass to the java interpreter
    JAVACMD_OPTS=
    ~
    [root@localhost test]# echo $PATH
    /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
    echo $JAVA_HOME
    it contains nothing
    ls /usr/share java*
    java
    java-1.3.0
    java-1.4.0
    java-1.4.1
    java-1.4.2
    java-1.5.0
    javadoc
    java-ext
    java-utils
    mysql-connector-java-3.1.13-bin.jar is under
    /usr/share/java
    in /etc/profile I have:
    export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java-3.1.13-bin.jar
    in /root/.bash_profile i have
    CLASSPATH=/usr/share/java/mysql-connector-java-3.1.13-bin.jar:/usr/lib/java-ext/mysql-connector/mysql-connector-java-3.1.13-bin.jar
    export CLASSPATH
    when I echo $PATH i have
    /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

    Thanks duff,
    The driver seems to be found
    when I run
    public class t {
    public static void main (String[] args) {
    try
    System.out.println("Hello, world!\n");
    Class.forName("com.mysql.jdbc.Driver");
    System.out.println("MySQL Driver Found");
    catch (ClassNotFoundException e)
    System.out.println("MySQL Driver NOT Found");
    e.printStackTrace();
    I feel somehow ive been focusing in the wrong side of the problem due to my ignorance in Java. Please help me to understand, the reson for which ithe runtime was telling me that there was an unhandled exception was because it is a requirement to handle all exceptions of this kind? why wouldnt it cmplain if I jst did the hello world without any exception handling, maybe because it is a requirement in the Class.forName...
    the other question is, is the message I was obtaining completely independent of the fact that the class was or was not found?
    Maybe, I should go with these questions to the newbies forum...
    thanks

  • Problem with CMP bean and MySQL: please help me!!!

    Hi,
    I am using J2EE Sun server 1.3 and Mysql 4.0 database with its MySQL Connector/J 3.0.
    The driver connection to the database is fine since "Generate Default SQL" in deploytool gives "SQL generation complete".
    However, I can't have a simple row with one text field called test being created in my mysql table called test.
    Of course , the mysql server is started and the test table set for use.
    Here is my code (I try to access my database from a servlet using a CMP Entity bean):
    try{
    Context initial = new InitialContext();
    Object objref = initial.lookup(EntityHome.JNDI_NAME);
    EntityHome home = (EntityHome)PortableRemoteObject.narrow(objref,EntityHome.class);     
    Entity test= home.create("zob");               
    /*EntityHome home = (EntityHome)PortableRemoteObject.narrow(objref,EntityHome.class);     
    catch (Exception ex){                                                                out.println("exception message : " + ex.getMessage()+"</body></html>");}
    I get the following exception message :
    RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: nested exception is: java.sql.SQLException: Syntax error or access violation, message from server: "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 '"EntityCMPTable" WHERE "test" = 'zob'' at line 1"; nested exception is: java.sql.SQLException: Syntax error or access violation, message from server: "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 '"EntityCMPTable" WHERE "test" = 'zob'' at line 1"
    I would be very grateful for help since I have a close deadline for this!!!!!!!!
    Thank you very much in advance dear java experts!!!!!!!
                                       

    Hallo
    I have the same problem and the same configuration.
    Do you have a solution for this problem ??
    Thanks
    Georg

  • Using PHP variable inside MySQL  recordset

    Can someone let me know if this is possible? I'm trying to
    use a variable inside a recordset. The code below is what I have at
    present but it white screens me when I try open it the page in the
    browser. $qualificationchoice is the variable (line 3)
    mysql_select_db($database_con_rsca, $con_rsca);
    $query_rs_Instructorsearch = sprintf("SELECT * FROM
    rsca_users WHERE rsca_public_region = %s AND
    rsca_public_"$qualificationchoice" = %s",
    GetSQLValueString($colname_rs_Instructorsearch,
    "text"),GetSQLValueString($colname2_rs_Instructorsearch, "int"));
    $rs_Instructorsearch =
    mysql_query($query_rs_Instructorsearch, $con_rsca) or
    die(mysql_error());
    $row_rs_Instructorsearch =
    mysql_fetch_assoc($rs_Instructorsearch);
    $totalRows_rs_Instructorsearch =
    mysql_num_rows($rs_Instructorsearch);

    Any chance you can help me with phase 2.
    I'm trying to get determine $qualificationchoice by the
    setting of a form menu $_POST['qualification']
    I know I'm close but it just won't quite work
    Here's what I have right now:
    if (isset($_POST['qualification'])) {
    $colname2_rs_Instructorsearch = (get_magic_quotes_gpc()) ?
    $_POST['qualification'] : addslashes($_POST['qualification']);
    //code to set qualification choice
    if($_POST['qualification']==1) {$qualificationchoice="CWA";}
    elseif ($_POST['qualification']==2)
    {$qualificationchoice="SPA";}
    elseif ($_POST['qualification']==3)
    {$qualificationchoice="WGL";}
    elseif ($_POST['qualification']==4)
    {$qualificationchoice="ML";}
    elseif ($_POST['qualification']==5)
    {$qualificationchoice="MLW";}
    elseif ($_POST['qualification']==6)
    {$qualificationchoice="MIA";}
    elseif ($_POST['qualification']==7)
    {$qualificationchoice="MIC";}
    elseif ($_POST['qualification']==8)
    {$qualificationchoice="guide";}
    // code to set qualification choice ends
    $colname_rs_Instructorsearch = "-1";
    if (isset($_POST['region'])) {
    $colname_rs_Instructorsearch = (get_magic_quotes_gpc()) ?
    $_POST['region'] : addslashes($_POST['region']);
    mysql_select_db($database_con_rsca, $con_rsca);
    $query_rs_Instructorsearch = sprintf("SELECT * FROM
    rsca_users WHERE rsca_public_region = %s AND
    rsca_public_{$qualificationchoice} = 1 AND rsca_public_listme =1
    AND expired =0", GetSQLValueString($colname_rs_Instructorsearch,
    "text"));
    $rs_Instructorsearch =
    mysql_query($query_rs_Instructorsearch, $con_rsca) or
    die(mysql_error());
    $row_rs_Instructorsearch =
    mysql_fetch_assoc($rs_Instructorsearch);
    $totalRows_rs_Instructorsearch =
    mysql_num_rows($rs_Instructorsearch);
    ?>
    Any suggestion would be great
    Thanks
    Dave

  • OC4J with MySQL please Help

    i wanna test my work with Ejb 3.0 and i want connect with MySQL
    i tested connection with MySQL database from JDeveloper
    and it successed and i created CMP from MySQL tables
    But the problem when im trying to deploy it with OC4J
    it throws an exception SQLException ( Invalid Oracle URL )
    if anybody know anything about this problem
    please help me

    thankx for help
    but it didnt work i dont know why
    i tried many way to deploy it but it stell throws exception
    << Invalid Oracle URL specifiedError Code: 17067
    >>
    this is OC4J data-sources.xml file
    <?xml version="1.0" ?>
    <data-sources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/data-sources-10_1.xsd" schema-major-version="10" schema-minor-version="1">
    <managed-data-source user="root" password="pagera" connection-pool-name="Example Connection Pool" jndi-name="jdbc/MySQLDS" name="MySQLDS" />
    <connection-pool name="Example Connection Pool">
    <connection-factory factory-class="oracle.jdbc.pool.OracleDataSource" user="root" password="pagera" url="jdbc:mysql://localhost/test" />
    </connection-pool>
    </data-sources>
    and i tried it
    <data-source class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
    name="mysqlDS" location="jdbc/mysqlCoreDS" xa-location="jdbc/xa/mysqlXADS"
    ejb-location="jdbc/mysqlDS" connection-driver="com.mysql.jdbc.Driver"
    username="root"
    password="pagera"
    url="jdbc:mysql://localhost/test"
    inactivity-timeout="30" />
    but it didnt work too
    i dont know what to do.....
    if anyone has another way pls tell me

  • DW MySQL query help

    I'm fairly new to DW and MySQL. I'm trying to develop what I
    thought was a simple search and results app., but am apparently
    having a program logic issue
    I have a form with 2 radio buttons, code below:
    <form name="card_search" id="card_search" method="post"
    action="card_search_results.asp">
    <p>
    <label>
    <input <%If
    (CStr((rsCardCatBaseball.Fields.Item("catID").Value)) = CStr("1"))
    Then Response.Write("CHECKED") : Response.Write("")%>
    type="radio" name="RadioGroupCardCat" value="1" />
    Baseball</label>
    <br />
    <label>
    <input <%If
    (CStr((rsCardCatBaseball.Fields.Item("catID").Value)) = CStr("2"))
    Then Response.Write("CHECKED") : Response.Write("")%>
    type="radio" name="RadioGroupCardCat" value="2" />
    Football</label>
    <br />
    <input name="submit_card_cat" type="submit"
    id="submit_card_cat" value="Submit" />
    </p>
    </form>
    When testing using the GET URL param. I see that the var
    RadioGroupCardCat=1 (baseball) or RadioGroupCardCat=2 (football)
    are getting passed to the card_search_results.asp page. However, I
    can't seem to figure out how to capture the RadioGroupCardCat
    values (1 or 2) in my SQL queries. I currently have 2 recordset
    queries (rsCardCatBaseball and rsCardCatFootball) below.
    rsCardCatBaseball:
    SELECT tblcard.cardyear, tblcardvend.vendname,
    tblcard.cardnum
    FROM tblcard, tblcardcat, tblcardvend
    WHERE RadioGroupCardCat=1 AND
    tblcardvend.vendid=tblcard.vendid AND
    tblcardcat.catid=tblcard.catid
    rsCardCatFootball:
    SELECT tblcard.cardyear, tblcardvend.vendname,
    tblcard.cardnum
    FROM tblcard, tblcardcat, tblcardvend
    WHERE RadioGroupCardCat=2 AND
    tblcardvend.vendid=tblcard.vendid AND
    tblcardcat.catid=tblcard.catid
    'catid' is the MySQL table field with either a value of 1
    (baseball) or 2 (football). I'm using ASP/VBScript, so below is how
    the variable is declared in the RecordSet variables area of DW.
    FOR rsCardCatBaseball:
    NAME
    RadioGroupCardCat
    DEFAULT VALUE
    1
    RUNTIME VALUE
    Request("catid")
    For rsCardCatFootball:
    NAME
    RadioGroupCardCat
    DEFAULT VALUE
    2
    RUNTIME VALUE
    Request("catid")
    The problem is that I get the same results for both queries.
    The results for the rsCardCatFootball query are identicle to the
    rsCardCatBaseball query. Aren't I supposed to have 2 seperate
    recordsets in the results page so that one gets passed one value
    and the other RS gets the other value? Any assistance much
    appreciated. Thanks.

    A radio group is only supposed to pass one value from the
    form depending
    upon which option has been clicked, therefore on the results
    page you should
    only need one recordset providing that everything is going
    against the same
    table. Providing that a value of 1 or 2 relate to the same
    field then you
    will be able to use the recordset dialogue box to build the
    SQL.
    However if different tables or fields are involved then you
    will need to
    handwrite the SQL statement
    Paul Whitham
    Certified Dreamweaver MX2004 Professional
    Adobe Community Expert - Dreamweaver
    Valleybiz Internet Design
    www.valleybiz.net
    "obcbeatle" <[email protected]> wrote in
    message
    news:[email protected]...
    > After reading my original post, I see that it is was not
    worded very well.
    > Basically the problem I am having is understanding how
    to capture values
    > that
    > are sent from a form to results page using Dreamweaver
    MX and MySQL.
    > Specifically, creating a group of two radio buttons
    where two values are
    > sent
    > to a results.asp page that contains a Recordset Query
    (using MySQL syntax)
    > that
    > will display the query results based on the values being
    sent from the
    > form
    > with the radio buttons. The radio button values being
    sent are either a
    > '1' or
    > a '2', depending on which radio button is selected and
    submitted. My
    > current
    > understanding is that I need to have two Recordset
    queries, one to capture
    > each
    > value being submitted. Thus I have a Recordset with a
    MySQL select
    > statement
    > designed to capture the value '1' and display the
    results, and a Recordset
    > with
    > a MySQL statement to capture the value '2' and display
    the results. At
    > present
    > when I Submit the radio button values, either a '1' or
    '2', I always get
    > the
    > display results for the Recordset Query designed to
    capture the value '1'.
    > So,
    > I believe that either I have NOT designed the program
    logic correctly in
    > Dreamweaver to capture two different values using two
    Recordsets, or my
    > MySQL
    > statement is flawed. I guess my primary questions are:
    >
    > 1) Should I be using two Recordsets or one Recordset in
    this case?
    >
    > 2) If I should be using one Recordset, can anyone point
    me to a sample
    > MySQL
    > select statement that handles two vales being submitted
    from a form?
    >
    > I have googled extensively looking for examples of how
    to do this, and
    > used a
    > book I have that has some examples, but NOT MySQL
    examples. Any
    > comments/suggestions appreciated. Thank you.
    >

  • PHP & MySQL recordset question

    Hello all,
    I've been searching for a while, and I can't seem to find an
    answer, so sorry if this has been asked a lot.
    I've got 5 tables that have similar information (id,
    firstname, lastname, topic, thread, and date).
    What I'm trying to do is have one search box where the user
    types in a keyword. Then it searches all 5 tables in both the topic
    and thread collumns. Then it displays the results from all 5 tables
    and orders them by date.
    I'm using dreamweaver 8, PHP, and MySQL.
    I've tried to use this format:
    SELECT column1 column 2
    FROM table1
    WHERE thread OR topic LIKE %variable%
    UNION
    SELECT column 1 column2
    FROM table 2
    WHERE thread OR topic LIKE %variable%
    ORDER by date DESC
    but keep getting error messages.
    Is this possible? If so, can anyone help me figure out how to
    do this, or where I can find a good tutorial?
    Thanks.

    Thanks for your reply.
    Sorry, here is the entire SQL statement:
    SELECT eventforum.FirstName, eventforum.LastName,
    eventforum.topic, eventforum.Thread, eventforum.`Date`
    FROM eventforum
    WHERE Thread or topic LIKE %colname%
    UNION
    SELECT fundforum.FirstName, fundforum.LastName,
    fundforum.topic, fundforum.Thread, fundforum.`Date`
    FROM fundforum
    WHERE Thread OR topic LIKE %colname%
    UNION
    SELECT generalforum.FirstName, generalforum.LastName,
    generalforum.topic, generalforum.Thread, generalforum.`Date`
    FROM generalforum
    WHERE Thread OR topic LIKE %colname%
    UNION
    SELECT persupport.FirstName, persupport.LastName,
    persupport.topic, persupport.Thread, persupport.`Date`
    FROM persupport
    WHERE Thread OR topic LIKE %colname%
    UNION
    SELECT prosupport.FirstName, prosupport.LastName,
    prosupport.topic, prosupport.Thread, prosupport.`Date`
    FROM prosupport
    WHERE Thread OR topic LIKE %colname%
    UNION
    SELECT soldier.FirstName, soldier.LastName, soldier.topic,
    soldier.Thread, soldier.`Date`
    FROM soldier
    WHERE Thread OR topic LIKE %colname%
    ORDER BY 'Date' DESC
    the variable colname is defined as:
    Name: colname
    Type: Text
    Default Value: -1
    Runtime value: $_POST['searchbox']
    here is the error message that I get with this setup:
    Missing type for variable:colname
    If I remove the variable and the WHERE statements, I get this
    error message:
    MySQL Error #: 1271
    Illegal mix of collations for operation 'UNION'
    If I remove the variable, the WHERE staements, and the ORDER
    BY statement, I get the following error message:
    MySQL Error #: 1271
    Illegal mix of collations for operation 'UNION'

Maybe you are looking for