Mysql Variable issue

I am passing a what will soon be my search variable into php from flash. The issue is when I need to search for something that needs to find a string value in quotes it fails.
Below is the like field variable declared in flash
LikeField = "Model_Profile.Gender = \'m\' ";
This is how I am capturing my like field in php.
$LikeField=mysql_real_escape_string($_POST['likefield']);
Below is my query
"SELECT count(*) AS Total FROM Model_Profile, Models  WHERE  Model_Profile.Model_ID = Models.Model_ID AND Models.Active = 1 AND {$LikeField}"
For some reason it just doesn't seem to like the single quotes on the m, but I need them there to execute. Tracing the flash variables passed it outputs this likefield=Model%5FProfile%2EGender%20%3D%20%27m%27
If I put the query in below it works fine, so I know it's not an issue with my query, misspelling etc.
"SELECT count(*) AS Total FROM Model_Profile, Models  WHERE  Model_Profile.Model_ID = Models.Model_ID AND Models.Active = 1 AND Model_Profile.Gender = 'm' "
If pass this value from flash I get a result
LikeField = "Model_Profile.Active = 1 ";
I am stump and don't know where the issue is at the moment.

It's difficult to give detailed advice without knowing exactly what's going on with this app and how it's going to be implemented.  Personally I like to use stored procedures with MySQL, it helps avoid SQL Injection attacks and it also eliminates the need to deal with quote literals when building a SQL string on the fly.
From the details you did post, it appears that your query alows the user to include or exclude the Gender feature.  How does it handle a situation in which the Gender is not set, so it's not equal to 'm' or 'f'?  Does it simply exclude that field from the WHERE clause?
One of the biggest limitations of MySQL stored procedures is that they don't allow for default values for their parameters.  But you can program around this in the PHP call by including a default value in your PHP code that would be overridden by input from the user in the search form.
If I were going to develop this search, I'd try to limit what I'm passing from Flash to PHP as much as possible.  I'd start with my stored procedure:
DELIMITER $$
DROP PROCEDURE IF EXISTS `db_name`.`sp_name` $$
CREATE DEFINER=`root`@`%` PROCDEURE `sp_name`(prmGender varchar(1))
BEGIN
     SELECT COUNT(*) AS Total FROM Model_Profile, Models  WHERE  Model_Profile.Model_ID = Models.Model_ID AND
Models.Active = 1 AND Model_Profile.Gender LIKE prmGender;
END $$
DELIMITER ;
In my PHP code that calls this stored procedure I'd create a variable for the gender selection and set it to '%' (the MySQL wildcard character) and override it if a specific gender was selected by the user.
This set up allows you to ignore the whole issue of dealing with quotation marks - simply pass the appropriate letter from Flash and pass it into the gender variable in PHP, which you would assign to the stored procedure call.  I hope this is somewhat helpful, if not please provide a bit more detail on your efforts and perhaps I can provide a better option.  Good luck! 

Similar Messages

  • MYSQL variable issues

    When creating a record set in a php document Dreamweaver
    seems to incorrectly wrap the order by variable in single quotes.
    For example at run time Dreamweaver returns the MySql statement
    select * from table order by 'var'
    This does not order the output. It should be
    select * from table order by var (no quotes on the var)
    Is there some fix for this or is anyone experiencing this
    issue?
    Thanks
    Wally

    There appears to be a glitch in the DW conversion of variable
    names when creating mysql queries in a php document.
    DW uses the following function to strip slashes and escape
    special characters when creating the query. Unfortunately this
    function also escapes the sort and order variables in the mysql
    statement - which places single quotes around the variables and
    makes them inoperable. This does not work.
    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;
    I was able to fix this problem by inserting an additional
    variable type into the function definition which then allows for
    the sort and order vars to be defined as 'other' and then passed
    without the enclosing single quotes yet still check for special
    characters. This works
    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;
    case "other":
    $theValue = ($theValue != "") ? $theValue : "NULL";
    break;
    return $theValue;

  • System PATH environment variable issue when user log off and log in or switch from admin to non-admin account

    Hi,
    Problem Description:
    After installing my new product version, when user does log-off and log in again into admin account
    or switch from admin account to non-admin account, PATH environment variable shows incorrect path of my product (previous product version’s path) using command prompt.
    It seems windows refresh issue during session changes (log off and log in / switch from Admin to
    Non-admin account).
    Why PATH environment variable is not refresh immediately after log off and log in again or Switch
    from admin to non-admin mode?. 
    Please see my thread for more details http://social.msdn.microsoft.com/Forums/vstudio/en-US/445ab42c-bdff-405a-8d53-558e1b6c7d34/path-environment-variable-issue-when-user-logoff-and-login-or-switch-from-admin-to-nonadmin?forum=windowsgeneraldevelopmentissues
    Also submitted bug for this in connect.microsoft.com portal.In that it has lots of information
    like problem statement, Reproduction steps and Expected Results.
    Bug ID: 871782
    Could you please any body help me for this?. your support will be appreciated.
    Thanks,
    Marichamy

    Why PATH environment variable is not refresh immediately after log off and log in again or Switch
    from admin to non-admin mode?. 
    I wouldn't have any expectation of what you are doing to work the way you expect.  E.g. why is the %ABC% being replaced at all?  There is some help about this ambiguous scenario in the cmd help...
    /V:ON Enable delayed environment variable expansion using ! as the
    delimiter. For example, /V:ON would allow !var! to expand the
    variable var at execution time. The var syntax expands variables
    at input time, which is quite a different thing when inside of a FOR
    loop.
    /V:OFF Disable delayed environment expansion.
    So, what's the setting for the /V:  switch that your users would be using?  Perhaps you should be using the ! instead of the % for your ABC variable?
    Oh.  There's more below where I found that...
    Delayed environment variable expansion is NOT enabled by default. You
    can enable or disable delayed environment variable expansion for a
    particular invocation of CMD.EXE with the /V:ON or /V:OFF switch. You
    can enable or disable delayed expansion for all invocations of CMD.EXE on a
    machine and/or user logon session by setting either or both of the
    following REG_DWORD values in the registry using REGEDIT.EXE:
    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\DelayedExpansion
    and/or
    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\DelayedExpansion
    to either 0x1 or 0x0. The user specific setting takes precedence over
    the machine setting. The command line switches take precedence over the
    registry settings.
    In a batch file the SETLOCAL ENABLEDELAYEDEXPANSION or DISABLEDELAYEDEXPANSION
    arguments takes precedence over the /V:ON or /V:OFF switch. See SETLOCAL /?
    for details.
    If delayed environment variable expansion is enabled, then the exclamation
    character can be used to substitute the value of an environment variable
    at execution time.
     So, I guess the essence of your "bug" will boil down to whether you
    need the feature to get the result you want and the
    truth of that first sentence but it certainly looks like a "can of worms" to me.   ; )
    HTH
    Robert Aldwinckle

  • Crystal Reports Server 2008 (Linux) - Crystal Reports/MySQL/ODBC Issue

    Hello,
    I have successfully installed CRS '08 on a Red Hat Enterprise Linux 4 server.  All services run fine.
    In the CMC, I have uploaded a Crystal Report that connect to a remote MySQL server. 
    I have installed the My SQL ODBC 3.51.11 and .12 Drivers as a System DSN.
    I have proven that the reports run fine in Crystal Reports 2008 directly against the remote MySQL DB server.
    (in Windows but with the same 3.51 ODBC Drivers)
    I have also proven that the database connection works okay from the CRS '08 Red Hat server to the remote MySQL DB server, when also creating a system DSN (using bash ./ODBCConfig)
    The problem is that when I log into the CMC or InfoView, and when I run the Crystal Reports from there, I get an error message:
    "Error in File <MyCrystalReport>: Failed to load database information"
    Is there something wrong with my specific Crystal Reports' Database Configuration? (Right click- Database Configuration)
    I see the driver was registered correctly in the /etc/odbc.ini file
    Am I supposed to set any other ODBC environment variables?
    Is there are firewall issue (port 3306 is already open)?
    In summary, the install was successful, and Crystal Reports can be uploaded and viewed via CMC or InfoView, but I cannot run the Crystal Reports against the database.
    Please advise, Thanks!

    Hi, I'm facing a similar problem. My ODBC DSN never works with CRS. Here are the details:<br><br>
    (1) I  installed the CRS 2008 in /opt/crystalreportsserver_2008_v1/ on a Linux platform. The CRS works well. I created a report with Crystal Reports 2008. This report directly connects to a MySQL server. After I published the report and manually modify its database configuration, I can browse it from InfoView. I'm sure that CRS, MySQL, and a report connecting to MySQL are all good.<br><br>
    (2) Then, I created an ODBC DSN on a Windows platform. This DSN connects to a MySQL server. I created another report with Crystal Reports using this DSN. The report can show the data within Crystal Reports.<br><br>
    (3) Then, I published the second report to CRS, but when I try to browse it, I always get such a message: Failed to open the connection.<br><br>
    I have configured the ODBC for CRS on the Linux server and I think the configuration is correct. This is how I do that: I edited the /opt/crystalreportsserver_2008_v1/bobje/odbc.ini file. In the file I added a data source called ods_telstar. Following is the content of the file:<br><br>
    [ODBC Data Sources]<br><
    CRSQLServerWP=DataDirect 5.3 SQLServer Wire Protocol Driver<br>
    CRSybaseWP=DataDirect 5.3 Sybase Wire Protocol Driver<br>
    CRText=DataDirect 5.3 Text Driver<br>
    %SYBASEDSN%=DataDirect 5.3 Sybase Wire Protocol Driver<br>
    ods_telstar = MySQL<br>
    <br>
    ... <br>
    <br>
    [ods_telstar]<br>
    Description     = ODS on telstar<br>
    Trace       = Off<br>
    TraceFile   = stderr<br>
    Driver      = /opt/crystalreportsserver_2008_v1/bobje/enterprise120/linux_x86/odbc/lib/libmyodbc5.so<br>
    SERVER      = xxx<br>
    USER        = xxx<br>
    PASSWORD    = xxx<br>
    PORT        = 3306<br>
    DATABASE    = ods<br>
    <br>
    In the middle I removed some data source definitions that are by default in the file. Note that I use "xxx" to replace the server name, user, and password. Such information is for internal use and I'm sure the original information is correct. The MySQL ODBC driver file has been put in the correct location. Correct access permissions has been assigned to the file.<br><br>
    I've tried to restart the CRS server, but still the report using ODBC DSN cannot be viewed.<br><br>
    The reason that we want to user ODBC DSN is that we may have many reports to publish. When we design the reports, we specify that they get data through an ODBC DSN such as ods_telstar. If we configure the same DSN on CRS, then we don't need manually modify each report's configuration after we publish them. If these reports are directly connecting to MySQL, then we have to manually modify each one's database configuration after we publish them.<br><br>
    I've no idea what's wrong with all the setup. Any suggestions and comments are appreciated!<br>

  • MySQL Connection Issues

    Hey,
    I am trying to use the MySQL database with my java application but I am experiencing some issues. I have downloaded the database as well as the appropriate drivers. I have also inserted in the classpath, the path to the connector (C:\Users\Nisha\Desktop\mysql-connector-java-5.1.14\mysql-connector-java-5.1.14-bin.jar). Nonetheless, when I run the application and try to insert a new entry into one of the tables in the database, I get the following error: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver. I am assuming that this is a basic problem and I would really appreciate it if someone can recommend a quick fix to it. It is really frustrating because at the present time the database is becoming a bottleneck for me and preventing me from continuing on with the rest of my project.
    Here's the code I have thus far (I just attempt to establish a connection and then add to the database):
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package homeworkorganizer;
    import java.sql.*;
    import java.util.Properties;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    * @author Nisha
    public class Database {
    private String ipAdress= "localhost";
         public void addCourse(String courseNumber,String courseCredit,String courseName) {
    try {
    Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException ex) {
    Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
    String server = "jdbc:mysql://"+ipAdress+"/";
    String dbName = "courses";
    String url = server + dbName;
    Properties props = new Properties();
    props.setProperty("user", "root");
    props.setProperty("password", "kish");
    Connection conn;
    Statement st;
    String columns = "course_number, no_credits, course_name";
    String sqlInsrt = "insert into Users (" + columns + ") values ";
    try {
    conn = DriverManager.getConnection(url, props);
    st = conn.createStatement();
    //Add user to the database
    String userInfo= " ('"+courseNumber+"','"+courseCredit+"','"+courseName+"')";
    //Use executeUpdate when our statement will change the database.
    st.executeUpdate(sqlInsrt + userInfo);
    } catch (SQLException ex) {
    Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
    }

    user13523574 wrote:
    This is how I set the class path. I went to control panel (btw I am running windows 7), I clicked on system and security, I clicked on system, I clicked on advanced system setting, I clicked on environment variables, I selected the classpath variable under system variables and clicked on edit, and finally I put a semi-colon (to seperate the path that was there before) and I pasted the path to the connector.1. You can set the class path via a command line option. That will override whatever is in the env var CLASSPATH.
    2. Recent experiences of mine suggest that windows 7 might have changed the way env vars are handled versus older windows. Certainly possible since the shell was re-written. On some occasions I have found it necessary to reboot to get it to take. Although a re-login might have worked as well. That said it is was always necessary to restart the console window or application (such as an IDE) for env vars to take. But for an IDE you must set the class path in the IDE not the env anyways.

  • Front Panel Mass Binding Project Variables Issue

    Hello -
    When attempting to bind controls to shared variables through the front panel mass binding option, there is an issue where you can not seem to bind a "project item" to the control. The method of binding I am using is to export a text list of control names, urls, mode, and function to a text editor utilizing the front panel binding mass configuration options.  The text editor shows, in the fourth column, a "0" for no function, a "1" for network item, and a "2" for project item. when attempting to import the list back into the front panel binding mass configuration, all "2" indications become "1", as all items are treated as network. Thus one can not effectively bind to a project shared variable item.
    The binding works fine manually by means of utilizing the properties selection of the control, but it is difficult to do this for 821 controls, as in my application.
    My application is based on a OPC served group of 821 variables which are linked to controls and indicators through the shared variable representation for each item created in the multiple variable editor.
    Does anyone have a work around for this issue, as it is a showstopper right now, ie, you can not effectively bind a large quantity of controls or indicators to project located shared variables as required.
    The rationale behind utilizing project located variables instead of network located variables is to reduce the amount of calls to the OPC server which was causnig a large latency in the refresh of the 821 items. With the items defined as shared variables within the project, a single call is issued, which has tremendously sped up the refresh cycle for the list of variables.
    Thank you in advance for your insight in this matter,
    John DeCroos

    Hello Brian A.,
    In response to you comment --
    "in 2006, and John did not follow up with any more information for Efosa"
     -- a great deal of information was provided to NI (Efosa and many, many others, up to the product manager for the DCS module). I have never heard back on a fix for this bug for the identified version of LabVIEW. The reply by Efosa here was well after we had shipped our product -- (please see date + Efosa's apology) -- we had found our own solution as is identified in the original post.
    My solution was, as is also indicated in my original post, to manually bind each variable. This was unbelievably time consuming, but was all I had.
    The version of software I am now working on uses far less variables, manually bound to avoid the multiple binding issue we had in the past.
    I have checked the mass binding function in LV 8.5.1, it works fine now. I guess it would have been nice to have had a reply that the bug had been resolved ---- would have helped me out a bit.
    Thank you,
    John DeCroos

  • Presentation Variable issue in OBIEE 11g

    Hi,
    I have 2 reports, report 1 and report 2
    When i drill down on report 1 column 'Number of id's' will open the details report of Id's report 2
    I am using a Presentation variable in report 2 filters (detail report) which is generated in Main report dasnbord prompt.
    They have separate star schema.
    Main report(reprot1) using Aggregated table.
    Sub report(report2) using detail table.
    Problem:
    After upgradation from OBIEE 10.1.3.4 to OBIEE 11.1.1.5,(Unix server) The presentation variable value is not getting passed to the detail report. This is working completely fine in OBIEE 10g.
    Is there any BUG in OBIEE 11g wrt presentation variable or do we want to change the configuration?
    Thanks,
    Satheesh

    Hi,
    Not sure about the behaviour in 11g, but we faced a similar issue in 10g while passing the presentation varaibles to detail report where main/detail report where coming from different subject areas. The behavior was a little unpredictable. To overcome this, we tried using request variable instead of presentation variable and it worked for us.
    You can give it a try by doing the same and see if it works for you.
    Thanks

  • [CLOSED] Weird mysql/php issue.

    Hi,
    I am running an ArchLinux as my Server. It's a fresh install. I just configured nginx as my Webserver and then configured MySQL. I wanted to use phpMyAdmin as a manager. I installed it via wget and it worked fine. But all of a sudden it would not let me log in anymore. The log in screen just keeps on popping up, without any errors or anything. It tried reinstalling phpMyAdmin, I also tried the alternative chive. In chive I get the error "CDbConnection failed to open the DB connection." I really am at a loss here, has anyone else encountered a similar issue and can point me in the right direction?
    Disclaimer: Please excuse my possibly poor english, as it is not my native language, also please excuse any questions that may sound noob-like, because I am quite new to Arch.
    Last edited by oengelha (2012-12-15 17:40:09)

    config.inc.php should be in
    /etc/webapps/phpmyadmin
    but the installation symlinks that file to
    /usr/share/webapps/phpMyAdmin
    where the installation is.
    You'll have to add this directive in open_basedir @
    /etc/php/:/usr/share/webapps/
    Also might need an alias in
    /etc/nginx/nginx.conf
    What I do is symlink
    ln -s /usr/share/webapps /srv/http/.webapps
    /srv/http being my www directory I can visit mysite.com/.webapps/phpMyAdmin to access.
    This can be a security issue, maybe allow only local access or use another mean of accessing the installation.
    Also symlinking just the installation directory to a hidden directory precursed with '.' won't float, like mysite.com/.phpmyadmin
    Last edited by ackt1c (2012-12-16 17:44:01)

  • Session Variables Issue

    Hi, I'm putting together my first shop.
    I have built and tested on
    IE6, then upgraded to IE7 & Firefox 2 XP PRo
    IE7 XP Home
    All is well and the site works fine on the XP machines. Each
    client / Browser retaining its own shopping cart information.
    Allowing for different users to select items.
    A friend has given me 2 old machines to build a testing
    workstation for browser compatability. These are both IE6 Win98
    machnes although 1 will be changing. Despite a few layout issues
    all seemed fine. Until I added things to the shopping basket.
    It seems IE6 now (at least certainly under Win98) cannot
    persist the session data across pages. I'm not sure if this could
    be related to how they are conntected together (using a 10/100
    switch) or if there is a setting in IE6 which would prevent this
    (not sure how this would be the case) or, more worrying, am I doing
    something wrong. My session/cart information is based heavily upon
    the CFMX7 Web Application Contruction Kit example. So I'm not sure
    what I could have done wrong.
    Here is the code below. Its using NAte Wiess' own CFC and
    works perfectly in IE7 and I Think IE6 on XP
    Any suggestions.

    or if there is a setting in IE6 which would prevent this (not
    sure how
    this would be the case)
    This is a very likely concern to investigate. For sessions to
    work
    correctly, by default, cookies must be enabled in the
    browser. If the
    browser has been configured to not accept cookies, then every
    request
    made from that browser creates a new session on the server.
    If you want your sessions to work without cookies you can
    pass the CFID
    and CFTOKEN values that define an individual session through
    URL
    variables. This does take some work to make sure every link,
    form and
    any other interaction that generates a new request to the web
    server
    pass these values.
    There are aides in ColdFusion to help you with this process,
    check the
    documentation for all the fun details.

  • Variable issue, not declaring

    Hi,
    i've an issue on Production Environment. When i use a variable (both declaring or setting) i retrieve an error.
    "com.sunopsis.core.SnpsInexistantObjectException: SnpSessTaskLog.getObjectByIdent : SnpSessTaskLog does not exist"
    I've checked agent and connection to repo. Any idea?
    Thanks in adavance

    Hi,
    For the record, I just had the same issue and in my case and purging the logs in the Operator was enough to solve the problem.
    Regards,
    Jerome Fr

  • Variable issue for Alternate Unit of Measure

    Hello Experts
    I have implemented the soultion for reporting data in Alternate Unit of measure using the "How to..." guide provided at https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b7b2aa90-0201-0010-a480-a755eeb82b6f
    This solution involves creating a variable which prompts the user to enter the required unit of measure.
    However I have a situation where I would like to create variable which is not input-ready and has a fixed value assigned to it without prompting the user. Moreover, I cannot modify the already existing input-ready variable as it is used in other Queries.
    Does this involves creating a new user exit or modifying the existing user exit. If yes then can you please tell me how this can be done.
    Thanks
    Rishi

    Hi Rishi,
    You can follow any one the below procedure for solve your issue.
    1. You can change the variable by removing the check box "Ready to input". But you mentioned that you used that variable in other queries also. So, I am not suggesting this.
    2. You create a new variable same as the existing variable but with out selecting "Ready to Input" check box. Now when the user run the query, that variable will not be seen to the user. Now, we will see the customer exit, you assign new variable value to existing variable, before that you have to write a condition for checking the query name. If you are running the query which have the new variable then assign the variable value to old variable. This will solve your question.
    I hope you understood this procedure. If you have any doubts let me know.
    Regards,
    Patil.

  • Variable issue in crystal report

    Hi Experts,
    I hope you are doing the good job and i developed the BEX report which is developed 3 variables , one of the variable is in navgational attribute and remain 2 attributes in char which is working fine  and we developed the crystal report on top of bex query  its working fine after that  as per requirement i changed navgational attribute and variable .Now the crystal report is not showing the variable prompt which i build on Nav attribute.So plz pass your inputs on this issue.
    Regards
    RK

    Dear Kumar,
    Thank you very much for you reply and we using the below mentioed details.
    Exact version:4.1,support pack/service pack:sp3,patch level of CR:0
    SAP BI:7.3
    Regards
    RK

  • MySQL Driver issue

    Hi,
    I've been trying to connect to a MySQL database from Java. I have no problems from PHP so the db is fine, but suspect this is a driver issue.
    I was using the Netbeans IDE but have now switched to a basic texteditor and command line to try understanding whats going on:
    $ javac *.java -cp <other-libs-here>:~/Java/libs/mysql-connector-java-5.1.6-bin/mysql-connector-java-5.1.6-bin.jar
    $ java Main
    Failed to get connection
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:169)
         at MyDBConnection.init(MyDBConnection.java:38)
         at MyDBConnection.query(MyDBConnection.java:23)
         at Processor.index(Processor.java:31)
         at Main.main(Main.java:32)
    Exception in thread "main" java.lang.NullPointerException
         at MyDBConnection.query(MyDBConnection.java:25)
         at Processor.index(Processor.java:31)
         at Main.main(Main.java:32)Any help you can offer on this would be greatly appreciated.

    OK I thought one classpath was the same as another. It seems that the system classpath is something different.
    Running: CLASSPATH=~/Java/libs/mysql-connector-java-5.1.6-bin/mysql-connector-java-5.1.6-bin.jar;export CLASSPATHin bash fixed this problems.
    But I really want to get it working in NetBeans, does anyone have any ideas?

  • MySQL & PHP issues since upgrade

    Little bit of background: I ran an arch server about two years ago, basically a personal web server (for about a year).  Had apache, mysql and php running nicely on it using the basic configurations with some minor changes.
    Now, present day.  I have recently installed Arch again and once the upgrades were announced, I held off on installing the LAMP applications.  So, Friday I installed them (as oppsed to upgrading), and thought I had them all working fine.  Apache was running, mysql was running (command line access was working well with one exception, more on that later), and php was being parsed.  When I tried to pull data out of a database, i was getting "call to undeclared function mysql_pconnect()."  I googled the error and searched the Arch forums, and everything said to make sure php was compiled with the '--with-mysql' option.  I checked that using phpinfo(), and indeed it was, but it was '--with-mysql=/shared', /usr' (or something similar).  What I ended up doing was removing the arch package and recompiling php myself using '--with-mysql' (no arguments) and it works beautifully.  So, basically, is the arch configuration for php correct?
    Also, issue number two, I have created a non-root user in mysql, but when i try to log in i receive access denied for 'user@localhost' (using password: YES).  Did i miss a setting that won't allow me to log in as anyone but root?
    Thanks in advance. 

    simple, edit your php.ini like so:
    BEFORE:
    1250:;extension=mysql.so
    AFTER
    1250:extension=mysql.so
    no need to recompile php.
    ps: "grep -n mysql.so /etc/php.ini"

  • FYI: date.timezine and mysql.sock issues resolved!

    For anyone who might run into the same issues with your website(s) like I did. Here are a couple things you may want to look into if you are having these issues.
    The cause of these issues is due to snow leopard server using PHP 5.3.
    *_ISSUE #1_*: PHP throwing the following errors:
    +Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the datedefault_timezoneset() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /path/to/my/www/wp-includes/functions.php on line 35+
    +Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the datedefault_timezoneset() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /path/to/my/www/wp-includes/functions.php on line 43+
    +Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the datedefault_timezoneset() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /path/to/my/www/wp-includes/functions.php on line 35+
    +Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the datedefault_timezoneset() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /path/to/my/www/wp-includes/functions.php on line 43+
    *_FIX FOR ISSUE #1:_* Set "date.timezone = "YOURTIMEZONE"" value in your /etc/php.ini. Here is the list of timezones http://nl3.php.net/manual/en/timezones.america.php. Then restart web service in server admin.
    *_ISSUE #2_:* PHP throwing error "+Warning: mysql_connect() [function.mysql-connect]: [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock)+"
    *_FIX FOR ISSUE #2:_* Set "mysql.default_socket" value in your /etc/php.ini to "mysql.default_socket = /var/mysql/mysql.sock". Then restart web service in server admin

    Didn't resolve it for me using 10.6.1 server. I tried adding each of the following in php.ini (not all at the same time, one by one...). Restarted web service after each change (even though you don't really need to).
    [Date]
    ; Defines the default timezone used by the date functions
    ; http://php.net/date.timezone
    date.timezone = 'America/Los_Angeles'
    date.timezone = 'PDT'
    datedefault_timezone_set('America/LosAngeles')
    datedefault_timezone_set("America/LosAngeles")
    Same error in the logs with any of these enabled:
    [Sat Sep 19 14:33:32 2009] [error] [client xxx.xxx.xxx.xx] PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the datedefault_timezoneset() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in /usr/share/squirrelmail/functions/date.php on line 289, referer: https://icecrown.hri.uci.edu/webmail/src/webmail.php
    I'm not running any PHP other than webmail anyway and it seems to be working fine (Besides not being able to get vacation replies working) but I haven't done a lot of sending / receiving since this is a test box.

Maybe you are looking for