Jump to content

Recommended Posts

One of my tables was hacked by a couple of morons causing me to create a new one

The old table was named lner, the new one is named lner3 which has a couple of extra fields

 

Using a playton script to display and manipulate lner3 works just fine

but the script used to put detail in gallery pages just DON'T.

I basically get a blank page  not even the table

Remember this is the working script I am still using with my old table until I get the new one working

So header and stuff is all fine and it all checks out with CSS and Validation

 

<body>
<div  id="head">
  <?php 
// please note
$tble = 'lner3';
// Only the above line has changed from 
//$tble = 'lner';
$brnum = '60112';
include ("../../include/adsense.php");
include_once("../../include/bsgal_conn.php");
?>
</div>
<?php
    $connect = mysqli_connect($host,$account,$password) OR DIE("Error !! Unable to connect to database");
    $db = mysqli_select_db($connect,"$dbname") OR DIE( "Unable to select database ");
    $db="SELECT * FROM $tble WHERE br_no = $brnum OR other_no = $brnum";
if ($result = mysqli_query($connect,$db)) {  
	if (mysqli_num_rows($result)) {
			while ($row = mysqli_fetch_assoc($result)){
?>
<div id="main">
<table width="410" align="center" border="4" cellspacing="0" cellpadding="1">
  <tr>
    <th>Class</th>
    <th>C.M.Engineer</th>
    <th>Arrangment</th>
  </tr>
  <tr>
    <td><?php echo $row['lclas']."/".$row['class2']; ?></td>
    <td><?php echo $row['cme']; ?></td>
    <td><?php echo $row['wheel']; ?></td>
  </tr>
</table>
</div>
</body>
</html>

 

So some hints on debugging why it does not work would be most welcome

 

Thanks  Roy...

The code you posted is missing three closing }'s, which should be producing a fatal php parse error of some kind.

 

You should have error_reporting set to E_ALL and display_errors set to on in your master php.ini of your development system so that all the php detected errors will be reported and displayed.

Thank you for your reply,

Sorry I missed out the }}} I cut it out when I cropped the script

E_ALL has been turned on in PHP.ini

But I still have no  errors showing, I am echoing  as far as I can but I  cannot echo the next section of code

So below is where I am up to including my echo's

 

<div id="head">
  <?php 
$tble = 'lner3';
$brnum = '60112';
include_once("../../include/bsgal_conn.php");  / connection include that definitly works 
?>

</div>

<?php
   echo $dbname;
   echo "<hr/>";

   $connect = mysqli_connect($host,$account,$password) OR DIE("Error !! Unable to connect to database");
   $db = mysqli_select_db($connect,"$dbname") OR DIE( "Unable to select database ");
   		
echo "The Select query =    ";
   		echo $db="SELECT * FROM $tble WHERE br_no = $brnum OR lner# = $brnum";

   echo "<br/>";
     echo "<hr/>"; 
          echo "It gets this Far !";
   echo "<hr/>";

if ($result = mysqli_query($connect,$db)) {  
       // But not here and no error messages";
  		if (mysqli_num_rows($result)) {
			while ($row = mysqli_fetch_assoc($result)){

?>

<div id="main">

<table width="410" align="center" border="4" cellspacing="0" cellpadding="1">
  <tr>
    <th>Class</th>
    <th>C.M.Engineer</th>
    <th>Arrangment</th>
  </tr>
  <tr>
    <td><?php echo $row['lclas']."/".$row['class2']; ?></td>

    <td><?php echo $row['cme']; ?></td>

    <td><?php echo $row['wheel']; ?></td>

  </tr>
</table>
<?php
  }
}
}
?>
</body>
</html>

 

Any idea's would be welcome

 

Roy...

Hi, can you replace this code

 

$result = mysqli_query($connect, $db)

 

with this one

 

$result == mysqli_query($connect, $db)

 

I think, the condition is never fulfilled, since you write an assignment as the condition. You should write comparison instead of assignment.

 

Please let me know wwhat you think

The assignment code is correct, you are essentially trying to get the OP to compare an undefined variable with the result of the function.

While the IF statement in question

if ($result = mysqli_query($connect,$db)) { 

will always result in true, it should not have an adverse effect on the rest of the code.

Thank you both for your assistance,

 

I tried the == and at least got errors after that but not any thaat I understand unless

we are talking about $connect being undeclared because I am now using ==

If so how do I declare it please

 

I think the last error may be the at the root of the problem,  so experts please ........

Errors below..

Notice: Undefined variable: result in /home/topshed/public_html/britishsteam.com/lner/A3/A3-60112_3.php on line 30

 

Notice: Undefined variable: result in /home/topshed/public_html/britishsteam.com/lner/A3/A3-60112_3.php on line 31

 

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/topshed/public_html/britishsteam.com/lner/A3/A3-60112_3.php on line 31

 

And the pesky bit of code

 

 

25 <?php
26   $connect = mysqli_connect($host,$account,$password) OR DIE("Error !! Unable to connect to database");
27   $db = mysqli_select_db($connect,"$dbname") OR DIE( "Unable to select database ");
28  		echo "The Select query =    ";
29   		echo $db="SELECT * FROM $tble WHERE br_no = $brnum OR lner# = $brnum";
30	if ($result == mysqli_query($connect,$db)) {  
31		if (mysqli_num_rows($result)) {
32				while ($row = mysqli_fetch_assoc($result)){
33 ?>


 

Futher..

I tried declaring the var $result after

include_once("../../include/bsgal_conn.php");

$result = I tried using NULL , 1, or 2 still got me the error

but this clears the error but still no table and no more errors

$result = ' ';

 

Roy...

Because you are using == on the mysqli_query function you aren't assigning anything to $result thus meaning $result being undefined... You are just seeing if it matches the function result. The 3 errors you posted are all in relation to the ==  change.

Your original code was fine in that respect.

 

Were you getting output at the bottom of the script like I originally asked?

Ok, Ive cleaned up your code a little bit and added some debugging stuff in there..

<div id="head">
<?php 
$tble = 'lner3';
$brnum = '60112';
include_once("../../include/bsgal_conn.php");
?>
</div>
<?php
$connect = mysqli_connect($host,$account,$password) OR DIE("Error !! Unable to connect to database");
$selected_db = mysqli_select_db($connect,"$dbname") OR DIE( "Unable to select database ");	
$db="SELECT * FROM `$tble` WHERE `br_no` = '{$brnum}' OR `lner3` = '{$brnum}'";

$result = mysqli_query($connect,$db) or die(mysqli_error());
if (mysqli_num_rows($result) > 0) {
	while ($row = mysqli_fetch_assoc($result)) { ?>
		<div id="main">
		<table width="410" align="center" border="4" cellspacing="0" cellpadding="1">
		  <tr>
		    <th>Class</th>
		    <th>C.M.Engineer</th>
		    <th>Arrangment</th>
		  </tr>
		  <tr>
		    <td><?php echo $row['lclas']."/".$row['class2']; ?></td>
		    <td><?php echo $row['cme']; ?></td>
		    <td><?php echo $row['wheel']; ?></td>
		  </tr>
		</table>
	<?php
	}
} else {
	echo 'Query returned 0 results.';
}
?>
</body>
</html>

I also noticed that <div id="main"> looks to be in the wrong spot.

Give this code a show and see what happens.

Okay,

loaded the script as suggested and got 1 error

 

Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/topshed/public_html/britishsteam.com/lner/A3/A3-60112_3.php on line 28

 

Line 28 is if (mysqli_num_rows($result) > 0) {

 

Thanks

Roy...

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.