Jump to content

mysql in a popup


gally

Recommended Posts

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?

Link to comment
Share on other sites

Hold on. :D

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.