不是有效的mysql资源(mysql_fetch_array() returns 'supplied argument is not a valid MySQL result resource')
我正在尝试以下代码:
<?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $query = "SELECT * FROM Auctions"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { foreach($row as $field=>$value) { echo "$field: {$value} <br />"; } } mysql_close($link); ?>
并得到此错误:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Programme\EasyPHP 2.0b1\www\test.php on line 14
我错过了什么?
I am trying the following code:
<?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $query = "SELECT * FROM Auctions"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { foreach($row as $field=>$value) { echo "$field: {$value} <br />"; } } mysql_close($link); ?>
And get this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Programme\EasyPHP 2.0b1\www\test.php on line 14
What am I missing?
原文:https://stackoverflow.com/questions/253378
最满意答案
TextBox应该触发
ChangeEvent
(或ValueChangeEvent
- 目前不知道)。 所以你可以在构造函数中轻松地做这样的事情:this.addChangeHandler(new ChangeHandler ...
如果这还不够,您还可以收听
Focus
事件。Thanks for your help. I figured it out by myself today and it is quiet simple. I didn't notice, that there is already the
DropHandler
.You can do this for example in the constructor:
addDropHandler(new DropHandler() { @Override public void onDrop(DropEvent event) { if(!event.getDataTransfer().getData("text/plain").isEmpty()) { Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { fireEvent(new TextChangeEvent(ExtendedTextBox.this.getText())); } }); } } });
To prevent the default behaviour of the
TextField
just addevent.preventDefault();
. Now you can get the input by callingevent.getDataTransfer().getData("text/plain")
and do your input validation etc.And as side effect the
onBrowserEvent(Event event)
method is called now by dropping something into the text field. But the type int is-1
, so it's not really helpful at this place.
相关问答
更多-
TextBox - 如何使用拖放操作插入文本时获取事件?(TextBox - how to get an event when inserted into the text using Drag&Drop?)[2023-10-25]
如果文本被删除,请使用PreviewDrop事件通知:Use PreviewDrop event to notified in case text is dropped on it: -
你应该试试这个: $(window).bind('drop', function(event) { event.preventDefault(); event.stopPropagation(); }); $(window).bind('dragover', function(event) {// the ondragover event needs to be canceled in Google Chrome and Safari to allow firing the ondrop e ...
-
TextBox应该触发ChangeEvent (或ValueChangeEvent - 目前不知道)。 所以你可以在构造函数中轻松地做这样的事情: this.addChangeHandler(new ChangeHandler ... 如果这还不够,您还可以收听Focus事件。 Thanks for your help. I figured it out by myself today and it is quiet simple. I didn't notice, that there is alrea ...
-
您可以通过监听事件CollectionEvent.COLLECTION_CHANGE来处理: myList.dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChangeHandle); 每当你进行一些更改时,这会触发一个event.kind == CollectionEventKind.* ( 见这里 ),所以你可以保存你想要的更改。 还有通过监听DragEvent.DRAG_COMPLETE事件的选 ...
-
JFace拖放项目突出显示(JFace Drag&Drop items highlight)[2022-02-04]
直接从DropTargetEvent.item获取TreeItem 。 如果您将JFace TreeViewer与关联的内容和标签提供程序一起使用,那么您可以使用ViewerDropAdapter ,它将负责解析该项目。 Take the TreeItem directly from DropTargetEvent.item. If you would be using JFace TreeViewer with associated content and label providers then you ... -
所以,问题出在mouseDown事件中,我还需要在那里存储实际坐标。 function onDocumentMouseDown(event){ mouseDown = true; last_position_x = event.clientX; last_position_y = event.clientY; } So, the problem was in the mouseDown event, I needed to store actual coordinates ther ...
-
出于隐私和安全原因,这是按照设计的:Chrome在这里比Firefox更密切地实施HTML5规范。 请参见http://www.w3.org/TR/html5/editing.html#drag-data-store-mode This is as-designed, for privacy and security reasons: Chrome implements the HTML5 spec more closely than Firefox here. See http://www.w3.org/ ...
-
使用WPF WebBrowser控件拖放 - 删除事件未触发(Drag&Drop with WPF WebBrowser control - Drop event not firing)[2022-08-23]
你应该尝试test.AllowDrop = true; 。 看一下这个教程 编辑: 经过几次尝试和一些研究后,我发现根本不会发射任何Drag事件。 但也许这个问题可以帮助你 You should try test.AllowDrop = true;. Take a look at this Tutorial Edit: After a few tries and a little research i found out that no Drag event will be fired at all. Bu ... -
JavaFX忽略将拖放文件拖放到TextField(Mac OS X)(JavaFX ignoring drop in drag and drop file onto TextField (Mac OS X))[2024-02-08]
由于某些原因我不清楚,你需要在dragOver处理程序中接受传输模式,而不是dragEntered处理程序: txtSource.setOnDragOver(this::handleEnter); // txtSource.setOnDragEntered(this::handleEnter); For some reason not clear to me, you need to accept the transfer mode in a dragOver handler, not a dragEnt ... -
包含较大TextField的矩形上的Actionscript事件侦听器(Actionscript event listener on rectangle containing larger TextField)[2023-02-01]
我认为你要找的是textField.autoSize参数。 它使文本字段边界缩小到文本的大小(否则它具有默认的高度/宽度,而不管它包含的文本) import flash.text.TextField; import flash.text.TextFieldAutoSize; var textField:TextField = new TextField(); textField.autoSize = TextFieldAutoSize.LEFT; textField.text = "your text" ...