Topshed Posted September 28, 2011 Share Posted September 28, 2011 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... Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 28, 2011 Share Posted September 28, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/#findComment-1273402 Share on other sites More sharing options...
Topshed Posted September 28, 2011 Author Share Posted September 28, 2011 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... Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/#findComment-1273443 Share on other sites More sharing options...
Buddski Posted September 28, 2011 Share Posted September 28, 2011 Is it outputting code AFTER your code block? (ie after the closing braces <?php } } } ?> Output here works!! Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/#findComment-1273451 Share on other sites More sharing options...
vin.code Posted September 28, 2011 Share Posted September 28, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/#findComment-1273452 Share on other sites More sharing options...
Buddski Posted September 28, 2011 Share Posted September 28, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/#findComment-1273454 Share on other sites More sharing options...
Topshed Posted September 28, 2011 Author Share Posted September 28, 2011 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 ?> Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/#findComment-1273472 Share on other sites More sharing options...
Topshed Posted September 28, 2011 Author Share Posted September 28, 2011 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... Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/#findComment-1273475 Share on other sites More sharing options...
Buddski Posted September 28, 2011 Share Posted September 28, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/#findComment-1273477 Share on other sites More sharing options...
Buddski Posted September 28, 2011 Share Posted September 28, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/#findComment-1273478 Share on other sites More sharing options...
Topshed Posted September 28, 2011 Author Share Posted September 28, 2011 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... Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/#findComment-1273508 Share on other sites More sharing options...
Buddski Posted September 28, 2011 Share Posted September 28, 2011 Sorry $result = mysqli_query($connect,$db) or die(mysqli_error($connect)); Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/#findComment-1273509 Share on other sites More sharing options...
Topshed Posted September 28, 2011 Author Share Posted September 28, 2011 Thank you so much it now works well and I also have a smarter script than before Kind Regards Roy... Quote Link to comment https://forums.phpfreaks.com/topic/247994-php-script-not-working-but-no-error-messages/#findComment-1273550 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.