Help changing to prepared statements for mysqli

I am trying to change previously working php pages from mysql to mysqli using prepared statements.
I am having problems with an error message.
Basically the page I have just changed produces a set of database results depending on list menu and check box criteria from user input. I run 2 queries, one to find the total number of records, and the other to retrieve the required subset for pagination. All works fine. However if there are no actual results found from the requested input my php script then uses an includes file which basically runs the same 2 queries but with the user criteria narrowed down so that similar options are presented to the user. This is where my problem lies, for some unknown to me reason the second set of queries is producing no results and an error:
'Attempt to read a row while there is no result set associated with the statement'
If I run the second set of queries without running the first set then the second set works fine so I know that it is not the statements themselves but something in my new code. How can the first set of queries be affecting the results of the second set?
Here is the code below which produces the first 2 queries that work, and below it the same code for the second 2 queries (which is from an 'Includes' file and is the same code exactly except the EXPECTED parameters $expected have been narrowed down in the expected array and list of params for binding).
//list of possible field input by user
$expected = array('location'   => 'text',
                  'type' => 'text',
                  'beds' => 'text',
                  'price' => 'text',
'nbuild'     => 'int',
'resale'     => 'int',
'coastal'    => 'int',
'seaview'    => 'int',
'rural'      => 'int',
'golf'       => 'int',
'ppool'      => 'int',
'comp'       => 'int',                            
'garden'     => 'int',
'terrace'    => 'int',
'aircon'     => 'int',
'heating'    => 'int',
'garage'     => 'int',
'telephone'  => 'int',
'furnished'  => 'int',
'internet'   => 'int',
'dpaid'      => 'int',
'propid'     => 'text');
define('SHOWMAX', 10);
// prepare SQL to get total records
$getTotal = 'SELECT COUNT(*) FROM detailstable JOIN newloctable ON detailstable.location=newloctable.newlocid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid JOIN photossale ON detailstable.detailsid=photossale.propsaleid ';
// Set a flag to indicate whether the query has a WHERE clause
$where = false;
// Loop through the associatiave array of expected search values
foreach ($expected as $var => $type) {
  if (isset($_GET[$var])) {
    $value = trim(urldecode($_GET[$var]));
    if (!empty($value)) {
      // Check if the value begins with > or <
      // If so, use it as the operator, and extract the value
      if ($value[0] == '>' || $value[0] == '<') {
        $operator = $value[0];
        $value = ltrim(substr($value, 1));
      } elseif (strtolower($type) != 'like') {
        $operator = '=';
      // Check if the WHERE clause has been added yet
      if ($where) {
        $getTotal .= ' AND ';
      } else {
        $getTotal .= ' WHERE ';
        $where = true;
      // Build the SQL query using the right operator and data type
       $type = strtolower($type);
      switch($type) {
        case 'like':
          $getTotal .= "`$var` LIKE ? ";
          break;
        case 'int':
        case 'double':
        case 'date':
          $getTotal .= "`$var` $operator ? ";
          break;
        default:
        $getTotal .= "`$var` = ? ";
$getTotal .= ' ORDER BY ABS(detailstable.trueprice), bedtable.number, detailstable.propid ASC';
$stmt = $conn->stmt_init();
if ($stmt->prepare($getTotal)) {
$params = array($_GET['location'], $_GET['type'], $_GET['beds'], $_GET['price'], $_GET['nbuild'], $_GET['resale'], $_GET['coastal'], $_GET['seaview'], $_GET['rural'], $_GET['golf'], $_GET['ppool'], $_GET['comp'], $_GET['garden'], $_GET['terrace'],
$_GET['aircon'], $_GET['heating'], $_GET['garage'], $_GET['telephone'], $_GET['furnished'], $_GET['internet'], $_GET['dpaid'], $_GET['propid']);
$params = array_filter($params);
$params = array_values($params);
if (!empty($params)) {
            $types = '';
            foreach($params as $param) {
                // set param type
                if (is_string($param)) {
                    $types .= 's';  // strings
                } else if (is_int($param)) {
                    $types .= 'i';  // integer
                } else if (is_float($param)) {
                    $types .= 'd';  // double
                } else {
                    $types .= 'b';  // default: blob and unknown types
            $bind_names[] = $types;
            for ($i=0; $i<count($params);$i++) {
                $bind_name = 'bind' . $i;      
                $$bind_name = $params[$i];     
$bind_names[] = &$$bind_name;  
call_user_func_array(array(&$stmt,'bind_param'),$bind_names);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($total);
$stmt->fetch();
// sort paging
$totalRecords = $total;
$stmt->free_result();
$stmt->close();
// check that there is at least 1 result and if there is do the second part of the search
// if there is no result then I skip this second bit of code
if($totalRecords > '0') {
// check current page
if (isset($_GET['curPage'])) {
$curPage = $_GET['curPage'];
} else {
$curPage = 0;
// calculate the start row of the subset
$startRow = $curPage * SHOWMAX;        
$sql = "SELECT DISTINCT detailsid, trueprice, reduced, offers, `desc`, `propid`, `bathrooms`, `location`, `type`, `price`, `beds`, photossale.photo1, newloctable.newloc,   typetable.style, bedtable.`number` FROM detailstable JOIN newloctable ON detailstable.location=newloctable.newlocid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid JOIN photossale ON detailstable.detailsid=photossale.propsaleid ";
// Set a flag to indicate whether the query has a WHERE clause
$where = false;
// Loop through the associatiave array of expected search values
foreach ($expected as $var => $type) {
  if (isset($_GET[$var])) {
    $value = trim(urldecode($_GET[$var]));
    if (!empty($value)) {
      // Check if the value begins with > or <
      // If so, use it as the operator, and extract the value
      if ($value[0] == '>' || $value[0] == '<') {
        $operator = $value[0];
        $value = ltrim(substr($value, 1));
      } elseif (strtolower($type) != 'like') {
        $operator = '=';
      // Check if the WHERE clause has been added yet
      if ($where) {
        $sql .= ' AND ';
      } else {
        $sql .= ' WHERE ';
        $where = true;
      // Build the SQL query using the right operator and data type
       $type = strtolower($type);
      switch($type) {
        case 'like':
          $sql .= "`$var` LIKE  ? ";
          break;
        case 'int':
        case 'double':
        case 'date':
          $sql .= "`$var` $operator ? ";
          break;
        default:
        $sql .= "`$var` = ? ";
$sql .= " ORDER BY ABS(detailstable.trueprice), bedtable.number, detailstable.propid ASC LIMIT $startRow," . SHOWMAX;
$stmt = $conn->stmt_init();
if ($stmt->prepare($sql)) {
$nextparams = $params;
if (!empty($nextparams)) {
            $nexttypes = '';
foreach($nextparams as $nextparam) {
                // set param type
                if (is_string($nextparam)) {
$nexttypes .= 's';  // strings
                } else if (is_int($nextparam)) {
$nexttypes .= 'i';  // integer
                } else if (is_float($nextparam)) {
$nexttypes .= 'd';  // double
                } else {
$nexttypes .= 'b';  // default: blob and unknown types
            $newbind_names[] = $nexttypes;
            for ($i=0; $i<count($nextparams);$i++) {
$newbind_name = 'bind' . $i;      
$$newbind_name = $nextparams[$i];
$newbind_names[] = &$$newbind_name;
call_user_func_array(array(&$stmt,'bind_param'),$newbind_names);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($detailsid, $trueprice, $reduced, $offers, $desc, $propid, $bathrooms, $location, $type, $price, $beds, $photo1, $newloc, $style, $bednumber);
$numRows = $stmt->num_rows;
If a result was found in the part that checks the numbers of records then the second query is run and displayed using : while ($stmt->fetch()) { ...... to display the results and then I use $stmt->free_result();
$stmt->close();
All fine no problems.
If the first query did not find a result then the second query is skipped and instead the script then uses a php includes file with exactly the same script as above except the expected params are narrowed as below: THIS IS WHEN I GET NO RESULTS – when I do expect to get a result) AND AN ERROR OF :
Attempt to read a row while there is no result set associated with the statement.
Yet if I run the includes file and skip the whole of the above code the code in the includes file find the result no problem. Anyway code below:
$expected = array('location'   => 'text',
                  'type' => 'text',
                  'beds' => 'text',
                  'price' => 'text',
'dpaid'      => 'int',
'propid'     => 'text');
define('SHOWMAX', 10);
// prepare SQL to get total records
$getTotal = 'SELECT COUNT(*) FROM detailstable JOIN newloctable ON detailstable.location=newloctable.newlocid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid JOIN photossale ON detailstable.detailsid=photossale.propsaleid ';
// Set a flag to indicate whether the query has a WHERE clause
$where = false;
// Loop through the associatiave array of expected search values
foreach ($expected as $var => $type) {
  if (isset($_GET[$var])) {
    $value = trim(urldecode($_GET[$var]));
    if (!empty($value)) {
      // Check if the value begins with > or <
      // If so, use it as the operator, and extract the value
      if ($value[0] == '>' || $value[0] == '<') {
        $operator = $value[0];
        $value = ltrim(substr($value, 1));
      } elseif (strtolower($type) != 'like') {
        $operator = '=';
      // Check if the WHERE clause has been added yet
      if ($where) {
        $getTotal .= ' AND ';
      } else {
        $getTotal .= ' WHERE ';
        $where = true;
      // Build the SQL query using the right operator and data type
       $type = strtolower($type);
      switch($type) {
        case 'like':
          $getTotal .= "`$var` LIKE ? ";
          break;
        case 'int':
        case 'double':
        case 'date':
          $getTotal .= "`$var` $operator ? ";
          break;
        default:
        $getTotal .= "`$var` = ? ";
$getTotal .= ' ORDER BY ABS(detailstable.trueprice), bedtable.number, detailstable.propid ASC';
$stmt = $conn->stmt_init();
if ($stmt->prepare($getTotal)) {
$params = array($_GET['location'], $_GET['type'], $_GET['beds'], $_GET['price'], $_GET['dpaid'], $_GET['propid']);
$params = array_filter($params);
$params = array_values($params);
if (!empty($params)) {
            $types = '';
            foreach($params as $param) {
                // set param type
                if (is_string($param)) {
                    $types .= 's';  // strings
                } else if (is_int($param)) {
                    $types .= 'i';  // integer
                } else if (is_float($param)) {
                    $types .= 'd';  // double
                } else {
                    $types .= 'b';  // default: blob and unknown types
            $bind_names[] = $types;
            for ($i=0; $i<count($params);$i++) {
                $bind_name = 'bind' . $i;      
                $$bind_name = $params[$i];     
$bind_names[] = &$$bind_name;  
call_user_func_array(array(&$stmt,'bind_param'),$bind_names);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($total);
$stmt->fetch();
// sort paging
$totalRecords2 = $total;
echo $stmt->error;
$stmt->free_result();
$stmt->close();
// there is a result get the subset
if($totalRecords2 > '0') {
// check current page
if (isset($_GET['curPage'])) {
$curPage = $_GET['curPage'];
} else {
$curPage = 0;
// calculate the start row of the subset
$startRow = $curPage * SHOWMAX;        
$sql = "SELECT DISTINCT detailsid, trueprice, reduced, offers, `desc`, `propid`, `bathrooms`, `location`, `type`, `price`, `beds`, photossale.photo1, newloctable.newloc,   typetable.style, bedtable.`number` FROM detailstable JOIN newloctable ON detailstable.location=newloctable.newlocid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid JOIN photossale ON detailstable.detailsid=photossale.propsaleid ";
// Set a flag to indicate whether the query has a WHERE clause
$where = false;
// Loop through the associatiave array of expected search values
foreach ($expected as $var => $type) {
  if (isset($_GET[$var])) {
    $value = trim(urldecode($_GET[$var]));
    if (!empty($value)) {
      // Check if the value begins with > or <
      // If so, use it as the operator, and extract the value
      if ($value[0] == '>' || $value[0] == '<') {
        $operator = $value[0];
        $value = ltrim(substr($value, 1));
      } elseif (strtolower($type) != 'like') {
        $operator = '=';
      // Check if the WHERE clause has been added yet
      if ($where) {
        $sql .= ' AND ';
      } else {
        $sql .= ' WHERE ';
        $where = true;
      // Build the SQL query using the right operator and data type
       $type = strtolower($type);
      switch($type) {
        case 'like':
          $sql .= "`$var` LIKE  ? ";
          break;
        case 'int':
        case 'double':
        case 'date':
          $sql .= "`$var` $operator ? ";
          break;
        default:
        $sql .= "`$var` = ? ";
$sql .= " ORDER BY ABS(detailstable.trueprice), bedtable.number, detailstable.propid ASC LIMIT $startRow," . SHOWMAX;
$stmt = $conn->stmt_init();
if ($stmt->prepare($sql)) {
$nextparams = $params;
if (!empty($nextparams)) {
            $nexttypes = '';
foreach($nextparams as $nextparam) {
                // set param type
                if (is_string($nextparam)) {
$nexttypes .= 's';  // strings
                } else if (is_int($nextparam)) {
$nexttypes .= 'i';  // integer
                } else if (is_float($nextparam)) {
$nexttypes .= 'd';  // double
                } else {
$nexttypes .= 'b';  // default: blob and unknown types
            $newbind_names[] = $nexttypes;
            for ($i=0; $i<count($nextparams);$i++) {
$newbind_name = 'bind' . $i;      
$$newbind_name = $nextparams[$i];
$newbind_names[] = &$$newbind_name;
call_user_func_array(array(&$stmt,'bind_param'),$newbind_names);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($detailsid, $trueprice, $reduced, $offers, $desc, $propid, $bathrooms, $location, $type, $price, $beds, $photo1, $newloc, $style, $bednumber);
$numRows = $stmt->num_rows;
Again here I would then display the results before closing and freeing the stmt or display a message to say there were no results found from the criteria. But instead I get the error message and echoing the value of $totalRecords2 is empty.
I have been pulling my hair out for days and days over this and as it is one of the first pages I am converting from mysql to mysqli I wonder if I am missing something very obvious to someone with more experience with the code.  I will be very grateful for any help, thank you in advance.

You have intel graphics, that means the graphics cannot be upgraded.
Welcome to the Toshiba user forums.
For those of you who do not know what a user forum is, it is a community of users who volunteer time to help other users. Anyone can participate. It's 100% voluntary.
Being super active is never a requirement

Similar Messages

  • How to use prepared statement - For Everyone Help

    public String count()
    int count = 0;
    String fetchsize = "";
    try
    Connection conn = getOADBTransaction().getJdbcConnection();
    Statement statement = conn.createStatement();
    String Query = "select count(*) count from fnd_lookups where lookup_type like 'SAPE_BILL_TO_SHIP_TO_UPDATE'";
    ResultSet resultset = statement.executeQuery(Query);
    while (resultset.next())
    count = (int)resultset.getInt("count");
    fetchsize = ""+count;
    catch(Exception e)
    return fetchsize;
    }

    Hi,
    we can use prepare statement in Co....
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    try
    PreparedStatement prpdStmt1 = am.getOADBTransaction().getJdbcConnection().prepareStatement("select full_name from per_all_people_f where person_id='"+empid+"' ");
    ResultSet rs=prpdStmt1.executeQuery(); //Cursor fetch row
    while(rs.next())
    empname=rs.getString(1);
    catch(Exception e)
    System.out.println("Exception is"+e.getMessage());
    t1.setValue(pageContext,empname);
    Thanks
    nani

  • Can any body Help me to prepare statement

    I want to provide dynamic table name for preparestatement that i just pass table name every time and it pass me total number in that table.
    I create this prepare statement
    PreparedStatement prepStmt=conn_.prepareStatement("select count(*) Total from ?");
    prepStmt.setString(1,"new");
    but it is giving error
    [JDBC SQL Server Driver] Line 1: Incorrect syntax near 'new'.
    Any body can help me??
    I will appreciate.

    In PreparedStatement, the setString method adds quotes at the start and at the end of your String.
    So your request :
    select count(*) Total from ?
    is interpreted :
    select count(*) Total from 'new'
    One possible solution is to pass your tablename parameter directly in the precompiled request :
    String myTableName = "new";
    PreparedStatement prepStmt=conn_.prepareStatement("select count(*) Total from "+myTableName);
    In your database, you will store as many precompiled Statement as you will call this method with different parameters.
    Hope it helps !

  • I need help changing my iTunes syncing for iPad and iPhone when I connect Ed my iPhone to computer it has a different name from my laptop so I can't sync iPhone music from iPad. Please help!!!

    I Need help changing my name on lipad and iPhone to sync. I have two different name1 is from my laptop and the other is from iPad ,so I can't sync iTunes. Please help!!!!!!

    Plug the iphone in and go to the music tab in the iphone,not your itunes library.There will be a button in the borrom right that says autofill. Click that and it should thransfer all your music. It worked for me,and i had the same problem.

  • Insert statement for MySQL conflict

    This works for MS SQL but not for MySql. can anyone tell me
    why and how it can be fixed?
    <cfquery ...>
    INSERT INTO ShippingRegions
    (ShippingRegionName,Multiplier,StoreID) VALUES ('Europe1',1,1);
    INSERT INTO ShippingRegions (ShippingRegionName,Multiplier,StoreID)
    VALUES ('Europe2',2,1); INSERT INTO ShippingRegions
    (ShippingRegionName,Multiplier,StoreID) VALUES ('Europe3',3,1);
    </cfquery>

    quote:
    Originally posted by:
    Ad Bec
    Hi,
    The first one is not an option becuase i would like to make
    mys software application scale in shared hosting environments. I
    also need Single Script to Rule Them All i.e. it must work for MS
    SQL as well as for MySql. With the second proposal you mentioned
    work with MS SQL? How about Oracle (althouth Oracle support is not
    a must at this point).
    Thanks
    Do a loop and run each insert inside a separate cfquery tag.

  • Help with an If Statement for a Message Dialog

    Hello all! I need help yet once again! I would prefer hints and nudges rather then the answer please, as this is for a homework assignment. Okay I am supposed to write a program that has 3 text boxes to enter a number between 0 and 255 (for red green and blue) and then the user should push the show button and the background color should change, which I have all working! But I am supposed to have a " gracefully handle the situation where the user enters an invalid color value (any number less than zero or greater than 255)" and I have the if statement written, but for some reason, whenever I hit the show button it always pops up that window, no matter what the user types in. So I need help figuring out how to make it stop popping up all of the time! Here is the code: Any other ideas on how to make the code better would be much appreciated!!! Thanks in advance!
    import java.awt.GridLayout;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JTextField;
    import javax.swing.JPanel;
    import javax.swing.BorderFactory;
    public class ColorEditor extends JPanel {
         private JLabel labelRed;
         private JLabel labelGreen;
         private JLabel labelBlue;
         private JTextField textFieldRed;
         private JTextField textFieldGreen;
         private JTextField textFieldBlue;
         private JButton showButton;
         private JButton exitButton;
         private JOptionPane optionPane;
         public ColorEditor()
              super(new BorderLayout());
              labelRed = new JLabel("red: ");
              textFieldRed = new JTextField(5);
              labelGreen = new JLabel("green: ");
              textFieldGreen = new JTextField(5);
              labelBlue = new JLabel("blue: ");
              textFieldBlue = new JTextField(5);
              showButton = new JButton("show");
              exitButton = new JButton("exit");
              JPanel labelPane = new JPanel(new GridLayout(0,1));
              labelPane.add(labelRed);
              labelPane.add(labelGreen);
              labelPane.add(labelBlue);
              labelPane.add(showButton);
              JPanel fieldPane = new JPanel( new GridLayout(0,1));
              fieldPane.add(textFieldRed);
              fieldPane.add(textFieldGreen);
              fieldPane.add(textFieldBlue);
              fieldPane.add(exitButton);
              setBorder(BorderFactory.createEmptyBorder(40,40,40,40));
              add(labelPane, BorderLayout.LINE_START);
              add(fieldPane, BorderLayout.CENTER);
              TextFieldHandler handler = new TextFieldHandler();
              textFieldRed.addActionListener(handler);
              textFieldGreen.addActionListener(handler);
              textFieldBlue.addActionListener(handler);
              showButton.addActionListener(handler);
         private class TextFieldHandler implements ActionListener
              public void actionPerformed(ActionEvent event)
                   if (event.getSource() == showButton)
                        String textRed = textFieldRed.getText();
                        String textGreen = textFieldGreen.getText();
                        String textBlue = textFieldBlue.getText();
                        int a = Integer.parseInt(textRed);
                        int b = Integer.parseInt(textGreen);
                        int c = Integer.parseInt(textBlue);
                        if ((a < 0) || (a > 255)||(b<0)||(b>255)||(c<0)||(c>255));
                             optionPane.showMessageDialog(null, "Please enter a number between 0 and 255!");//HERE IS WHERE I NEED THE HELP!!
                        Color colorObject = new Color(a,b,c);
                        setBackground(colorObject);
         public static void main(String args[])
              JFrame frame = new JFrame("Color Editor");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
              frame.add(new ColorEditor());
              frame.pack();
              frame.setVisible(true);
    }

    Okay now Eclipse is giving me a really funky error that I cannot quite figure out (in the compiler) but my program is running fine.... Can you help me with this too?
    Here is what the compiler is giving me....
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Color parameter outside of expected range: Green
    +     at java.awt.Color.testColorValueRange(Unknown Source)+
    +     at java.awt.Color.<init>(Unknown Source)+
    +     at java.awt.Color.<init>(Unknown Source)+
    +     at ColorEditor$TextFieldHandler.actionPerformed(ColorEditor.java:80)+
    +     at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)+
    +     at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)+
    +     at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)+
    +     at javax.swing.DefaultButtonModel.setPressed(Unknown Source)+
    +     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)+
    +     at java.awt.Component.processMouseEvent(Unknown Source)+
    +     at javax.swing.JComponent.processMouseEvent(Unknown Source)+
    +     at java.awt.Component.processEvent(Unknown Source)+
    +     at java.awt.Container.processEvent(Unknown Source)+
    +     at java.awt.Component.dispatchEventImpl(Unknown Source)+
    +     at java.awt.Container.dispatchEventImpl(Unknown Source)+
    +     at java.awt.Component.dispatchEvent(Unknown Source)+
    +     at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)+
    +     at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)+
    +     at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)+
    +     at java.awt.Container.dispatchEventImpl(Unknown Source)+
    +     at java.awt.Window.dispatchEventImpl(Unknown Source)+
    +     at java.awt.Component.dispatchEvent(Unknown Source)+
    +     at java.awt.EventQueue.dispatchEvent(Unknown Source)+
    +     at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)+
    +     at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)+
    +     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)+
    +     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)+
    +     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)+
    +     at java.awt.EventDispatchThread.run(Unknown Source)+

  • Need Help: Changing Colors in Template for Flyer

    I am trying to create a flyer from a template. I chose a template that has a colored border, but want to change the colors....I cannot figure out how to?
    Also,
    How to change the background color on a template too?
    Thanks so much for the help!!!
    PS: I am using the iWork, Pages...for this

    Hi Streater
    Welcome to the forum.
    There are 3 possiblilities:
    *1. It is locked* and shows small grey crosses on the corners
    +Menu > Arrange > Unlock ( option command l)+
    *2. It is grouped*
    +Menu > Arrange > Ungroup ( option shift command g)+
    *3. It is a scan or pdf*
    +Inspector > Metrics > File Info+
    Need to edit it outside Pages in a graphics program.
    If you can get at the object the colors and strokes etc are at:
    +Inspector > Graphic > Fill / Stroke+
    Double click any color fields to get the color picker.
    Peter

  • Unable to create updatable statement for MySQL?

    The following code fragment prints 'Read only', even though the updatable flag is being set for the createStatement function. Can anyone give me an idea of what I am doing wrong here? I'm able to read stuff OK, but not update anything.
    Connection conn = DriverManager.getConnection("jdbc:mysql:[removed]");
    Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    String query = "select * from foo";
    rs = stmt.executeQuery(query);
    int concurrency = rs.getConcurrency();
    if (concurrency == ResultSet.CONCUR_READ_ONLY)
         System.out.println("Read only");
    else
         if (concurrency == ResultSet.CONCUR_UPDATABLE)
              System.out.println("Updatable");
         else
              System.out.println("Unknown concurrency - " + concurrency);

    Not all databases support all the listed resultSetType and resultSetConcurrency values; usually, if you try to use an unsopported type, you still get a connection but it's type os downgraded.
    You can usually find out if a type is supported by reading the documentation, or querying the database, using DataBaseMetaData.supportsResultSetConcurrency()
    Sadly, the only thing in the MySQL documentation that I'm aware of on this topic is a note in the changelog for the 3.0.2-dev version of MySQL
        - Fixed DBMD.supportsResultSetConcurrency() so that it returns true
          for ResultSet.TYPE_SCROLL_INSENSITIVE and ResultSet.CONCUR_READ_ONLY or
          ResultSet.CONCUR_UPDATABLEI did a quick search and might have missed something:
    http://dev.mysql.com/doc/mysql/en/index.html
    I suspect TYPE_SCROLL_SENSITIVE is not supported and your connection is being downgraded; you might try testing the DBMD to see what the database says is supported...

  • I need help changing the security key for WRT54G2 1.5

    I already know the security key on my network, I just need to change it.  I don't have 'cisco connect'. I've tried the web based method with the 192.168.1.1 IP and using 'admin' for the password, but that gives me a '401 Not Authorized' error.  I've tried using my own security key instead of 'admin' and that doesn't work either.   How do I change this.  I tried to use the Linsky's knowledgebase and that didn't help. Live Chat won't help unless I'm willing to sign-up for some paid service plan, and there is no way I'm doing that.  I've never heard of a company charging their customers just to explain how to do something. All I have is a simple question about how to change the network security key when I already know what it is and there is no problem with the connection. Can anyone help me.  PLEASE.

    If admin didn’t work, it’s possible that you might have setup a different password to login to the setup of the router when you initially set it up. Since admin and your security key didn’t work when you tried accessing your router page, the other option for you then is to reset the router. Push and hold the reset button on the router using a pin or a paper clip for 30 seconds and unplug the power cord for another 30 seconds. Once the power light goes solid, you may start reconfiguring the settings of the router. For instructions, refer to these links: Setting up a Linksys router with Cable Internet service & Setting up a Linksys router for DSL Internet connection. Once you establish the wired internet connection, you may then start reconfiguring the wireless settings. Go to the Wireless tab: set the wireless configuration to manual; set a network name; then save the settings. Once saved, click on Wireless Security subtab:  set the security mode to WPA2 Personal and enter a new security key on the passphrase bar.

  • Help with Like Prepared statement

    Hi,
    Below is a part of the code in my test application which I am using for searching the phone book.
    I want to do a pattern search with like, but for some reason, my code is not fetching me the results.
    It just gives Zero results.
    But if i use "=" it works fine.
    I have highlighted the important part
    Can you please guide me to correct this code ?
    public class DBprgm {
    ResultSet result;
    public ResultSet getSearch(String a) {
              try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:source", "sa" , "");
    Statement st = con.createStatement();
    PreparedStatement ps = con.prepareStatement("select from friends where fname like ? ");*
    *String x = "%"+a+"%";*
    *ps.setString(1, x);*
    result = ps.executeQuery();
         catch (SQLException s){
              s.printStackTrace();
         catch (ClassNotFoundException c){
              c.printStackTrace();
         return result;
    }

    Your code leaks Connections! You create a Connection and never close it, that's a pretty bad idea.
    What database are you using? From a quick glance the code seems correct (apart from the problem I mentioned above, of course).
    Edit: also, I see that you're using the JDBC-ODBC bridge. That JDBC driver has only very limited functionality and also has a few tiny bugs. Generally I'd strongly suggest that you avoid it and use your databases native JDBC drivers instead. Maybe that's also the problem here, but I can't say for sure.

  • Problems with prepared statement in MYSQL.

    I 've this code:
    String sql = "UPDATE dcr SET Fecha=?, Origen=?, Destino=?, Mensaje=?, Estado=? WHERE IDDCR=? AND IDUsuario=?";
    PreparedStatement st = cn.prepareStatement(sql);
    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
    java.sql.Date sqlDate = java.sql.Date.valueOf(fmt.format(this.fecha));
    st.setDate(1, sqlDate);
    st.setString(2, this.origen);
    st.setString(3, this.destino);
    st.setString(4, this.mensaje);
    st.setString(5, this.estado);
    st.setString(6, this.primaryKey);
    st.setString(7, this.usuario);
    I receive a SQLException with this message "Callable statments not supported" when the line "PreparedStatement st = cn.prepareStatement(sql)" is executed.
    My JDBC Driver is "mysql-connector-java-3.0.11-stable-bin" and my server is "*MySQL 4.0.17-max"*.
    Anybody see where is the problem?
    Tnaks in advance.
    Ricardo.

    I've more information about this problem.
    If I take my code and put it in a class with a main function it works fine.
    The original code is a part of a DAO pattern object that is invoked by a servlet (is the storeObject function).
    The servlet create a record, send a native TCP/IP transaction to a external system and whit this code update the record previously created with the result of the transaction.
    The system uses connection pooling. But the conection used in create of the record is diferent from the used in this code. (It's returned to the Datasource) All objects of the database process are closed in a finaly block before return the connection. (Statements, PreparedStatements , ResultSets, etc...)
    Thanks in advance.
    Ricardo

  • How can I change the state for normal. All I get is a question mark.

    I can't change the normal state for my site. The button for color of text for the normal state is a question mark. Is there a way to reset this?

    Thanks. I am trying to change the appearance of a hyperlink on a web page. Specifically, I want to change the default text color from blue to another color. I can change the color for the other states of the hyperlink (rollover, etc.) but the attempt to change the normal state of the hyperlink is unsuccessful because the color box for that state is a question mark. Bill

  • Problem in prepared Statement

    hi,
    i have used following prepared Statement for the update in database.
    Can any one tell me that,How can i use date in following method.
    I have 4 field for date as given below:(BOLD shown)
    I have used String in that place.
    It is not working.
    PreparedStatement pstatement = conn.prepareStatement(
    "UPDATE sec_mast SET catg_code=?, vou_no=?, vou_date=?, vou_amt=?, due_date1=?, due_date2=?, mat_date=? where sec_no=? ");
    pstatement.setInt(1,Integer.parseInt(request.getParameter("catg_code")));
    pstatement.setString(2,request.getParameter("vou_no"));
    pstatement.setString(3,request.getParameter("vou_date"));
    pstatement.setInt(4,Integer.parseInt(request.getParameter("vou_amt")));
    pstatement.setString(5,request.getParameter("due_date1"));
    pstatement.setString(6,request.getParameter("due_date2"));
    pstatement.setString(7,request.getParameter("mat_date"));
    pstatement.setInt(8,Integer.parseInt(request.getParameter("sec_no")));
    int rowCount = pstatement.executeUpdate();
    conn.setAutoCommit(false);
    conn.setAutoCommit(true);
    plz help me

    thanx for u r reply.
    MY whole code is shown as below:
    This page is for the updating the values in database..
    <html>
    <body>
    <table>
    <tr>
    <td>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="javax.servlet.http.*" %>
    <%@ page language="java" import="java.sql.*" %>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn=DriverManager.getConnection("jdbc:odbc:pf","scott","ttlscott");
    System.out.println("got connection");
    %>
    <%
    String action = request.getParameter("action");
    // Check if an update is requested
    if (action != null && action.equals("update")) {
    conn.setAutoCommit(false);
    PreparedStatement pstatement = conn.prepareStatement(
    "UPDATE sec_mast SET sec_no=? , catg_code=?, face_val=?, pur_val=?, int_paid=?, int_recd=?, brkr=?, vou_no=?, vou_date=?, vou_amt=?, due_date1=?, due_date2=?, lf_no=?, mat_date=? where tot_val=? ");
    pstatement.setInt(1,Integer.parseInt(request.getParameter("sec_no")));
    pstatement.setInt(2,Integer.parseInt(request.getParameter("catg_code")));
    pstatement.setInt(3,Integer.parseInt(request.getParameter("face_val")));
    pstatement.setInt(4,Integer.parseInt(request.getParameter("pur_val")));
    pstatement.setInt(5,Integer.parseInt(request.getParameter("int_paid")));
    pstatement.setInt(6,Integer.parseInt(request.getParameter("int_recd")));
    pstatement.setInt(7,Integer.parseInt(request.getParameter("brkr")));
    pstatement.setString(8,request.getParameter("vou_no"));
    pstatement.setString(9,request.getParameter("vou_date"));
    pstatement.setInt(10,Integer.parseInt(request.getParameter("vou_amt")));
    pstatement.setString(11,request.getParameter("due_date1"));
    pstatement.setString(12,request.getParameter("due_date2"));
    pstatement.setString(13,request.getParameter("lf_no"));
    pstatement.setString(14,request.getParameter("mat_date"));
    pstatement.setInt(15,Integer.parseInt(request.getParameter("tot_val")));
    int rowCount = pstatement.executeUpdate();
    conn.setAutoCommit(false);
    conn.setAutoCommit(true);
    %>
    <%
    // Create the statement
    Statement statement = conn.createStatement();
    ResultSet rs = statement.executeQuery
    ("SELECT * from sec_mast ");
    %>
    <%
    // Iterate over the ResultSet
    while ( rs.next() ) {
    %>
    <tr>
    <form action="security_update.jsp" method="get">
    <input type="hidden" value="update" name="action">
    <td><input value="<%= rs.getInt("sec_no") %>" name="sec_no"></td>
    <td><input value="<%= rs.getInt("catg_code") %>" name="catg_code"></td>
    <td><input value="<%= rs.getInt("face_val") %>" name="face_val"></td>
    <td><input value="<%= rs.getInt("pur_val") %>" name="pur_val"></td>
    <td><input value="<%= rs.getInt("int_paid") %>" name="int_paid"></td>
    <td><input value="<%= rs.getInt("int_recd") %>" name="int_recd"></td>
    <td><input value="<%= rs.getInt("brkr") %>" name="brkr"></td>
    <td><input value="<%= rs.getInt("tot_val") %>" name="tot_val"></td>
    <td><input value="<%= rs.getString("vou_no") %>" name="vou_no"></td>
    <td><input value="<%= rs.getDate("vou_date") %>" name="vou_date"></td>
    <td><input value="<%= rs.getInt("vou_amt") %>" name="vou_amt"></td>
    <td><input value="<%= rs.getDate("due_date1") %>" name="due_date1"></td>
    <td><input value="<%= rs.getDate("due_date2") %>" name="due_date2"></td>
    <td><input value="<%= rs.getString("lf_no") %>" name="lf_no"></td>
    <td><input value="<%= rs.getDate("mat_date") %>" name="mat_date"></td>
    <td><input type="submit" value="Update"></td>
    </form>
    </tr>
    <%
    %>
    </table>
    <%
    // Close the ResultSet
    rs.close();
    // Close the Statement
    statement.close();
    // Close the Connection
    conn.close();
    } catch (SQLException sqle) {
    out.println(sqle.getMessage());
    } catch (Exception e) {
    out.println(e.getMessage());
    %>
    </td>
    </tr>
    </body>
    </html>

  • Prepared statement parameter order?

    We have prepared statements for insert and update where changing the order of columns in the statement gives different results.
    Problem 1:
    For an update statements setting 8 column values via preparedStatement.executeUpdate, we got the following exception containing an internal error:
    java.sql.SQLException: Interner Fehler: Daten-Array nicht zugewiesen
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
    at oracle.jdbc.dbaccess.DBDataSetImpl._setDBItem(DBDataSetImpl.java:365)
    at oracle.jdbc.dbaccess.DBDataSetImpl._bindsRowCompleted(DBDataSetImpl.java:737)
    at oracle.jdbc.dbaccess.DBDataSetImpl.rowCompleted(DBDataSetImpl.java:1619)
    at oracle.jdbc.driver.OraclePreparedStatement.get_data_for_columns(OraclePreparedStatement.java:2343)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:362)
    All statement ? parameters where bound correctly.
    When we changed the order of the update's set-clauses and of the according setString parameters to the same order the table is created in the database, the statement works fine.
    Problem 2:
    An insert statement using a VALUES clause with not more than 10 columns works fine independent of the column order.
    But if we have a table with more than 10 columns, the insert only works if the columns in the insert statement are in the same order as the database table. Otherwise we got an IndexOutOfBoundsException - looks like a array overflow in an internal array used to sort column indexes...
    We are using Oracle 8.1.7 and JDBC 1.2 thin driver.
    Anyone else with similar problems?

    Did you try to define the Parameter name?
    Like these:
    strSQL="XXX(p_1=>?, p_2=>?,p_3=>?)"
    cstmt.setXXX(1,'v1');
    cstmt.setXXX(3,'v3');
    cstmt.setXXX(2,'v2');
    I am suprised, If you have so many parameter, how can you maintain you code if you do not define the parameter names?

  • MS SQL Server 7 - Performance of Prepared Statements and Stored Procedures

    Hello All,
    Our team is currently tuning an application running on WL 5.1 SP 10 with a MS
    SQL Server 7 DB that it accesses via the WebLogic jConnect drivers. The application
    uses Prepared Statements for all types of database operations (selects, updates,
    inserts, etc.) and we have noticed that a great deal of the DB host's resources
    are consumed by the parsing of these statements. Our thought was to convert many
    of these Prepared Statements to Stored Procedures with the idea that the parsing
    overhead would be eliminated. In spite of all this, I have read that because
    of the way that the jConnect drivers are implemented for MS SQL Server, Prepared
    Statments are actually SLOWER than straight SQL because of the way that parameter
    values are converted. Does this also apply to Stored Procedures??? If anyone
    can give me an answer, it would be greatly appreciated.
    Thanks in advance!

    Joseph Weinstein <[email protected]> wrote:
    >
    >
    Matt wrote:
    Hello All,
    Our team is currently tuning an application running on WL 5.1 SP 10with a MS
    SQL Server 7 DB that it accesses via the WebLogic jConnect drivers.The application
    uses Prepared Statements for all types of database operations (selects,updates,
    inserts, etc.) and we have noticed that a great deal of the DB host'sresources
    are consumed by the parsing of these statements. Our thought was toconvert many
    of these Prepared Statements to Stored Procedures with the idea thatthe parsing
    overhead would be eliminated. In spite of all this, I have read thatbecause
    of the way that the jConnect drivers are implemented for MS SQL Server,Prepared
    Statments are actually SLOWER than straight SQL because of the waythat parameter
    values are converted. Does this also apply to Stored Procedures???If anyone
    can give me an answer, it would be greatly appreciated.
    Thanks in advance!Hi. Stored procedures may help, but you can also try MS's new free type-4
    driver,
    which does use DBMS optimizations to make PreparedStatements run faster.
    Joe
    Thanks Joe! I also wanted to know if setting the statement cache (assuming that
    this feature is available in WL 5.1 SP 10) will give a boost for both Prepared Statements
    and stored procs called via Callable Statements. Pretty much all of the Prepared
    Statements that we are replacing are executed from entity bean transactions.
    Thanks again

Maybe you are looking for

  • How do I set up itunes library for my family

    Hi all, am needing some advice if you can help please. My family all have iphones 4 of us. All our music is held in one computer what I am trying to do is connect all the phones one laptop and the library pc so each person can access our music. How d

  • Uploading exported Excel file to Google Docs

    I exported a spreadsheet as an Excel .xls file, but Google won't let me upload it giving me an error: We're sorry, but we were unable to upload this document. If you have the desktop word processor installed on this computer, there are two other easy

  • New HDD in Imac

    i have in my imac new hdd. Servis changed for me without installing osx. Now when put in osx dvd and hold down c key, nothing happen and dvd comes out. Any solution for it? Thank zou guys... Mac os version 10.6.2.

  • Apply MVC to a Swing app?

    Folks, I got inspired by this thread: http://forum.java.sun.com/thread.jspa?threadID=5244847&start=23&tstart=0 and wrote the below version of MineSweeper (winmine.exe) in Swing as a learning exercise. I'm about half way through my TODO list, and the

  • Host name, port number and service name

    Hi! I have a question that will sound easy and stupid, but not for me. during the instal of 9iAS.There is a screen ask to provide the host name,port number and service name. Did host anme is only the name of my PC? and what is the port number?(window