gally Posted May 7, 2011 Share Posted May 7, 2011 Hi all, Ive a php script which reads and outputs some data. It works very well when data are displayed, let me call this way, in the browser but get following error if I try to display them in a popup window. This is the error message I get Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /hdb1/foo/Gestione/dati/printer1.php on line 103 What I know about mysql, not too much to be honest) is that the error is shown when mysql cant read the DB, but this happens only if I use the popup window This is the script which opens the popup <script language="javascript" type="text/javascript"> <!-- function popitup(url) { newwindow=window.open(url,'name','height=300,width=400'); if (window.focus) {newwindow.focus()} return false; } // --> </script> and this is the command to activate it. <form method='post' name='alfa' action='printer1.php' onSubmit="return popitup('printer1.php')" > <input type = 'hidden' name = 'opzione' value = "<?php echo $option; ?>" /> <input type = 'hidden' name = 'testo' value = "<?php echo $cerca; ?>" /> <input class = 'input' value = 'Print' type = 'submit'/> </form> and finally the php code which calls mysql $db = mysqli_connect($db_host,$db_user, $db_password) or die('Connessione a MySql fallita. Controllare i dati di configurazione: ' . mysqli_connect_error($db)); mysqli_select_db($db,$db_name) or die('Selezione del DB fallita. Controllare il nome del DataBase: ' . mysqli_error($db)); $result = mysqli_query($db,"SELECT * FROM $db_table WHERE $option LIKE \"%$cerca%\" ORDER BY $sort LIMIT 0,1000"); $num_rows = mysqli_num_rows($result); any hint? Quote Link to comment https://forums.phpfreaks.com/topic/235762-mysql-in-a-popup/ Share on other sites More sharing options...
sunfighter Posted May 7, 2011 Share Posted May 7, 2011 Your query is failing. If you echoed out $num_rows in the given php file you might see that. "WHERE $option LIKE" <- I hope you have defined $option to be the name of a column. If your looking to match the column 'option' remove the $. Quote Link to comment https://forums.phpfreaks.com/topic/235762-mysql-in-a-popup/#findComment-1211955 Share on other sites More sharing options...
gally Posted May 7, 2011 Author Share Posted May 7, 2011 Hold on. The query is ok if I display the result on the "normal screen", it fails if I want to see the result into the popup window. The code of the quesry is the same. In the code below if I remove "onSubmit="return popitup('printer1.php')"" from the <form.... it works very well Quote Link to comment https://forums.phpfreaks.com/topic/235762-mysql-in-a-popup/#findComment-1211992 Share on other sites More sharing options...
sunfighter Posted May 8, 2011 Share Posted May 8, 2011 OK, I'll take an error for this but only half wrong. Your error code does say something is wrong with the results of a query. That string lead me up the wrong street. On re-reading the error I see: hdb1/foo/Gestione/dati/printer1.php on line 103 That's a different file, but this is where the error occurs. Not you say that page displays if ran normally, but it is the source of the problem. Echo out your results and then the mysqli_num_rows(). If you don't see the problem print the page here and we'll have a look. Quote Link to comment https://forums.phpfreaks.com/topic/235762-mysql-in-a-popup/#findComment-1212115 Share on other sites More sharing options...
fenway Posted May 11, 2011 Share Posted May 11, 2011 Those sound like PHP errors.. Quote Link to comment https://forums.phpfreaks.com/topic/235762-mysql-in-a-popup/#findComment-1213924 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.