Autocomplete from database mysqli
I am using auto complete where the suggestions come from database and it
is working fine, however I tried to change it to mysqli but it doesn't
work. It doesn't show any suggestions;no error.
what I am missing on the mysqli end?
How can I be able to add more tables(I have like 40 tables)? Thanks.
MySQL:
<?php
mysql_connect("localhost","root","");
mysql_select_db("database");
$term=$_GET["term"];
$query=mysql_query("SELECT * FROM products1 where title like
'%".$term."%' order by id ");
$json=array();
while($student=mysql_fetch_array($query)){
$json[]=array(
'value'=> $student["title"],
'label'=>$student["title"]
);
}
echo json_encode($json);
?>
What I tried with MySQLi:
<?php
$mydb = new mysqli('localhost', 'root', '', 'database');
$q = $_POST['term'];
$stmt = $mydb->prepare(" SELECT * from products1 where title LIKE ? ");
echo $mydb->error;
$stmt->bind_param('s', $q);
$stmt->execute();
?>
<?php
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
$json[]=array(
'value'=> $student["title"],
'label'=>$student["title"]
);
}
echo json_encode($json);
?>
Friday, 13 September 2013
Titanium - Error Loading Browser - MOZILLA_HOME_FIVE not set
Titanium - Error Loading Browser - MOZILLA_HOME_FIVE not set
Firstly, I am running on Manjaro Linux.
I downloaded Titanium, unzipped it, then ran it. All fine. However, at
startup it is throwing a "Cannot find chromimum. See documentation for
possible workaround/fixes" error which is then followed by a
MOZILLA_FIVE_HOME not set error and lastly it suggests that I should
terminate the workbench due to a SWT Error.
I've tried the many suggestions I've found online including:
Installing xulrunner. Did not work.
Setting an env variable called MOZILLA_FIVE_HOME according to
(http://www.eclipse.org/swt/faq.php#browserlinuxrcp). However, I may have
messeg up following these instructions. If anyone would kindly explain
what step number 2 means with a little bit of extra detail, I would
seriously appreciate it.
I will post the full error I am getting below:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]
org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path
(MOZILLA_FIVE_HOME not set)] at org.eclipse.swt.SWT.error(SWT.java:4308)
at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) at
org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) at
org.eclipse.swt.browser.Browser.(Browser.java:99) at
org.eclipse.ui.internal.browser.BrowserViewer.(BrowserViewer.java:225) at
com.aptana.portal.ui.internal.BrowserViewerWrapper.createSWTBrowserViewer(BrowserViewerWrapper.java:26)
at
com.aptana.portal.ui.browser.AbstractPortalBrowserEditor.createBrowserViewer(AbstractPortalBrowserEditor.java:211)
at
com.aptana.portal.ui.browser.AbstractPortalBrowserEditor.createPartControl(AbstractPortalBrowserEditor.java:108)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:670)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313) at
org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
at
org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
at
org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at
org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
at
org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1245)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1198) at
org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1597) at
org.eclipse.ui.internal.PartStack.add(PartStack.java:493) at
org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103) at
org.eclipse.ui.internal.PartStack.add(PartStack.java:479) at
org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112) at
org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
at
org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
at
org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
at
org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:808)
at
org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:707)
at
org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:666)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2942)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2850)
at
org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2842)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2793)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2789)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2773)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2756)
at com.aptana.portal.ui.internal.Portal$1.runInUIThread(Portal.java:227)
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95) at
org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) at
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) at
org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) at
org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) at
org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) at
org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at
com.appcelerator.titanium.rcp.IDEApplication.start(IDEApplication.java:125)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at
org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at
org.eclipse.equinox.launcher.Main.run(Main.java:1410) at
org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Firstly, I am running on Manjaro Linux.
I downloaded Titanium, unzipped it, then ran it. All fine. However, at
startup it is throwing a "Cannot find chromimum. See documentation for
possible workaround/fixes" error which is then followed by a
MOZILLA_FIVE_HOME not set error and lastly it suggests that I should
terminate the workbench due to a SWT Error.
I've tried the many suggestions I've found online including:
Installing xulrunner. Did not work.
Setting an env variable called MOZILLA_FIVE_HOME according to
(http://www.eclipse.org/swt/faq.php#browserlinuxrcp). However, I may have
messeg up following these instructions. If anyone would kindly explain
what step number 2 means with a little bit of extra detail, I would
seriously appreciate it.
I will post the full error I am getting below:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]
org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path
(MOZILLA_FIVE_HOME not set)] at org.eclipse.swt.SWT.error(SWT.java:4308)
at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) at
org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) at
org.eclipse.swt.browser.Browser.(Browser.java:99) at
org.eclipse.ui.internal.browser.BrowserViewer.(BrowserViewer.java:225) at
com.aptana.portal.ui.internal.BrowserViewerWrapper.createSWTBrowserViewer(BrowserViewerWrapper.java:26)
at
com.aptana.portal.ui.browser.AbstractPortalBrowserEditor.createBrowserViewer(AbstractPortalBrowserEditor.java:211)
at
com.aptana.portal.ui.browser.AbstractPortalBrowserEditor.createPartControl(AbstractPortalBrowserEditor.java:108)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:670)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313) at
org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
at
org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
at
org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at
org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
at
org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1245)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1198) at
org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1597) at
org.eclipse.ui.internal.PartStack.add(PartStack.java:493) at
org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103) at
org.eclipse.ui.internal.PartStack.add(PartStack.java:479) at
org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112) at
org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
at
org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
at
org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
at
org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:808)
at
org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:707)
at
org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:666)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2942)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2850)
at
org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2842)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2793)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2789)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2773)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2756)
at com.aptana.portal.ui.internal.Portal$1.runInUIThread(Portal.java:227)
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95) at
org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) at
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) at
org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) at
org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) at
org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) at
org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at
com.appcelerator.titanium.rcp.IDEApplication.start(IDEApplication.java:125)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at
org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at
org.eclipse.equinox.launcher.Main.run(Main.java:1410) at
org.eclipse.equinox.launcher.Main.main(Main.java:1386)
How to swipe images up or down using the Gallery widget
How to swipe images up or down using the Gallery widget
I have a project for which I have to display some images. Even if the
Gallery widget is deprecated, it seems to be the best choice, since I have
not so much time to spend on it.
I would like to mimic Android's photo gallery and deleting an image when
swiping it up or down (see the screenshots below). I saw another in SO
question that we can detect vertical swipings (see the code below), but I
would like to move the image during the movement, as in Android's photo
gallery.
How could I implement this feature?
public class CustomGallery extends Gallery
{
[...]
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float
velocityX, float velocityY)
{
if (Math.abs(velocityX) > Math.abs(velocityY))
// Moving horizontally
else
// Moving vertically
return super.onFling(e1, e2, velocityX, velocityY);
}
}
NB: I can also accept an answer based on HorizontalScrollView if it
implements the up- or down-swiping feature and if it has center-locking.
!
I have a project for which I have to display some images. Even if the
Gallery widget is deprecated, it seems to be the best choice, since I have
not so much time to spend on it.
I would like to mimic Android's photo gallery and deleting an image when
swiping it up or down (see the screenshots below). I saw another in SO
question that we can detect vertical swipings (see the code below), but I
would like to move the image during the movement, as in Android's photo
gallery.
How could I implement this feature?
public class CustomGallery extends Gallery
{
[...]
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float
velocityX, float velocityY)
{
if (Math.abs(velocityX) > Math.abs(velocityY))
// Moving horizontally
else
// Moving vertically
return super.onFling(e1, e2, velocityX, velocityY);
}
}
NB: I can also accept an answer based on HorizontalScrollView if it
implements the up- or down-swiping feature and if it has center-locking.
!
CKEdtor 4: How to add CSS stylesheet from plugin?
CKEdtor 4: How to add CSS stylesheet from plugin?
Tried this for now, but no luck
editor.addCss(this.path + 'tabber.css');
editor.document.appendStyleSheet(this.path + 'tabber.css');
Full code
(function () {
CKEDITOR.plugins.add('tabber', {
init: function (editor) {
editor.ui.addButton('addTab', {
command: 'addTab',
icon: this.path + 'icons/tabber.png',
label: Drupal.t('Insert tabs')
});
editor.addCss(this.path + 'tabber.css');
editor.document.appendStyleSheet(this.path + 'tabber.css');
editor.addCommand('addTab', {
exec: function (editor) {
editor.insertHtml('<dl>' +
'<dt>Tab title 1</dt>' +
'<dd><p>Tab content 1.</p></dd>' +
'<dt>Tab title 2</dt>' +
'<dd><p>Tab content 2.</p></dd>' +
'</dl>');
}
});
}
});
})();
Tried this for now, but no luck
editor.addCss(this.path + 'tabber.css');
editor.document.appendStyleSheet(this.path + 'tabber.css');
Full code
(function () {
CKEDITOR.plugins.add('tabber', {
init: function (editor) {
editor.ui.addButton('addTab', {
command: 'addTab',
icon: this.path + 'icons/tabber.png',
label: Drupal.t('Insert tabs')
});
editor.addCss(this.path + 'tabber.css');
editor.document.appendStyleSheet(this.path + 'tabber.css');
editor.addCommand('addTab', {
exec: function (editor) {
editor.insertHtml('<dl>' +
'<dt>Tab title 1</dt>' +
'<dd><p>Tab content 1.</p></dd>' +
'<dt>Tab title 2</dt>' +
'<dd><p>Tab content 2.</p></dd>' +
'</dl>');
}
});
}
});
})();
How to make all the textarea disabled used as ckeditor
How to make all the textarea disabled used as ckeditor
I have a set of textareas which are used as editors. I want to make those
textareas readonly in some condition. I am able to do it for individual
textareas.
$("#txtHtmlHead").ckeditorGet().setReadOnly();
but when looping through each textareas is not working
$('textarea').each(function() {
$(this).ckeditorGet().setReadOnly();
});
I am getting the below exception
CKEditor is not initialized yet, use ckeditor() with a callback.
Can anybody help?
I have a set of textareas which are used as editors. I want to make those
textareas readonly in some condition. I am able to do it for individual
textareas.
$("#txtHtmlHead").ckeditorGet().setReadOnly();
but when looping through each textareas is not working
$('textarea').each(function() {
$(this).ckeditorGet().setReadOnly();
});
I am getting the below exception
CKEditor is not initialized yet, use ckeditor() with a callback.
Can anybody help?
Thursday, 12 September 2013
How can I join path fragments using objective-C in iOS?
How can I join path fragments using objective-C in iOS?
What's the objective-C equivalent of python's os.path.join in iOS? e.g.:
>>> import os
>>> os.path.join("foo", "bar", "buuxometer", "hi.jpg")
'foo/bar/buuxometer/hi.jpg'
What's the objective-C equivalent of python's os.path.join in iOS? e.g.:
>>> import os
>>> os.path.join("foo", "bar", "buuxometer", "hi.jpg")
'foo/bar/buuxometer/hi.jpg'
Implementing PHPBB3 user management on external page
Implementing PHPBB3 user management on external page
I'm trying to figure out how to modify the PHPBB3 user management
information to have it redirect back to my pages instead of the forum
index. For example, when a user registers it or requests their password be
resent it will redirect them to the forum index instead of one of my
external pages. How can I begin tracing this logic back through the PHPBB3
code so I know what I need to modify?
I'm trying to figure out how to modify the PHPBB3 user management
information to have it redirect back to my pages instead of the forum
index. For example, when a user registers it or requests their password be
resent it will redirect them to the forum index instead of one of my
external pages. How can I begin tracing this logic back through the PHPBB3
code so I know what I need to modify?
Subscribe to:
Posts (Atom)