having problems with this sections on the script.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • josh dismukes

    #1

    having problems with this sections on the script.

    //Query the Database
    $query = "SELECT type FROM map WHERE map_file = " .
    $_SESSION['new_map'] . " AND col = " . $_SESSION['new_col'] . " AND
    row = " . $_SESSION['new_row'];
    $db_result = @mysql_query($q uery);
    $db_cell_type = @mysql_fetch_ar ray($result);

    //Evaluate the Cell Type
    if ($db_cell_type= ='W'){
    $_SESSION['new_col']=$_SESSION['old_col'];
    $_SESSION['new_row']=$_SESSION['old_row'];
    $_SESSION['new_map']=$_SESSION['old_map'];
    $_SESSION['celltype']='W';}
    elseif($db_cell _type=='T'){
    $query2 = "SELECT townID FROM map WHERE map_file = " .
    $_SESSION['new_map'] . " AND col = " . $_SESSION['new_col'] . " AND
    row = " . $_SESSION['new_row'];
    $db_result2 = @mysql_query($q uery2);
    $db_townid = mysql_fetch_arr ay($db_result2) ;
    $_SESSION['townID'] = $db_townid;
    $_SESSION['is_town'] = 1;
    $_SESSION['celltype']='T';}
    else {
    $_SESSION['old_col']=$_SESSION['new_col'];
    $_SESSION['old_row']=$_SESSION['new_row'];
    $_SESSION['old_map']=$_SESSION['new_map'];
    $_SESSION['celltype']='L';}
  • Andy Hassall

    #2
    Re: having problems with this sections on the script.

    On 30 Mar 2004 10:59:30 -0800, sk8er1796@yahoo .com (josh dismukes) wrote:
    [color=blue]
    >//Query the Database
    > $query = "SELECT type FROM map WHERE map_file = " .
    >$_SESSION['new_map'] . " AND col = " . $_SESSION['new_col'] . " AND
    >row = " . $_SESSION['new_row'];
    > $db_result = @mysql_query($q uery);
    > $db_cell_type = @mysql_fetch_ar ray($result);
    >
    >//Evaluate the Cell Type
    >if ($db_cell_type= ='W'){
    > $_SESSION['new_col']=$_SESSION['old_col'];
    > $_SESSION['new_row']=$_SESSION['old_row'];
    > $_SESSION['new_map']=$_SESSION['old_map'];
    > $_SESSION['celltype']='W';}
    > elseif($db_cell _type=='T'){
    > $query2 = "SELECT townID FROM map WHERE map_file = " .
    >$_SESSION['new_map'] . " AND col = " . $_SESSION['new_col'] . " AND
    >row = " . $_SESSION['new_row'];
    > $db_result2 = @mysql_query($q uery2);
    > $db_townid = mysql_fetch_arr ay($db_result2) ;
    > $_SESSION['townID'] = $db_townid;
    > $_SESSION['is_town'] = 1;
    > $_SESSION['celltype']='T';}
    >else {
    > $_SESSION['old_col']=$_SESSION['new_col'];
    > $_SESSION['old_row']=$_SESSION['new_row'];
    > $_SESSION['old_map']=$_SESSION['new_map'];
    > $_SESSION['celltype']='L';}[/color]

    So, do you have a question?

    --
    Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
    http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

    Comment

    • Pedro Graca

      #3
      Re: having problems with this sections on the script.

      josh dismukes wrote:[color=blue]
      > //Query the Database
      > $query = "SELECT type FROM map WHERE map_file = " .
      > $_SESSION['new_map'] . " AND col = " . $_SESSION['new_col'] . " AND
      > row = " . $_SESSION['new_row'];
      > $db_result = @mysql_query($q uery);[/color]

      What if your query fails?
      You will never know about it until later, when your script fails for
      some reason that can have little relation to the failed query.
      Try inserting here:

      if (!$db_result) die('query failed because ' . mysql_error());


      I suspect not all of $_SESSION['new_map'], $_SESSION['new_col'], and
      $_SESSION['new_row'] are integers. If they are strings they need quotes
      around them.
      [color=blue]
      > $db_cell_type = @mysql_fetch_ar ray($result);[/color]

      $db_cell_type is an array!
      [color=blue]
      > //Evaluate the Cell Type
      > if ($db_cell_type= ='W'){[/color]

      When you use it in comparisons with string it will be automagically
      converted to "Array" (and "Array" != "W" always)

      Probably you want

      if ($db_cell_type['type'] == 'W') {
      [color=blue]
      > $_SESSION['new_col']=$_SESSION['old_col'];
      > $_SESSION['new_row']=$_SESSION['old_row'];
      > $_SESSION['new_map']=$_SESSION['old_map'];
      > $_SESSION['celltype']='W';}
      > elseif($db_cell _type=='T'){[/color]

      same mistake as before
      [color=blue]
      > $query2 = "SELECT townID FROM map WHERE map_file = " .
      > $_SESSION['new_map'] . " AND col = " . $_SESSION['new_col'] . " AND
      > row = " . $_SESSION['new_row'];
      > $db_result2 = @mysql_query($q uery2);
      > $db_townid = mysql_fetch_arr ay($db_result2) ;
      > $_SESSION['townID'] = $db_townid;[/color]

      and again
      [color=blue]
      > $_SESSION['is_town'] = 1;
      > $_SESSION['celltype']='T';}
      > else {
      > $_SESSION['old_col']=$_SESSION['new_col'];
      > $_SESSION['old_row']=$_SESSION['new_row'];
      > $_SESSION['old_map']=$_SESSION['new_map'];
      > $_SESSION['celltype']='L';}[/color]

      HTH
      --
      USENET would be a better place if everybody read: : mail address :
      http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
      http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
      http://www.expita.com/nomime.html : to 10K bytes :

      Comment

      Working...