work with local but it's not with on line server

Discussion in 'PHP' started by abosirage, Nov 11, 2010.

  1. abosirage

    abosirage Member

    Joined:
    Jul 29, 2010
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Occupation:
    IT
    Location:
    Tripoli-Libya
    :confused: dear friends
    I have this question my following code work with local but it's not with on line server the

    the pages code is attached

    please have a look & tell me how to do with it
    remember that code works OK on local host
     

    Attached Files:

  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    What error does it give when run online.
     
  3. abosirage

    abosirage Member

    Joined:
    Jul 29, 2010
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Occupation:
    IT
    Location:
    Tripoli-Libya
    dear shabbir
    good day

    the error showing when I run it online is:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/umma/public_html/db/data/view.php on line 11
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    This means it is nothing to do with your online or offline issue but your code is not well coded to work.

    What is the code you have on line 11
     
  5. abosirage

    abosirage Member

    Joined:
    Jul 29, 2010
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Occupation:
    IT
    Location:
    Tripoli-Libya
    dear Shabbir

    good day

    I attached text file for my pages code with my post
    anyhow the code in line 11 is:
    $myrow = mysql_fetch_array($result);
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Don't expect that someone will download your txt file. Split code into each files. Upload. test and tell you what could be the changes needed. Will you do the same for someone's query?

    Coming back to your issue.

    You are having this query.

    $result = mysql_query("SELECT * FROM personnel WHERE id=$id");
    $myrow = mysql_fetch_array($result);
    So I can sense that your query and id variables does not have the right values to return the right result set.
     
  7. abosirage

    abosirage Member

    Joined:
    Jul 29, 2010
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Occupation:
    IT
    Location:
    Tripoli-Libya
    dear Shabbir

    my view.php code like this:
    Code:
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    </head>
    <div align="center" dir="rtl">
    <table border="0" width="65%" id="table1">
    <tr><td><?php 
    include ('config.php');
    mysql_select_db("umma_mydb"); 
    $result = mysql_query("SELECT * FROM personnel WHERE id=$id"); 
    $myrow = mysql_fetch_array($result);
    echo "الاسم : ".$myrow["firstname"]; 
    echo "<br>اللقب : ".$myrow["lastname"]; 
    echo "<br>العنوان : ".$myrow["nick"]; 
    echo "<br>البريد الالكتروني : ".$myrow["email"]; 
    echo "<br>المرتب : ".$myrow["salary"]; 
    ?></td></tr></table>
    <b><span lang="ar-sa"><a href="serch.php">بحــــث</a>&nbsp;&nbsp; <a href="viewdb.php">عودة للقائمة</a></span></b></p>
    </div>
    </HTML>
     and the page with $id value viewdb.php code :
    <HTML> 
    <div align="center">
    	<table border="0" width="63%" id="table1">
    		<tr>
    			<td>
    			<?php 
    include ('config.php');
    $result = mysql_query("SELECT * FROM personnel"); 
    echo "<TABLE BORDER=2>"; 
    echo"<TR><td align=center width=190><B>الاجـــــــراء</B><td align=center width=190><B>الاسم بالكامـــــل</B>
    <td align=center width=220><B>العنــــــــوان</B></TR>"; 
    while($myrow = mysql_fetch_array($result)) 
    { 
    echo "<TR>
    <td align=center width=190><a href=\"view.php?id=".$myrow['id']."\">عرض</a> ";
    echo "<a href=\"delete.php?id=".$myrow['id']."\">حذف</a> ";
    echo "<a href=\"edit.php?id=".$myrow['id']."\">تعديل</ a>";
    echo "<td align=center width=190>".$myrow["firstname"]." ".$myrow["lastname"]."
    </a><td align=center width=190>".$myrow["nick"];
    } 
    echo "</TABLE>"; 
    ?> 
    
    			
    			
    			
    			</td>
    		</tr>
    	</table>
    </div>
    <p align="center"><b><font size="4"><a href="serch.php">بحـــث</a>&nbsp;&nbsp;
    <a href="input.php">إدخال جديد</a></font></b></p>
    <p>&nbsp;</p>
    
    
    </HTML>
     
    Last edited by a moderator: Nov 14, 2010
  8. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    What does $id contain in SELECT * FROM personnel WHERE id=$id
     
  9. abosirage

    abosirage Member

    Joined:
    Jul 29, 2010
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Occupation:
    IT
    Location:
    Tripoli-Libya
    dear Shabbir

    thank you for your reply
    good day

    in my code $id contain (int) id for personnel record
     
  10. abosirage

    abosirage Member

    Joined:
    Jul 29, 2010
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Occupation:
    IT
    Location:
    Tripoli-Libya
    dear Shabbir

    good day

    I would like to thank you very much for your time & help I inform you that my problem solved the missing was to identified $id the following line is missing in my code

    $id=(int)$_GET['id'];

    thank you very much
     
  11. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Great to see that. :D
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice