SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 33 of 33
  1. #26
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Jenny

    Can you re-post your code as it currently stands, with all the modifications you have made.

    One thing that strikes me, is that you have setup 2 variables

    PHP Code:
       $start == 1;
      
    $perpage ==1
    Are you trying to assign the value 1 to each of these variables?
    If yes, then the code should be

    PHP Code:
      $start 1;
      
    $perpage 1
    == is used for testing, = is used for assigning.

    Hope this helps

  2. #27
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    code

    Here is the code that I currently have. I tried uploading with just 1 = sign, and with 2 = signs and got the same error message:

    Error in SELECT id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current FROM allen where id='' LIMIT , 10. Mysql saysYou have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' 10' at line 1


    Code:
    <? 
    $start = 1;
    $perpage = 1;
    
    $host="localhost"; 
    $user="test_user"; 
    $password="test_pw"; 
    $dbname="test_db"; 
    $dbtable="test_table";  
    
    $dbh=mysql_connect ("localhost", "test_user", "test_pw") or die ('I cannot connect to the database because: ' . mysql_error()); 
    mysql_select_db ("test_db"); 
    ?> 
    <html> 
    <head> 
    <title>site</title> 
    </head> 
    <body> 
    <? 
    
    if($hdAction==1) 
    { 
    
    
    $sql = "SELECT id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current FROM $dbtable where id='$id' LIMIT $Start, 10"; 
    $result = mysql_query($sql, $dbh) or die( "Error in <b>$sql</b>. Mysql says". mysql_error() ); 
    
    } 
    else 
    { 
    $sql = "SELECT id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current FROM $dbtable where id='$id' LIMIT $Start, 10"; 
    $result = mysql_query($sql, $dbh) or die( "Error in <b>$sql</b>. Mysql says". mysql_error() ); 
    } 
    $first = mysql_result($result, 0, "first"); 
    $last = mysql_result($result, 0, "last"); 
    $thumba = mysql_result($result, 0, "thumba"); 
    $thumbb = mysql_result($result, 0, "thumbb"); 
    $thumbc = mysql_result($result, 0, "thumbc"); 
    $thumbd = mysql_result($result, 0, "thumbd"); 
    $team = mysql_result($result, 0, "team"); 
    $number = mysql_result($result, 0, "number"); 
    $league = mysql_result($result, 0, "league"); 
    $year = mysql_result($result, 0, "year"); 
    $home = mysql_result($result, 0, "home"); 
    $brand = mysql_result($result, 0, "brand"); 
    $loa = mysql_result($result, 0, "loa"); 
    $size = mysql_result($result, 0, "size"); 
    $description = mysql_result($result, 0, "description"); 
    $draft = mysql_result($result, 0, "draft"); 
    $current = mysql_result($result, 0, "current"); 
    
    ?> 
    &nbsp; 
    &nbsp; 
    <form name="form1" method="post" action=""> 
    <table width="100%" border="0" cellspacing="10" cellpadding="0"> 
    <tr> 
    <td valign="top"> 
    
    <table width="100%" height="30" border="0" cellpadding="0" cellspacing="3"> 
    <tr> 
    <td><a href="display_jersey.php?hdAction=1&id=<? print mysql_result($result, 0, "id");?>-1">Previous</a></td> 
    <td>Home</td> 
    <td><a href="display_jersey.php?hdAction=1&id=<? print mysql_result($result, 0, "id");?>%2B1" >Next</a> 
    
    <input type="hidden" name="hdAction"> 
    <input type="hidden" name="Ident"> </td> 
    </tr> 
    </table></td> 
    </tr> 
    <tr> 
    <td> <table width="100%"> 
    <tr> 
    <td colspan="4"><? print "$first"; ?> <? print "$last"; ?></td> 
    </tr> 
    <tr> 
    <td colspan="4"><table width="100%" border="0" cellspacing="2" cellpadding="0"> 
    <tr> 
    <td><? print "$thumba"; ?> </td> 
    <td><? print "$thumbb"; ?> </td> 
    <td><? print "$thumbc"; ?> </td> 
    <td><? print "$thumbd"; ?> </td> 
    </tr> 
    </table></td> 
    </tr> 
    <tr> 
    <td>Team</td> 
    <td>Number</td> 
    <td>League</td> 
    <td>Year</td> 
    </tr> 
    <tr> 
    <td><? print "$team"; ?></td> 
    <td><? print "$number"; ?></td> 
    <td><? print "$league"; ?></td> 
    <td> <? print "$year"; ?></td> 
    </tr> 
    <tr> 
    <td>Home</td> 
    <td>Brand</td> 
    <td>LOA</td> 
    <td>Size</td> 
    </tr> 
    <tr> 
    <td><? print "$home"; ?></td> 
    <td><? print "$brand"; ?></td> 
    <td><? print "$loa"; ?></td> 
    <td> <? print "$size"; ?></td> 
    </tr> 
    <tr> 
    <td colspan="4">Description</td> 
    </tr> 
    <tr> 
    <td colspan="4"><? print "$description"; ?></td> 
    </tr> 
    <tr> 
    <td colspan="2">Draft</td> 
    <td height="21" colspan="2">Current</td> 
    </tr> 
    <tr> 
    <td colspan="2"><? print "$draft"; ?></td> 
    <td colspan="2"><? print "$current"; ?></td> 
    </tr> 
    </table></td> 
    </tr> 
    </table> </form> 
    </body> 
    </html>
    Glory Lasts Forever.

  3. #28
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In your queries, try putting the $dbtable and $start variables inbetween single quotes (as you did with $id). Also, that second variable is $start (lowerkey), not $Start. By the way, where does $id come from? Post or get? If so, you'd have to respectively call it as $_GET[id] or $_POST[id].

    HTH

  4. #29
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    At the top of the code, you have
    PHP Code:
        $start 1
    In your SQL queries, you have $Start.

    Notice the difference?

    Either change $start to $Start or vice versa. Be consistent in your naming convesntions. It will save you much heartache


    Also $id is never set, so you will be selecting data from the database where id is blank, probably not what you expect.

    A good idea (IMHO) when you are having problems, is to echo out the POST variables at the start of your page like this

    PHP Code:
       print_r($_POST]);
       echo 
    '<br />'
    Hope this helps

  5. #30
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I understand where everyone's trying to go..and it makes sense logistically to me...what I don't understand, and what I feel I'm doing wrong - is WHERE to put this code. I can change the $Start to $start - that i get...but if I were to try the "POST" or "GET"...where in the code do I do that? Where would i put the print_r($_POST]);
    echo '<br />';


    This is where I'm struggling. When you say "start of the page"...do you mean above the <? or after it...or after the $sql string.

    I know i'm being stupid here, adn I really AM trying everything and giving it a shot everywhere I think it's supposed to be. I'm not just trying one thing and giving up, I promise. I'm just getting so frustrated because nothing seems to work.
    Glory Lasts Forever.

  6. #31
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never give up!

    PHP Code:

    <?
    /*
    Let's say you landed on this page by clicking a link
    called details.php?id=1
    If you got here by clicking a form button, you'd use $_POST instead of $_GET
    First check whether the id is set correctly in the url, if not give it value 1
    */
    if(empty($_GET[id]) or !is_numeric($_GET[id])){//not set or not numeric
        
    $id 1;
    }
    else{
        
    $id $_GET[id];
    }
    $start 1;
    $perpage 1;

    $host="localhost"
    $user="test_user"
    $password="test_pw"
    $dbname="test_db"
    $dbtable="test_table";  

    $dbh=mysql_connect ("localhost""test_user""test_pw") or die ('I cannot connect to the database because: ' mysql_error()); 
    mysql_select_db ("test_db"); 
    ?> 
    <html> 
    <head> 
    <title>site</title> 
    </head> 
    <body> 
    <? 

    if($hdAction==1



    $sql "SELECT id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current FROM $dbtable where id='$id' LIMIT $start, 10"
    $result mysql_query($sql$dbh) or die( "Error in <b>$sql</b>. Mysql says"mysql_error() ); 


    else 

    $sql "SELECT id, first, last, thumba, thumbb, thumbc, thumbd, team, number, league, year, home, brand, loa, size, description, draft, current FROM $dbtable where id='$id' LIMIT $start, 10"
    $result mysql_query($sql$dbh) or die( "Error in <b>$sql</b>. Mysql says"mysql_error() ); 

    $first mysql_result($result0"first"); 
    $last mysql_result($result0"last"); 
    $thumba mysql_result($result0"thumba"); 
    $thumbb mysql_result($result0"thumbb"); 
    $thumbc mysql_result($result0"thumbc"); 
    $thumbd mysql_result($result0"thumbd"); 
    $team mysql_result($result0"team"); 
    $number mysql_result($result0"number"); 
    $league mysql_result($result0"league"); 
    $year mysql_result($result0"year"); 
    $home mysql_result($result0"home"); 
    $brand mysql_result($result0"brand"); 
    $loa mysql_result($result0"loa"); 
    $size mysql_result($result0"size"); 
    $description mysql_result($result0"description"); 
    $draft mysql_result($result0"draft"); 
    $current mysql_result($result0"current"); 

    ?> 
    &nbsp; 
    &nbsp; 
    <form name="form1" method="post" action=""> 
    <table width="100%" border="0" cellspacing="10" cellpadding="0"> 
    <tr> 
    <td valign="top"> 

    <table width="100%" height="30" border="0" cellpadding="0" cellspacing="3"> 
    <tr> 
    <td><a href="display_jersey.php?hdAction=1&id=<? print mysql_result($result0"id");?>-1">Previous</a></td> 
    <td>Home</td> 
    <td><a href="display_jersey.php?hdAction=1&id=<? print mysql_result($result0"id");?>%2B1" >Next</a> 

    <input type="hidden" name="hdAction"> 
    <input type="hidden" name="Ident"> </td> 
    </tr> 
    </table></td> 
    </tr> 
    <tr> 
    <td> <table width="100%"> 
    <tr> 
    <td colspan="4"><? print "$first"?> <? print "$last"?></td> 
    </tr> 
    <tr> 
    <td colspan="4"><table width="100%" border="0" cellspacing="2" cellpadding="0"> 
    <tr> 
    <td><? print "$thumba"?> </td> 
    <td><? print "$thumbb"?> </td> 
    <td><? print "$thumbc"?> </td> 
    <td><? print "$thumbd"?> </td> 
    </tr> 
    </table></td> 
    </tr> 
    <tr> 
    <td>Team</td> 
    <td>Number</td> 
    <td>League</td> 
    <td>Year</td> 
    </tr> 
    <tr> 
    <td><? print "$team"?></td> 
    <td><? print "$number"?></td> 
    <td><? print "$league"?></td> 
    <td> <? print "$year"?></td> 
    </tr> 
    <tr> 
    <td>Home</td> 
    <td>Brand</td> 
    <td>LOA</td> 
    <td>Size</td> 
    </tr> 
    <tr> 
    <td><? print "$home"?></td> 
    <td><? print "$brand"?></td> 
    <td><? print "$loa"?></td> 
    <td> <? print "$size"?></td> 
    </tr> 
    <tr> 
    <td colspan="4">Description</td> 
    </tr> 
    <tr> 
    <td colspan="4"><? print "$description"?></td> 
    </tr> 
    <tr> 
    <td colspan="2">Draft</td> 
    <td height="21" colspan="2">Current</td> 
    </tr> 
    <tr> 
    <td colspan="2"><? print "$draft"?></td> 
    <td colspan="2"><? print "$current"?></td> 
    </tr> 
    </table></td> 
    </tr> 
    </table> </form> 
    </body> 
    </html>
    See if that works for you...

  7. #32
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    new errors

    I can't believe you guys haven't given up on me yet

    Ok, I tried it with both "GET" and "POST" and for the exact same result...

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 56

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 57

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 58

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 59

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 60

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 61

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 62

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 63

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 64

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 65

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 66

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 67

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 68

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 69

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 70

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 71

    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/sitename/public_html/******/display_jersey.php on line 72

    These relate to the code that is as follows:
    Code:
    $first = mysql_result($result, 0, "first"); 
    $last = mysql_result($result, 0, "last"); 
    $thumba = mysql_result($result, 0, "thumba"); 
    $thumbb = mysql_result($result, 0, "thumbb"); 
    $thumbc = mysql_result($result, 0, "thumbc"); 
    $thumbd = mysql_result($result, 0, "thumbd"); 
    $team = mysql_result($result, 0, "team"); 
    $number = mysql_result($result, 0, "number"); 
    $league = mysql_result($result, 0, "league"); 
    $year = mysql_result($result, 0, "year"); 
    $home = mysql_result($result, 0, "home"); 
    $brand = mysql_result($result, 0, "brand"); 
    $loa = mysql_result($result, 0, "loa"); 
    $size = mysql_result($result, 0, "size"); 
    $description = mysql_result($result, 0, "description"); 
    $draft = mysql_result($result, 0, "draft"); 
    $current = mysql_result($result, 0, "current");
    Glory Lasts Forever.

  8. #33
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using mysql_fetch_row or mysql_fetch_array instead of mysql_result. Assuming only one row in the db corresponds to the $id, that would mean something like this:

    PHP Code:
    <?
    /*
    Let's say you landed on this page by clicking a link
    called details.php?id=1
    If you got here by clicking a form button, you'd use $_POST instead of $_GET
    First check whether the id is set correctly in the url, if not give it value 1
    */
    if(empty($_GET[id]) or !is_numeric($_GET[id])){//not set or not numeric
        
    $id 1;
    }
    else{
        
    $id $_GET[id];
    }
    $start 1;
    $perpage 1;

    $host="localhost"
    $user="test_user"
    $password="test_pw"
    $dbname="test_db"
    $dbtable="test_table";  

    $dbh=mysql_connect ("localhost""test_user""test_pw") or die ('I cannot connect to the database because: ' mysql_error()); 
    mysql_select_db ("test_db"); 
    ?> 
    <html> 
    <head> 
    <title>site</title> 
    </head> 
    <body> 
    <? 

    if($hdAction==1



    $sql "SELECT * FROM $dbtable where id='$id' LIMIT $start, 10"
    $result mysql_query($sql$dbh) or die( "Error in <b>$sql</b>. Mysql says"mysql_error() ); 


    else 

    $sql "SELECT * FROM $dbtable where id='$id' LIMIT $start, 10"
    $result mysql_query($sql$dbh) or die( "Error in <b>$sql</b>. Mysql says"mysql_error() ); 
    }
    //use mysql_fetch_row or mysql_fetch_array instead of mysql_result
    //this gives you the $row array containing all the db data for $id
    $row mysql_fetch_row($result);
    ?> 
    &nbsp; 
    &nbsp; 
    <form name="form1" method="post" action=""> 
    <table width="100%" border="0" cellspacing="10" cellpadding="0"> 
    <tr> 
    <td valign="top"> 

    <table width="100%" height="30" border="0" cellpadding="0" cellspacing="3"> 
    <tr> 
    <td><a href="display_jersey.php?hdAction=1&id=<? echo $row[id] - 1?>">Previous</a></td> 
    <td>Home</td> 
    <td><a href="display_jersey.php?hdAction=1&id=<? echo $row[id] + 1?>">Next</a> 

    <input type="hidden" name="hdAction"> 
    <input type="hidden" name="Ident"> </td> 
    </tr> 
    </table></td> 
    </tr> 
    <tr> 
    <td> <table width="100%"> 
    <tr> 
    <td colspan="4"><? echo $row[first]; ?> <? echo $row[last]; ?></td> 
    </tr> 
    <tr> 
    <td colspan="4"><table width="100%" border="0" cellspacing="2" cellpadding="0"> 
    <tr> 
    <td><? echo $row[thumba]; ?> </td> 
    <td><? echo $row[thumbb]; ?> </td> 
    <td><? echo $row[thumbc]; ?> </td> 
    <td><? echo $row[thumbd]; ?> </td> 
    </tr> 
    </table></td> 
    </tr> 
    <tr> 
    <td>Team</td> 
    <td>Number</td> 
    <td>League</td> 
    <td>Year</td> 
    </tr> 
    <tr> 
    <td><? echo $row[team]; ?></td> 
    <td><? echo $row[number]; ?></td> 
    <td><? echo $row[league]; ?></td> 
    <td> <? echo $row[year]; ?></td> 
    </tr> 
    <tr> 
    <td>Home</td> 
    <td>Brand</td> 
    <td>LOA</td> 
    <td>Size</td> 
    </tr> 
    <tr> 
    <td><? echo $row[home]; ?></td> 
    <td><? echo $row[brand]; ?></td> 
    <td><? echo $row[loa]; ?></td> 
    <td> <? echo $row[size]; ?></td> 
    </tr> 
    <tr> 
    <td colspan="4">Description</td> 
    </tr> 
    <tr> 
    <td colspan="4"><? echo $row[description]; ?></td> 
    </tr> 
    <tr> 
    <td colspan="2">Draft</td> 
    <td height="21" colspan="2">Current</td> 
    </tr> 
    <tr> 
    <td colspan="2"><? echo $row[draft]; ?></td> 
    <td colspan="2"><? echo $row[current]; ?></td> 
    </tr> 
    </table></td> 
    </tr> 
    </table> </form> 
    </body> 
    </html>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •