6 Replies - 754 Views - Last Post: 24 June 2011 - 07:06 AM Rate Topic: -----

#1 HUSSEin AHMeD  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 10-May 11

help pls page not working on server

Posted 23 June 2011 - 06:19 PM

hello guys i need help with this page for my graduation project
it all working in localhost but on server there is error i cant find i got this :

Posted Image

and i should get a table full of user from database working very good on localhost
here is the code pls if any one know where is the error help me fast ...

<html>
<center>

<!-- Javascript goes in the document HEAD -->
<script type="text/javascript">
function altRows(id){
	if(document.getElementsByTagName){  
		
		var table = document.getElementById(id);  
		var rows = table.getElementsByTagName("tr"); 
		 
		for(i = 0; i < rows.length; i++){          
			if(i % 2 == 0){
				rows[i].className = "evenrowcolor";
			}else{
				rows[i].className = "oddrowcolor";
			}      
		}
	}
}

window.onload=function(){
	altRows('alternatecolor');
}
</script>
<?php
include("inc/config.php");
session_start();

if(isset($_SESSION["admin_id"]))
	{
		$sql="SELECT * FROM admin where admin_id=".$_SESSION['admin_id'];
		$result=mysql_query($sql);
		$row=mysql_fetch_assoc($result);
?>
		<!--head-->
		<head>
		<title>ALL USERS PAGE</title>
		<meta http-equiv="Content-Language" content="English" />
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
		<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
		</head>
		<body>
		<div id="wrap">
		<div id="header">
		<p align="left"><IMG width="150" SRC="images/logo.png"></p>
		</div>
		<div id="top"> </div>
		<div id="menu">
		<ul>
		<li><a href="../cp/cpanel.php">Main</a></li>
		<li><a href="../cp/admin.php">Admins</a></li>
		<li><a href="../cp/user.php">Users</a></li>
		<li><a href="../cp/driver.php">Drivers</a></li>
		<li><a href="../cp/route.php">Routes</a></li>
		</ul>
		</div>
		<div id="content">
		<div class="left"> 
		<!--/head-->
<?

		// database connection info
		$conn = mysql_connect('localhost','name','pass') or trigger_error("SQL", E_USER_ERROR);
		$db = mysql_select_db('project',$conn) or trigger_error("SQL", E_USER_ERROR);

		// find out how many rows are in the table 
		$sql = "SELECT COUNT(*) FROM user";
		$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
		$r = mysql_fetch_row($result);


		$numrows = $r[0];

		// number of rows to show per page
		$rowsperpage = 10;
		// find out total pages
		$totalpages = ceil($numrows / $rowsperpage);

		// get the current page or set a default
		if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
		   // cast var as int
		   $currentpage = (int) $_GET['currentpage'];
		} else {
		   // default page num
		   $currentpage = 1;
		} // end if

		// if current page is greater than total pages...
		if ($currentpage > $totalpages) {
		   // set current page to last page
		   $currentpage = $totalpages;
		} // end if
		// if current page is less than first page...
		if ($currentpage < 1) {
		   // set current page to first page
		   $currentpage = 1;
		} // end if

		// the offset of the list, based on current page 
		$offset = ($currentpage - 1) * $rowsperpage;

?>
		
		<!-- result table --> 
		<br>
		<center><b><h3>USERS</h3></b></center>
		<center>
		<table class="altrowstable" id="alternatecolor" width="100%" border="1" bordercolor="#666666">
		<tr>
		<th>#</th>
        <th>Full&nbsp;Name  </th>
        <th>User&nbsp;Name  </th>
        <th>User&nbsp;Pass  </th>
        <th>Email           </th>
        <th>Phone           </th>
        <th>Checkpoint		</th>
        <th>Edit			</th>
		<th>Delete			</th>
		</tr>
		<?
		  $result = mysql_query("select * from user LIMIT $offset, $rowsperpage" );  //  LIMIT 10
		  $num = mysql_num_rows($result);
			$i=0;  
			while( $i < $num )  
		{  
			$id  = mysql_result( $result , $i , "user_id"           );
			$fname = mysql_result( $result , $i , "name"            );  
			$uname = mysql_result( $result , $i , "web_username"    );  
			$pass = mysql_result( $result , $i , "web_password"     ); 
			$email = mysql_result( $result , $i , "email"           ); 
			$phone = mysql_result( $result , $i , "phone"           ); 
			$check = mysql_result( $result , $i , "checkpoint_code" ); 
			echo"<tr>";
			echo "<form method='post' action='de_mul_user.php'>"; 
			?>
                <td align="center" >
                <input type='checkbox' name='checkbox[]'  value="<?echo"$id";?>" />
                </td>
			<?

			echo"<td>$fname  </td>";  
			echo"<td>$uname  </td>";  
			echo"<td>$pass   </td>";   
			echo"<td>$email  </td>";   
			echo"<td>$phone  </td>";   
			echo"<td>$check  </td>"; 
						
			echo"<td width='5%'><a href='ed_user.php?id=$id'><center><img border='0' src='../cp/images/edit.png'></center></a></td>"; 
			echo"";
			echo"<td><a href='de_user.php?id=$id' onclick=\"return confirm('WARNING: You sure you want to DELETE $uname ?')\" ><center><img border='0' src='../cp/images/delete.png'></center></a></td>";  
			echo"</tr>";
			++$i;  
		}
			?>
			</table>
			</center>
			<center>
			<BR>
			<tr>
			<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete Selected" onclick="return confirm('WARNING: You sure you want to DELETE these USER/S ?');"></td>
			</tr>
			</form>
			</center>
			<!-- /result table -->	
			</body>

		<?	
		echo"<br>";

		echo"<center>";
		echo"<div class='pagesorter'>";
		//how many results found..........
		$num_rows = mysql_num_rows($result); 
		//echo results...........
		echo "<div align='left'><a>No. OF USERS: </a>" .$numrows; "</div>";
		echo"</div>";
		//echo "<div align='left'><a>IN THIS PAGE: </a>" .$num_rows;"</div>";
		/******  build the pagination links ******/
		// range of num links to show
		$range = 3;

		// if not on page 1, don't show back links
		if ($currentpage > 1) {
				  
		   // get previous page num
		   $prevpage = $currentpage - 1;
		
		   // show < link to go back to 1 page
		   echo"<div class='pagenos'><k><h><a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'>First</a></k></h></div> ";
		 // show << link to go back to page 1
		   echo"<div class='pagenos'><k><h><a href='{$_SERVER['PHP_SELF']}?currentpage=1'>Previous</a></k></h></div> ";

		} // end if 
			
		// loop to show links to range of pages around current page
		for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) 
		{
			// if it's a valid page number...
			if (($x > 0) && ($x <= $totalpages)) 
			{
					// if we're on current page...
				if ($x == $currentpage) 
				{
					// 'highlight' it but don't make a link				 
					echo"<div class='pagenos'><h>$x</h></div>";				
					// if not current page...
				} 
					else 
				{
					// make it a link
					echo " <div class='pagenos'><k><h><a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a></h></k></div> ";
				} 	// end else
			} 		// end if 
		} 			// end for
						 
		// if not on last page, show forward and last page links        
		if ($currentpage != $totalpages) 
		{
		   // get next page
		   $nextpage = $currentpage + 1;
			// echo forward link for next page 
		   echo "<div class='pagenos'><k><h><a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>Next</a></k></h></div> ";
		   // echo forward link for lastpage
		   echo " <div class='pagenos'><k><h><a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>Last</a></k></h></div> ";
		} // end if
		
		echo"</center>";
		/****** end build pagination links ******/

		?>
		<!--MENU--> 
		</div>
		<div class="right"> 
		<h2>Welcome: <? echo "<b>".$row['admin_name']."</b>"; ?></h2>
		<!-- DATE AND TIME-->
		<ul>
		<div id="clock">Loading...</div>
		<script type="text/javascript">
		function refrClock()
		{
		var d=new Date();
		var s=d.getSeconds();
		var m=d.getMinutes();
		var h=d.getHours();
		var day=d.getDay();
		var date=d.getDate();
		var month=d.getMonth();
		var year=d.getFullYear();
		var days=new Array("Sun.","Mon.","Tues.","Wednes.","Thurs.","Fri.","Satur.");
		var months=new Array
		 
		("1","2","3","4","5","6","7","8","9","10","11","12");
		var am_pm;
		if (s<10) {s="0" + s}
		if (m<10) {m="0" + m}
		if (h>12) {h-=12;am_pm = "PM"}
		else {am_pm="AM"}
		if (h<10) {h="0" + h}
		document.getElementById("clock").innerHTML=
		"<b>Date:</b> " +
		days[day] +
		" " +
		date +
		" / " +
		months[month] +
		" / " +
		year +
		"<br>" +
		"<b>Clock:</b> " +
		h +
		":" +
		m +
		":" +
		s +
		" " +
		am_pm;
		setTimeout("refrClock()",1000);
		}
		refrClock();
		</script>
		</ul>
		<!--/DATE AND TIME-->
		<ul>
		<li><a href="../cp/cpanel.php">Main</a>&nbsp;|&nbsp;<a href="../cp/logout.php">LogOut</a></li>
		</ul>
		<hr>
		<h2>ADMIN</h2>
		<ul>
		  <li><a href="../cp/admin.php">Add Admin</a></li>
		  <li><a href="../cp/find_all_admins.php">Show All Admins</a></li>
		</ul>
		<hr>
		<h2>USER</h2>
		<ul>
		  <li><a href="../cp/user.php">Add User</a></li>
		  <li><a href="../cp/find_all_users.php">Show All Users</a></li>		
		<br>		
		<form name="form1" method="post" action="find_user.php">
		<td>	
		<td><b>User&nbsp;Name</b></td>
		<td width="205"><input name="uname" type="text" id="uname"></td>
		<li><br></li>
		<td colspan="3">
		<p align="center"><input type="submit" name="Submit" value="Find User"></td></p>		
		</td>
		</form>
		</ul>
		<br>		
		<hr>		
		<h2>DRIVER</h2>
		<ul>
		  <li><a href="../cp/driver.php">Add Driver</a></li>
		  <li><a href="../cp/find_all_drivers.php">Show All Drivers</a></li>
		</ul>		
		<hr>		
		<h2>ROUTE</h2>
		<ul>
		  <li><a href="../cp/route.php">Add Route</a></li>
		  <li><a href="../cp/find_all_routes.php">Show All Routes</a></li>
		</ul>
		<!--MENU-->		
		</div>
		<div style="clear: both;"> </div>
		</div>
		<div id="bottom"> </div>
		
		<!--/flash footer-->
		<body bgcolor="#555555">
		<center>
		<object
        classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
        codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"
        id="foooter"
        width="91" height="14"
      >
        <param name="movie" value="foooter.swf">
        <param name="bgcolor" value="#555555">
        <param name="quality" value="high">
        <param name="seamlesstabbing" value="false">
        <param name="allowscriptaccess" value="samedomain">
        <embed
          type="application/x-shockwave-flash"
          pluginspage="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
          name="foooter"
          width="91" height="14"
          src="foooter.swf"
          bgcolor="#555555"
          quality="high"
          seamlesstabbing="false"
          allowscriptaccess="samedomain"
        >
          <noembed>
          </noembed>
        </embed>
		</object>
		</center>
		</body>
		<!--/flash footer-->		
		</div>
		</body>

<?php 
	}
	else
	{	
		include("index.php");
	}
?>
</center>
</html>


This post has been edited by HUSSEin AHMeD: 23 June 2011 - 06:22 PM


Is This A Good Question/Topic? 0
  • +

Replies To: help pls page not working on server

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3034
  • Posts: 10,598
  • Joined: 08-August 08

Re: help pls page not working on server

Posted 23 June 2011 - 06:58 PM

You've got Javascript, HTML, and PHP all jumbled together in one 372 line file??? And it appears that you're using tables for formatting? And you're wondering why you have problems? I'm surprised it works at all! Most of the time people with code like that are asking for help before they get to 100 lines.

You need to work on getting some structure into your code. Start by separating it.
Was This Post Helpful? 0
  • +
  • -

#3 maniacalsounds  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 117
  • View blog
  • Posts: 472
  • Joined: 27-June 10

Re: help pls page not working on server

Posted 23 June 2011 - 08:26 PM

There are times when it is necessary to "jumble" code together, such as lines 143 - 148. However, You shouldn't (practically) surround the entire thing with PHP tags. Sure, some of this is dynamically generated content.

I understand you may be on a time constraint, but the best help you're going to get is telling you two seperate your code. If you do such, it'll be easier to pinpoint the exact location of errors, so you don't have to post the entire code on D.I.C. Plus, it gives you great coding habits.

$the_new_you = $current_you->upgrade($code_seperation).
$the_new_you->echoAwesomeness();

//Output: I can find errors easily now! I don't have to type as much on a post! I've learned good coding habits. I can rub my stupid professor's nose in my easily-readible syntax. :)/>
//Happy coding.


Suggested Reading: http://stackoverflow...p-code-and-html
Was This Post Helpful? 0
  • +
  • -

#4 HUSSEin AHMeD  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 10-May 11

Re: help pls page not working on server

Posted 24 June 2011 - 01:40 AM

well i don't really think i understand im a beginner self study ,
and it was working on localhost so it seemed ok to work on the rest of project and neglect it , not its not working and Sunday is my dead line , is there any way to fix it without re constructing ?
Was This Post Helpful? 0
  • +
  • -

#5 youngone  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 60
  • Joined: 12-June 11

Re: help pls page not working on server

Posted 24 June 2011 - 03:01 AM

What was the error/problem again? You launch the site and there is no table of users but there should be one? Seems like you are not even connected to your database and it dies before anything else is executed. Could you provide us your inc/config.php with passwords *** shadowed?
Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3034
  • Posts: 10,598
  • Joined: 08-August 08

Re: help pls page not working on server

Posted 24 June 2011 - 05:35 AM

Honestly, I don't know why it would work on localhost because you send HTML to the browser before calling session_start(). That's just one more reason you should separate your PHP from HTML: it's too easy to make mistakes like that when you don't.
Was This Post Helpful? 0
  • +
  • -

#7 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3034
  • Posts: 10,598
  • Joined: 08-August 08

Re: help pls page not working on server

Posted 24 June 2011 - 07:06 AM

View Postmaniacalsounds, on 23 June 2011 - 11:26 PM, said:

There are times when it is necessary to "jumble" code together, such as lines 143 - 148.

Maybe, but I've never seen code that couldn't be rewritten in a way that only breaks into/out of PHP once. When that has been done it never fails to be easier to read, edit, and debug.

Beginners tend to go for expediency over good design, and that's what gets them into big trouble. This code wreaks of the "just get it to work" attitude. The irony is that as usual, that attitude is why it won't work.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1