DISTINCT MySQL Issues

I am trying to pull only one record per MLSNumber using
DISTINCT for MySQL,
but it isn't working. What am I doing wrong? Also, is there a
way to pull
the most recent record of the 2+ based on PostDate?
Select
DISTINCT(MLSNumber),PhotoURL,ListPrice,City,PropertyID,ListOfficeId,PropertyType
FROM property WHERE ListOfficeId = 340169
Wally Kolcz
MyNextPet.org
Founder / Developer
586.871.4126

select blah blah
from property join
(select max(postdate) maxdate
from property
where listofficeid = 340169 ) x on postdate = maxdate
where listofficeid = 340169

Similar Messages

  • PHP/MySQL issue after security update 2010-005

    Hello,
    I run Apache/PHP/MySQL on my MBP for testing Web sites.
    After the 2010-005 security update I can't connect to my databases anymore.
    I don't know how to fix this, I even don't know where to start looking.
    Ideas, anyone?

    coloma wrote:
    etresoft, thanks for sharing this ... I decided to go with the TriangleJuice suggestion instead for two reasons ... first is that I wasn't sure where to find this launchd file.
    There is nothing wrong with TriangleJuice's suggestion. My only issue with creating a php.ini file is that now I have to worry about all those other settings in the ini file. If something else in PHP breaks, I have to figure out if I am the one who broke it.
    Apple ships MySQL with MacOS X Server. They probably adjusted the PHP settings to match how they have MySQL setup in MacOS X Server.
    For MySQL's, no, Sun's - drat! no, Oracle's part, they still haven't acknowledged the fact that Apple has shipped MacOS X 10.4. MySQL still ships with a Startup Item. If you don't know where the launchd file is, it is because you don't have one. You probably have a MySQL entry in /Library/StartupItems or maybe /System/Library/StartupItems. Startup Items were deprecated in 10.4. Oracle should be creating a file named com.mysql.mysqld.plist in /Library/LaunchDaemons.
    Here is what mine looks like now:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>ProgramArguments</key>
    <array>
    <string>/usr/local/mysql/bin/mysqld</string>
    <string>--socket=/var/mysql/mysql.sock</string>
    <string>--basedir=/usr/local/mysql</string>
    <string>--datadir=/usr/local/mysql/data</string>
    <string>--user=mysql</string>
    <string>--log-error=/usr/local/mysql/data/Pele.local.err</string>
    <string>--pid-file=/usr/local/mysql/data/Pele.local.pid</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    </dict>
    </plist>
    I also don't have a /var/mysql directory and wasn't sure whether I should just create one or if this meant my configuration was different. If you feel like explaining any of this, I'd be curious to know.
    You have to create one. Such a directory probably already exists on MacOS X Server. Just make sure it is owned by mysql.
    sudo mkdir /var/mysql
    sudo chown _mysql:staff /var/mysql
    sudo chmod 0755 /var/mysql
    [jdaniel@Pele:516] /var $ ls -al /private/var | grep mysql
    drwxr-xr-x 3 _mysql staff 102 Aug 26 20:03 mysql
    Of course, /var is a symbolic link to /private/var. Long story there.

  • Flash PHP MySQL issue

    can someone please tell me what i'm doing wrong:
    (Actionscript)
    var db_out:URLVariables = new URLVariables();
    db_out.from = "property";
    db_out.where = "`state`='OR'";
    var db_req:URLRequest = new URLRequest("php/search.php");
    db_req.data = db_out;
    db_req.method = URLRequestMethod.POST;
    ldr_db.load(db_req);
    (PHP)
    $select='`id`';
    $from=$_POST['from'];
    $where=$_POST['where'];
    $order='`type`';
    $result=mysql_query('SELECT '.$select.' FROM `'.$from.'` WHERE '.$where.' ORDER BY '.$order);
    this returns no results.
    this issue is within the db_out.where variable.
    other searches where db_out.where is a Number (IE: where = "`status`=1") work fine.
    so how do i pass a String query from Flash to MySQL?
    if it were a single variable sent to PHP, i would wrap it in single quotes (IE: ''SELECT '.$select.' FROM `'.$from.'` WHERE `state`='."'".$var."'".' ORDER BY '.$order), but how do i properly send a WHERE statement from Flash to MySQL involving a String??
    much appreciated,

    i figured it out. no idea why this is an issue, but it seems to be.
    if Flash passes a string to PHP to be used in a MySQL query, and that string contains single quotes (IE `city`='Portland'), the query will return 0 results, even if its WHERE had an OR conditional in it not using single quotes (IE `status`=1).
    so here's the fix:
    use some unused symbol in place of the single quotes (IE ^) in Flash, and have PHP use str_replace to swap them for single quotes.
    i dont know why PHP has to be the one to implement the single quotes, but it seems to
    IE:
    $where = str_replace('^', "'", $_POST['where']);
    i hope this saves someone the hours i spent trying to figure this one out!!

  • Yet again with (probably) php/mysql issues

    Hello, everyone. I think I am setting a record for asking the most questions about basically the same thing, but here goes:
    Okay, I am trying to install a message board on one of my sites. I downloaded mysql 5 and made it possible for php to access it per the instructions found here: http://docs.info.apple.com/article.html?artnum=301457. The message board is already on my server, but when I go to the install.php page, it will not let me go beyond the first page. When I try to access the forums directly on the web at mydomain.com/forum, I get the following error:
    Access denied for user 'root'@'localhost' (using password: NO)
    Unable to connect to DB server localhost at port 3306
    I have been having a couple of dns issues, so I tried changing localhost to my server's name and my hostname, only to get the following errors:
    Host '70.90.83.165' is not allowed to connect to this MySQL server
    Unable to connect to DB server artsmiths.local at port 3306
    Unknown MySQL server host '70-90-83-165-BusName-md.dc.hfc.comcastbusiness.net' (1)
    Unable to connect to DB server 70-90-83-165-BusName-md.dc.hfc.comcastbusiness.net at port 3306
    (because of the dns issue I was having, apple tech support recently had me change my hostname to that crazy comcast one using my static ip. This was done after I had downloaded the message boards, so I don't know if that matters).
    Another thing that could be an issue is that for the site I wanted the forums on, the index.php file was deleted when I installed the boards. I was wondering if simply reinstalling now that I have replaced it would help.
    The only other thing I could think of that could be creating the problem is a permissions issue, which is what the tech support person for the boards seems to think. However, I have done repair permissions and manually changed the affected files, and all to no avail.
    Since this board is always more helpful than tech support, I thought I'd come on here and see if anyone has any suggestions. I'm sorry this is such a long post; I am just trying to be thorough. Thanks in advance for any help.

    It is php 4.4.1. I have attempted to find it in my php.ini, but I swear it's not there (unless I'm truly losing my mind). I've pasted below the contents of the data handling section to see if anyone can tell where I'm missing something. I think I am going to have to put it in the .htaccess file because I can't figure out what else to do. Does it matter where I put it in the .htaccess file, or can I just put it at the end? Thank you again.
    ; Data Handling ;
    ; Note - track_vars is ALWAYS enabled as of PHP 4.0.3
    ; The separator used in PHP generated URLs to separate arguments.
    ; Default is "&".
    ;arg_separator.output = "&"
    ; List of separator(s) used by PHP to parse input URLs into variables.
    ; Default is "&".
    ; NOTE: Every character in this directive is considered as separator!
    ;arg_separator.input = ";&"
    ; This directive describes the order in which PHP registers GET, POST, Cookie,
    ; Environment and Built-in variables (G, P, C, E & S respectively, often
    ; referred to as EGPCS or GPC). Registration is done from left to right, newer
    ; values override older values.
    variables_order = "EGPCS"
    ; Whether or not to register the EGPCS variables as global variables. You may
    ; want to turn this off if you don't want to clutter your scripts' global scope
    ; with user data. This makes most sense when coupled with track_vars - in which
    ; case you can access all of the GPC variables through the $HTTP*VARS[],
    ; variables.
    ; You should do your best to write your scripts so that they do not require
    ; register_globals to be on; Using form variables as globals can easily lead
    ; to possible security problems, if the code is not very well thought of.
    register_globals = Off
    ; This directive tells PHP whether to declare the argv&argc variables (that
    ; would contain the GET information). If you don't use these variables, you
    ; should turn it off for increased performance.
    registerargcargv = On
    ; Maximum size of POST data that PHP will accept.
    postmaxsize = 8M
    ; This directive is deprecated. Use variables_order instead.
    gpc_order = "GPC"
    ; Magic quotes
    ; Magic quotes for incoming GET/POST/Cookie data.
    magicquotesgpc = On
    ; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
    magicquotesruntime = Off
    ; Use Sybase-style magic quotes (escape ' with '' instead of \').
    magicquotessybase = Off
    ; Automatically add files before or after any PHP document.
    autoprependfile =
    autoappendfile =
    ; As of 4.0b4, PHP always outputs a character encoding by default in
    ; the Content-type: header. To disable sending of the charset, simply
    ; set it to be empty.
    ; PHP's built-in default is text/html
    default_mimetype = "text/html"
    ;default_charset = "iso-8859-1"
    ; Always populate the $HTTPRAW_POSTDATA variable.
    ;alwayspopulate_raw_postdata = On

  • OBIEE 11G with MySql Issue Hierarchy is not working..

    Hi,
    i am using the OBIEE 11G with MySQL DB. i have sucessfully created the RPD. i created the Hierarchy in the RPD. this is the scerario i have created.
    i have only one data column created_at. by using this column i create 3 more logical logical columns, which are Year,Month Name,Week and created Hierarchy by taking the these columns only.
    when i am viewing the result by taking the hierarchy it throwing the error systax error"ou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version".
    but we selecting the year column it successfully nagvigating to the month level data but when selecting the Hierarchy directly it is unable to navigate from year to month.
    please provide me the solution for this as soon as possbile i have an urgent requirement on this.
    Thanks,
    Yogi.

    Hi,
    Thanks for you post..
    My Requriement is that we no need to create new columns we need to necessary columns in BMM layer only and we need to use them in Hierarchy.
    Thanks,
    Yogi.

  • PHP/Mysql issue

    I use Dreamweaver CS3 to create my sites on a Windows/Apache
    Server with PHP5 and Mysql 5. The site works perfectly on my
    testing server at home. On the Web server I'm getting the following
    error which causes the page to not load:
    PHP Warning: mysql_query(): supplied argument is not a valid
    MySQL-Link resource in
    /hermes/bosweb/web248/b2488/ipw.horsehelp/public_html/residents/residents.php
    on line 63
    PHP Warning: mysql_select_db(): supplied argument is not a
    valid MySQL-Link resource in
    /hermes/bosweb/web248/b2488/ipw.horsehelp/public_html/residents/residents.php
    on line 61
    The lines in question are:
    Line 61 - mysql_select_db($database_conn_phh, $conn_phh);
    $query_getSuccess = "SELECT * FROM horses WHERE status =
    'Success Story' ORDER BY horse_barn ASC";
    $getSuccess = mysql_query($query_getSuccess, $conn_phh) or
    die(mysql_error());
    $row_getSuccess = mysql_fetch_assoc($getSuccess);
    $totalRows_getSuccess = mysql_num_rows($getSuccess);
    All of the code is supplied by Dreamweaver. I did not tweak
    the code. I'm not a web developer and what I have found out there
    is still reading greek to me. My connection file is working and
    connecting the database that I have tested.
    Since the above code is throughout the site in one form or
    another it's causing me major headaches. Any help would be
    appreciated.

    This is the first time I've used Adobe products so if the
    following is in the wrong forum (It's the closest one I found so
    far) or the format is incorrect please forgive me.
    I'm new to Dreamweaver CS3 and as I was reading the "first
    steps" it mentions to set up a Dreamweaver site right away. I got
    as far as completing "Site Definition" page under the basic side of
    the setup screen.
    The next screen is "Do you want to work with server
    Technology?"
    There are 2 options - Yes or No. If you select yes a
    drop-down menu appears with several options (but you can only
    select one)...
    Asp Javascript
    Asp VbScript
    Asp.net#
    Asp.net Vb
    Cold Fusion
    JSP
    Php MySql.
    I know nothing about these format and brand new to web design
    so I thought it best to contact GoDaddy (my hosting account) to
    find out what their servers would support. I spoke to a tech rep
    but she wasn't sure.
    She did mention that I have a windows hosting account and Php
    MySql would not work unless I changed to their Linux platform at no
    additional charge.
    The site I have in mind will design with CSS, Liquid layout,
    have some flash, widgets, an inquiry form that clients complete and
    results e-mailed to me, auto-responder, Paypal link and whatever
    else I can discover from Dreamweaver.
    My question being:
    I haven't even begun designing my site because I do not know
    what weather I should select the Yes option and select one of the
    formats mentioned above (if so which one) - or select the No
    option. If I do select the No option at the very beginning, will I
    have problems with my site uploading and working correctly?
    Thank you
    Travis

  • AS3 to PHP to MySQL issue

    I have searched for a solution over many forums and none of the code seems to work. I cannot get AS3 to work with a php script.
    I am trying to create a registration form in AS3
    and then have that information go to mysql database when
    the submit button is pressed. Here is part of the AS3 code: var variables:URLVariables = new URLVariables;
    var varSend:URLRequest = new URLRequest("register.php");
    varSend.method = URLRequestMethod.POST;
    varSend.data = variables;
    var varLoader:URLLoader = new URLLoader;
    varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
    variables.userName = user_txt.text;
    variables.userPass = pass_txt.text;
    variables.userEmail = email_txt.text;
    varLoader.load(varSend); Here is the php script "register.php": <?php $db_host = "localhost";
    $db_username = "root";
    $db_pass = "";
    $db_name = "userregister"; mysql_connect("$db_host","$db_username","$db_pass" ) or die ("could not connect to mysql");
    mysql_select_db("$db_name") or die ("no database"); $senderName = $_POST['userName'];
    $senderPass = $_POST['userPass'];
    $senderEmail = $_POST['userEmail']; $sqlCommand = "INSERT INTO user (username, password, email)
    VALUES('$senderName','$senderPass','$senderEmail') "; $query = mysql_query($sqlCommand) or die (mysql_error()); $my_msg = "Thanks $senderName, all data has been sent."; echo "return_msg=$my_msg"; ?>

    there's no problem with your flash if your textfields are passing the correct values.
    you have a table named user and it's failing to add passed variables?   if yes, use fixed strings (instead of passed variables) in your php and test your php code.

  • The distinct count issue?

    Hello experts,
      So, I have an OBI report (table view).  I needed to get the percentage difference btn 2 columns, I did. Then I had to summarize  difference in 4 buckets (0-15, 16-30, 31-50, >50%); I did (case statement). NOW,  I need to summarize(distinct count) the above buckets based on Store numbers for each day.
    Basically, if the difference is btn(0-5%) and I have 5 stores then I need to see 5 stores separately. The problem I am having when I do the distinct count instead of having the counts separately for each bucket I am getting the total.  I see the buckets summarized, but the store column is showing the total number of all(we have about 700 stores) instead of breaking down the count for each bucket.  In the stores column I am using the distinct count function, I don't know if the problem is here or the case statement.
    I know its Friday, still I believe there is someone who might have an idea on my dilemma.
    As always, your insights are highly appreciated,

    Header 1
    Header 2
    Header 3
    Header 4
    Header 5
    Header 6
    Date
    Store Count
    Sales
    Todate Sales
    Difference %
    Difference buckets
    03/24/2013
    698
    716,374
    717,011
    -0%
    0-15%
    03/25/2013
    698
    583,335
    583,793
    -0%
    0-15%
    03/26/2013
    698
    220,640
    220,886
    -0%
    0-15%
    03/27/2013
    698
    236,803
    188,150
    215
    11-30%
    Header 8
    Srini,
      I am still not good at using OTN tables, but above is what I am talking about. Basically, The store count should not show the total count of all stores, instead it should show only distinct count that within the percentage bucket. As u can see it gives me the total, I made sure the aggregate rule isn't sum. By the way, could the problem be the case statement not the store column..
    I also tried bucket and store only, still it shows the sum of all stores and not just distinct.
    any idea

  • MySQL issue: Exception while getting MetaDataInfo

    Hi Folks,
    Our application is starting MySQL internally during startup.
    Sometimes, I get the following exception and MySQL doesn't start:
    [09 Jul 2007 14:05:35:733] Exception while getting MetaDataInfo : Can't create/write to file 'C:\DOCUME~1\sridhar\LOCALS~1\Temp\#sql_884_0.MYI' (Errcode: 13)
    [09 Jul 2007 14:05:35:733] java.sql.SQLException: Can't create/write to file 'C:\DOCUME~1\sridhar\LOCALS~1\Temp\#sql_884_0.MYI' (Errcode: 13)
    [09 Jul 2007 14:05:35:748]      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
    [09 Jul 2007 14:05:35:748]      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
    [09 Jul 2007 14:05:35:748]      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
    [09 Jul 2007 14:05:35:748]      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
    [09 Jul 2007 14:05:35:748]      at com.mysql.jdbc.Connection.execSQL(Connection.java:3118)
    [09 Jul 2007 14:05:35:748]      at com.mysql.jdbc.Connection.execSQL(Connection.java:3047)
    [09 Jul 2007 14:05:35:748]      at com.mysql.jdbc.Statement.executeQuery(Statement.java:1166)
    [09 Jul 2007 14:05:35:748]      at com.mysql.jdbc.DatabaseMetaData$2.forEach(DatabaseMetaData.java:2046)
    [09 Jul 2007 14:05:35:748]      at com.mysql.jdbc.DatabaseMetaData$IterateBlock.doForAll(DatabaseMetaData.java:76)
    [09 Jul 2007 14:05:35:748]      at com.mysql.jdbc.DatabaseMetaData.getColumns(DatabaseMetaData.java:1920)
    [09 Jul 2007 14:05:35:748]      at com.adventnet.nms.store.relational.MetaDataInfo.getMetaDataInfo(MetaDataInfo.java:355)
    [09 Jul 2007 14:05:35:748]      at com.adventnet.nms.store.relational.RelationalUtil.initMetaInfo(RelationalUtil.java:1251)
    [09 Jul 2007 14:05:35:748]      at com.adventnet.nms.store.relational.RelationalUtil.initMetaInfo(RelationalUtil.java:1240)
    [09 Jul 2007 14:05:35:748]      at com.adventnet.nms.startnms.NmsMainBE.main(NmsMainBE.java:361)
    [09 Jul 2007 14:05:35:748] Exception while getting MetaDataInfo : Can't create/write to file
    If any of you have seen the same, please do let me know what can be the problem and how to overcome the same.
    Thanks much,
    Sandeep

    Hi,
    I do have the permission. I've logged in as admin.
    There was another related mail thread that says it may be to do with Virus Scan settings on the machine:
    http://forum.java.sun.com/thread.jspa?threadID=5061757&messageID=9333692
    Will try the solution provided there.
    Thanks,
    Sandeep

  • Many To Many relationship, Distinct Aggregate issue

    Hi, 
    I need some help pleeeaaase... 
    Ok, so i'm implementing a GL cube, and i have a bunch of accounts which can be aggregated to different levels of a parent child hierarchy, because i'm using a parent child hierarchy SSAS does a distinct "sum" to the Fact table, and so my Totals
    get a bit messed up... 
    So, i've tried looking for way to turn off this feature, but couldn't find one.
    The alternative which i'm also stuck on, which is to create a member which goes to the child level, for each total, and re-aggregates ALL the values that are there.
    I seem to have created a member in an MDX query that works perfectly... yay!, BUT when i put this into a calculated member... well it goes pear shaped, and i can't understand how it arrives at the number.. 
    Please shout if my explanation is a bit sketchy..
    Here is the code.
    MDX Query....
    WITH MEMBER [Measures].CurrentBalanceActualDecendants
    AS 
    SUM(
                           EXCEPT(
                                      DESCENDANTS([Dimension Report Detail].[Finance Report Hierachy].CurrentMember, 2, BEFORE),
                                      [Dimension Report Detail].[Finance Report Hierachy].CurrentMember
                         [Measures].[Current month Actual]
    MEMBER [Measures].[BalanceTestc]
    AS( IIF (
                         [Measures].CurrentBalanceActualDecendants = 0, 
                         [Measures].[Current month Actual],
                         [Measures].CurrentBalanceActualDecendants
    SELECT {[Measures].[Current month Actual],
    [Measures].[BalanceTestc]}
    on 0
    DESCENDANTS([Dimension Report Detail].[Finance Report Hierachy].&[4], 3, BEFORE)
    --[Dimension Report Detail].[Finance Report Hierachy].Allmembers
    )on 1
    FROM [opfinanceGLTransaction]
    WHERE { [Dimension Snapshot].[Date Value].&[2014-06-30T00:00:00],
    [Dimension Snapshot].[Date Value].&[2014-05-31T00:00:00],
    [Dimension Snapshot].[Date Value].&[2014-04-30T00:00:00],
    [Dimension Snapshot].[Date Value].&[2014-03-31T00:00:00],
    [Dimension Snapshot].[Date Value].&[2014-02-28T00:00:00],
    [Dimension Snapshot].[Date Value].&[2014-01-31T00:00:00]
    CALCULATED Measure.......
    CREATE MEMBER CURRENTCUBE.[Measures].[Current Month Actual]
     AS IIF(
                         [Measures].CurrentmonthActualDecendants = 0, 
                         [Measures].[Balance],
                         [Measures].CurrentmonthActualDecendants
    VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'Fact GL Transaction';   
    CREATE MEMBER CURRENTCUBE.[Measures].CurrentmonthActualDecendants
     AS AGGREGATE(
                           EXCEPT(
                                      DESCENDANTS([Dimension Report Detail].[Finance Report Hierachy].CurrentMember, 2, BEFORE),
                                      [Dimension Report Detail].[Finance Report Hierachy].CurrentMember
                         [Measures].[Balance]
    VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'Fact GL Transaction';        

    Have you seen the "Multiple Parent-Child Hierarchies" design pattern in this paper:
    http://www.sqlbi.com/articles/many2many/
    I'm wondering whether you really need such MDX.
    Marco Russo (Blog,
    Twitter,
    LinkedIn) - sqlbi.com:
    Articles, Videos,
    Tools, Consultancy,
    Training
    Format with DAX Formatter and design with
    DAX Patterns. Learn
    Power Pivot and SSAS Tabular.

  • MySQL issues

    I have setup a brand new 10.4. server and have enabled mysql.
    I am using navicat to manage my OS X 10.4.4 mysql database. When i run navicat off the server, i am able to do a test connection to my sql
    When i run navicat on a 10,4.4 client, it says can't connect to server
    Why is this so?
    How do i solve this simple problem?

    select blah blah
    from property join
    (select max(postdate) maxdate
    from property
    where listofficeid = 340169 ) x on postdate = maxdate
    where listofficeid = 340169

  • PHP and MySQL issue {subject edited by moderator}

    Using Dreamweaver and PHP.   On one page, I have a form with an Insert Field (LastName) that enter into the SQL database. SQL database has the ID auto-increment.   When I click on Send (with the data entered into the database), I want the new page to open and display the ID field.  but when I insert a new id and I click Send it still displays the old id, whereas I want to display a new ID

    This code for isert page
    <?php require_once('Connections/pendaftaran.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      $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_insert"])) && ($_POST["MM_insert"] == "form")) {
      $insertSQL = sprintf("INSERT INTO maklumat_fail (fail_tajuk, fail_no, fail_seksyen, fail_hari, fail_bulan, fail_tahun, fail_rakbesi, fail_laci, fail_baris) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['fail_tajuk'], "text"),
                           GetSQLValueString($_POST['fail_no'], "int"),
                           GetSQLValueString($_POST['fail_seksyen'], "text"),
                           GetSQLValueString($_POST['fail_hari'], "int"),
                           GetSQLValueString($_POST['fail_bulan'], "text"),
                           GetSQLValueString($_POST['fail_tahun'], "int"),
                           GetSQLValueString($_POST['fail_rakbesi'], "text"),
                           GetSQLValueString($_POST['fail_laci'], "text"),
                           GetSQLValueString($_POST['fail_baris'], "text"));
      mysql_select_db($database_pendaftaran, $pendaftaran);
      $Result1 = mysql_query($insertSQL, $pendaftaran) or die(mysql_error());
      $insertGoTo = "detailPendaftaran.php?" . $row_Recordset1['fail_tajuk'] . "=";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form")) {
      $updateSQL = sprintf("UPDATE maklumat_fail SET fail_no=%s, fail_seksyen=%s, fail_hari=%s, fail_bulan=%s, fail_tahun=%s, fail_rakbesi=%s, fail_laci=%s, fail_baris=%s WHERE fail_tajuk=%s",
                           GetSQLValueString($_POST['fail_no'], "int"),
                           GetSQLValueString($_POST['fail_seksyen'], "text"),
                           GetSQLValueString($_POST['fail_hari'], "int"),
                           GetSQLValueString($_POST['fail_bulan'], "text"),
                           GetSQLValueString($_POST['fail_tahun'], "int"),
                           GetSQLValueString($_POST['fail_rakbesi'], "text"),
                           GetSQLValueString($_POST['fail_laci'], "text"),
                           GetSQLValueString($_POST['fail_baris'], "text"),
                           GetSQLValueString($_POST['fail_tajuk'], "text"));
      mysql_select_db($database_pendaftaran, $pendaftaran);
      $Result1 = mysql_query($updateSQL, $pendaftaran) or die(mysql_error());
      $updateGoTo = "detailPendaftaran.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $updateGoTo));
    mysql_select_db($database_pendaftaran, $pendaftaran);
    $query_Recordset1 = "SELECT * FROM maklumat_fail";
    $Recordset1 = mysql_query($query_Recordset1, $pendaftaran) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SISTEM PENDAFTARAN FAIL</title>
    <style type="text/css">
    .right {
      text-align: right;
    body {
      background-color: #6699CC;
    </style>
    </head>
    <body><form action="<?php echo $editFormAction; ?>" name="form" method="POST">
      <center>
        <p><img src="mps.png" width="1119" height="244" /></p></center>
      <table width="332" border="0" align="center">
          <tr>
            <td><h1 class="K">PENDAFTARAN FAIL</h1></td>
          </tr>
      </table>
        <p> </p>
        <table width="200" border="2" align="center" class="l">
          <tr>
            <td><center isoptional="l">Maklumat Fail</center></td>
          </tr>
      </table>
        <p> </p>
        <center><table width="587" border="6">
          <tr>
            <td width="567" height="233"><table width="560" height="206" border="0">
                <tr>
                  <td width="147" class="right"><strong>No. Fail</strong></td>
                  <td width="10">:</td>
                  <td width="432">MPSepang
                    <input name="fail_no" type="text" id="fail_no" size="40" /></td>
                </tr>
                <tr>
                  <td class="right"><strong>Tajuk Fail</strong></td>
                  <td>:</td>
                  <td><textarea name="fail_tajuk" cols="40" rows="5" id="fail_tajuk"></textarea></td>
                </tr>
                <tr>
                  <td class="right"><strong>Seksyen</strong></td>
                  <td>:</td>
                  <td><select name="fail_seksyen" size="Seksyen" id="fail_seksyen">
                      <option>Seksyen</option>
                      <option>Pentadbiran</option>
                      <option>Web, Latihan &amp; Komuniti</option>
                      <option>Rangkaian &amp; Infrastruktur</option>
                      <option>Sistem</option>
                  </select></td>
                </tr>
                <tr>
                  <td class="right"><strong>Tarikh Fail Dibuka</strong></td>
                  <td>:</td>
                  <td><select name="fail_hari" size="Hari" id="fail_hari">
                      <option>Hari</option>
                      <option>1</option>
                      <option>2</option>
                      <option>3</option>
                      <option>4</option>
                      <option>5</option>
                      <option>6</option>
                      <option>7</option>
                      <option>8</option>
                      <option>9</option>
                      <option>10</option>
                      <option>11</option>
                      <option>12</option>
                      <option>13</option>
                      <option>14</option>
                      <option>15</option>
                      <option>16</option>
                      <option>17</option>
                      <option>18</option>
                      <option>19</option>
                      <option>20</option>
                      <option>21</option>
                      <option>22</option>
                      <option>23</option>
                      <option>24</option>
                      <option>25</option>
                      <option>26</option>
                      <option>27</option>
                      <option>28</option>
                      <option>29</option>
                      <option>30</option>
                      <option>31</option>
                    </select>
                      <label for="bulan2"></label>
                      <select name="fail_bulan" size="Bulan" id="bulan2">
                        <option>Bulan</option>
                        <option>Januari</option>
                        <option>Februari</option>
                        <option>Mac</option>
                        <option>April</option>
                        <option>Mei</option>
                        <option>Jun</option>
                        <option>Julai</option>
                        <option>Ogos</option>
                        <option>September</option>
                        <option>Oktober</option>
                        <option>November</option>
                        <option>Disember</option>
                      </select>
                      <label for="fail_tahun"></label>
                      <select name="fail_tahun" size="Tahun" id="fail_tahun">
                        <option>Tahun</option>
                        <option>2014</option>
                        <option>2015</option>
                        <option>2016</option>
                        <option>2017</option>
                        <option>2018</option>
                      </select>
                      <label for="tarikhBuka"></label></td>
                </tr>
                <tr>
                  <td bgcolor="#FFFFFF" class="right"> <label><strong>Lokasi</strong></label></td>
                  <td>:</td>
                  <td>Rak Besi
                    <label>
                      <select name="fail_rakbesi" size="Seksyen" id="fail_rakbesi">
                        <option>Rak Besi</option>
                        <option>A</option>
                        <option>B</option>
                      </select>
                      Laci
                      <select name="fail_laci" size="Seksyen" id="fail_laci">
                        <option>Laci</option>
                        <option>A1</option>
                        <option>A2</option>
                        <option>A3</option>
                        <option>A4</option>
                        <option>B1</option>
                        <option>B2</option>
                        <option>B3</option>
                        <option>B4</option>
                      </select>
                      Baris
                      <select name="fail_baris" size="Seksyen" id="fail_baris">
                        <option>Baris</option>
                        <option>1</option>
                        <option>2</option>
                        <option>3</option>
                        <option>4</option>
                        <option>5</option>
                        <option>6</option>
                        <option>7</option>
                        <option>8</option>
                        <option>9</option>
                        <option>10</option>
                        <option>11</option>
                        <option>12</option>
                        <option>13</option>
                        <option>14</option>
                        <option>15</option>
                        <option>16</option>
                        <option>17</option>
                        <option>18</option>
                        <option>19</option>
                        <option>20</option>
                      </select>
                    </label></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><label>
              <div align="center">
                <input type="submit" name="submit" id="submit" value="Submit" />
              </div>
            </label></td>
          </tr>
      </table>
      </center>
        <p> </p>
    <center>
          <p>
            <label></label>
          <p> </p>
      </center>
      <center>
        <p><img src="nwUWE4K.jpg" width="1119" height="200" /></p>
      </center>
      <input type="hidden" name="MM_insert" value="form" />
      <input type="hidden" name="MM_update" value="form" />
    </form>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    ?>
    This for display page
    <?php require_once('Connections/pendaftaran.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      $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;
    $colname_Recordset1 = "-1";
    if (isset($_GET['fail_baris'])) {
      $colname_Recordset1 = $_GET['fail_baris'];
    mysql_select_db($database_pendaftaran, $pendaftaran);
    $query_Recordset1 = sprintf("SELECT * FROM maklumat_fail WHERE fail_baris = %s", GetSQLValueString($colname_Recordset1, "text"));
    $Recordset1 = mysql_query($query_Recordset1, $pendaftaran) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SISTEM PENDAFTARAN FAIL</title>
    <style type="text/css">
    .right {
      text-align: right;
    body {
      background-color: #6699CC;
    </style>
    </head>
    <body><form action="" method="get">
      <center>
        <p><img src="mps.png" width="1119" height="244" /></p>
      </center>
        <p><center>
        </p>
        <p> </p>
        <p> </p>
        <center>
          <table width="406" border="0">
            <tr>
              <td width="247"><h1>Fail telah berjaya didaftar!!</h1></td>
            </tr>
          </table>
          <p> </p>
          <table width="389" border="6">
            <tr>
              <td><table width="370" height="174" border="0">
                <tr>
                  <td width="129" class="right"><strong>No.Fail</strong></td>
                  <td width="8">:</td>
                  <td width="211"><?php echo $row_Recordset1['fail_no']; ?></td>
                </tr>
                <tr>
                  <td class="right"><strong>Tajuk Fail</strong></td>
                  <td>:</td>
                  <td><?php echo $row_Recordset1['fail_tajuk']; ?></td>
                </tr>
                <tr>
                  <td class="right"><strong>Seksyen</strong></td>
                  <td>:</td>
                  <td><?php echo $row_Recordset1['fail_seksyen']; ?></td>
                </tr>
                <tr>
                  <td class="right"><strong>Tarikh Fail Dibuka</strong></td>
                  <td>:</td>
                  <td><?php echo $row_Recordset1['fail_hari']; ?><?php echo $row_Recordset1['fail_bulan']; ?><?php echo $row_Recordset1['fail_tahun']; ?></td>
                </tr>
                <tr>
                  <td class="right"><strong>Lokasi</strong></td>
                  <td>:</td>
                  <td><?php echo $row_Recordset1['fail_rakbesi']; ?><?php echo $row_Recordset1['fail_laci']; ?><?php echo $row_Recordset1['fail_baris']; ?></td>
                </tr>
              </table></td>
            </tr>
          </table>
          <p><a href="test1.php">MENU</a></p>
          <p> </p>
          <p> </p>
      </center>
        <p> </p>
        <p><img src="nwUWE4K.jpg" width="1119" height="200" /></p>
    </form>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    ?>

  • Mysql issue plz

    Hi guys, I am trying to delete the user. my User gets deleted
    successfully.
    my userid is realted to table2 which has refernce of userid.
    I mean like i have 3 records and 2 records are related to
    userid 2.
    now i delete userid 2, i want that also in should reflect
    that thinh in table 2.
    I want it should update the table 2 userd value to null where
    userid was 2.
    i am trying to do it in 2 queries but it is now working.
    no err is tthrown,
    first query make update using in operator (i think my query
    structure is wrong)
    update userid
    set userid = null
    where userid in ('form.userid')
    then i make th delete query?
    DELETE FROM users
    WHERE
    userid = <cfqueryparam cfsqltype="cf_sql_numeric"
    value="#trim(arguments.userid)#">
    can u please tell me how this structure can be achieved.
    well i am no good at procedures. if this can be done through
    procedures, can anybody tell how can it done..
    Cheers

    If you had a normalized db, the userid would be a foreign key
    in the 2nd table. You would not be able to set it to null. You
    would have to delete the records. Plus, you would have to delete
    the related records before you delete the ones in the users table.
    An alternative approach is to delete nothing and simply
    de-activate the user.

  • JDeveloper/MySql: 'access denied'

    I'm trying to develop a web application using JDeveloper/MySql...
    My 'try-out' servlet ends here:
    conn = DriverManager.getConnection("jdbc:mysql://localhost/eyes?user=me&password=pwd");
    saying
    "Access denied for user 'me'@'localhost.localdomain' (using password: YES) 11045 228000"
    user me has been granted 'all' and the database eyes is accessible via the commandline.
    Any help is appreciated!

    This is MySQL issue not JDeveloper.
    Anyway this problem usually occurs when:
    1. there is not localhost or hostname in "user" table (mysql).
    So check whether user table contains two rows for user, one row for "localhost" and the second row for hostname or single row where "%" (any host) is in hostname column.
    Example:
    mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1810 to server version: 4.1.5-gamma-standard
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    mysql> \u mysql
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    Database changed
    mysql> select * from user where user = 'test2';
    | Host      | User  | Password         | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections |
    | localhost | test2 | 35a7d8163f9d93b2 | Y           | Y           | Y           | Y           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                |          |            |             |              |             0 |           0 |               0 |
    | machinename  | test2 | 35a7d8163f9d93b2 | Y           | Y           | Y           | Y           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                |          |            |             |              |             0 |           0 |               0 |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------2. common mistake is when user is created and privileges granted and administrator didn't flush hosts and privileges.
    So login as root and execute "flush hosts" and "flush privileges" commands.
    Example:
    mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1812 to server version: 4.1.5-gamma-standard
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    mysql> flush hosts;
    Query OK, 0 rows affected (0.00 sec)
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

  • MySQL/j Stored procedure on Server Failure? is it a bug? workaround?

    Hi all, with the release of SE 6 pending, I thought that this issue should be addressed. As I'm not sure if it's a bug or not, I decided to post in this forum to see if anybody has haad experience with it, has a workaround or any other information that could be usefull.
    The issue:
    MySQL v5.x offers stored procedures. the MySQL/j connector has the ability to call these procedures.
    If you run the stored procedure localy through Java, the stored procedure executes perfectly.
    Once deployed onto a server, and the stored procedures on the same server in a mysql database and "ALL PRIVILAGES" including "EXECUTE ROUTINE" are granted. The stored procedure fails to run.
    The error returned by the mysql/j connector is this :
    "Driver requires declaration of procedure to either contain a 'nbegin' or 'n' to follow argument declaration, or SELECT privilege on mysql.proc to parse column types."
    Here is a link to a MySQL forum about the issue:
    http://forums.mysql.com/read.php?98,67532,67532#msg-67532
    So it appears that it is a java issue.
    Is there a workaround?
    Has anybody successfully been able to use Java with MySQL stored Procedures?? (Pretty sad if we havn't)
    Any help on this topic would be greatly appreciated.
    cheers!

    Yes, I read through the threads, that is Why I cam here after posting back with MySQL trying all the suggeestions, I still can't find the thread from the MySQL/J developer, I did find the one from a MySQL developer though.
    We can't actually change permissions oursevles with our currecnt Servlet host.
    So they changed permissions for us:
    We checked to see if we had permissions, All permissions are granted for the localhost.
    currently not sure how to check them for the '%' assignment
    Our host also tried to drop the procedurees and create them again with the invoker command, but this was also to no avail.
    I was also sure that it was a MySQL issue, but was hoping someobody had another method of a workaround.
    It seems to be something to do with Java wanting the metadata for registering output variables.

Maybe you are looking for