Current location: Hot Scripts Forums » Programming Languages » PHP » Can't see the error


Can't see the error

Reply
  #1 (permalink)  
Old 07-13-04, 11:06 AM
fccolon fccolon is offline
Newbie Coder
 
Join Date: Mar 2004
Location: West Mids. UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Can't see the error

Hi,

This is one of my first scripts and when I run it I get a parse error on line 9 - blowed if I can work it out at the moment.
Could someone point me to the error ?

<?php

$conn = mysql_connect(server, user, pwd);
echo $conn;
mysql_select_db("leaguedb", $conn);

$display_block = "<h1>Add Driver to Division</h1>

if ($_POST[op1] != "select1")

{

$get_list = "select id, div_name from GPL_division";
$get_list_res = mysql_query($get_list) or die(mysql_error());

$display_block .= "
<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<p><strong> Select Division:</strong><br>
<select name=\"sel_id\">
<option value=\"\">-- Go on, pick your division --</option>";

while ($divrecs = mysql_fetch_array($get_list_res))
{
$id = $divrecs[id];
$div_name = stripslashes($divrecs[div_name]);
$display_block .= "
<option value=\"$id\">$div_name</option>";
}

$display_block .= "
</select>
<input type=\"hidden\" name=\"op1\" value=\"select1\">
<p><INPUT type=\"submit\" value=\"Select\"></p>

</form>";

}

if ($_POST[op2] != "select2")

{

$get_list = "select id, driver_name from GPL_drivers";
$get_list_res = mysql_query($get_list) or die(mysql_error());


$display_block .= "
<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<p><strong> Select Drivers:</strong><br>
<select name=\"sel_id[]\" multiple>
<option value=\"\">-- Go on, pick your drivers --</option>";

while ($drvrecs = mysql_fetch_array($get_list_res))
{
$id = $drvrecs[id];
$driver_name = stripslashes($drvrecs[driver_name]);
$display_block .= "
<option value=\"$id\">$driver_name</option>";
}

$display_block .= "
</select>
<input type=\"hidden\" name=\"op2\" value=\"select2\">
<p><INPUT type=\"submit\" value=\"Select\"></p>

</form>";

}

if ($_POST[op1]= "select1")
if ($_POST[op2]= "select2")

{

$make_link = "INSERT INTO GPL_lsdd ('', '$divid', '$_POST[sel_id]')";

foreach ($_POST[sel_id] as $value)
{
echo $value;

$make_link_res = mysql_query($make_link) or die(mysql_error());

}

}

?>

<html>
<head>
<title>Add Drivers to Division</title>
</head>
<body>
<?php echo $display_block; ?>
</body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-13-04, 12:15 PM
Dj_Farout Dj_Farout is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
I think your problem is here... sometimes PHP will reject this because op1 isn't in quotes.. I know for a fact this wouldn't work in IIS

PHP Code:

 if ($_POST[op1] != "select1"
PHP Code:

if ($_POST["op1"] != "select1"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-13-04, 02:21 PM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
Dj_farout is incorrect your problem lies here

$display_block = "<h1>Add Driver to Division</h1>

you need a close quote and semicolon.
$display_block = "<h1>Add Driver to Division</h1>";

might I suggest using single quotes however unless you plan on putting in espace charaters.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-13-04, 02:40 PM
Dj_Farout Dj_Farout is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
ya, your right.. I counted wrong.. I wish there was a way to put line numbers on there.. hehe

thanks for the backup, infinitylimit
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-14-04, 05:02 AM
fccolon fccolon is offline
Newbie Coder
 
Join Date: Mar 2004
Location: West Mids. UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
D'oh.....

Thanks to you both for taking the time to have a look. I just need to sort my logic now

Whats the difference in using single/double quotes ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 07-15-04, 11:36 AM
fccolon fccolon is offline
Newbie Coder
 
Join Date: Mar 2004
Location: West Mids. UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
The script executes now......only the db doesn't appear to get one of the values passed to it.

Whats supposed to happen is that you select a division from the first screen, that divisions id number is stored in var divid.
A list of drivers are then displayed, from which you can make multiple selections, which are stored in drv_id[].

The values from both sets of selection are to be stored in a table called GPL_lsdd, which has 3 fields for sid, divid, did - these relate to season, division & driver ids.
I'm passing a null for the first field at the mo.
Whats actually happening is that the table gets an entry like 0,0,3 or 0,0,4 so the divid var doesn't appear to be getting a value assigned to it.
I've tried moving the line that transfers the value from the selection around but with no luck.
Apologies for being a pain but could someone point to where I'm going wrong ?

Thanks in advance
Attached Files
File Type: txt adddriverdiv.txt (2.4 KB, 256 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 07-16-04, 07:16 AM
fccolon fccolon is offline
Newbie Coder
 
Join Date: Mar 2004
Location: West Mids. UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
I've put echos of the variables in at various points....and all is well with the $sel_divid var until I get inside the while statement....then nothing, tho echoing the $sel_drivid[] array works ok

???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 07-16-04, 01:28 PM
mikaelf mikaelf is offline
Wannabe Coder
 
Join Date: Jun 2004
Location: php[dot]net
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by fccolon
I've put echos of the variables in at various points....and all is well with the $sel_divid var until I get inside the while statement....then nothing, tho echoing the $sel_drivid[] array works ok

???
Have you try to dump the variable (php function: var_dump or print_r). sometimes thehy will help a bit. sorry, i can't read the attachment. i have javascript disabled on my browser.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 07-16-04, 02:54 PM
fccolon fccolon is offline
Newbie Coder
 
Join Date: Mar 2004
Location: West Mids. UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
founds how yoy import the code now

PHP Code:



<?php

$conn 
mysql_connect("server""user""pwd");
  
mysql_select_db("leaguedb"$conn);

if (
$_POST[op1] != "select1")

 {

  
$get_list "select id, div_name from GPL_division";
  
$get_list_res mysql_query($get_list) or die(mysql_error());

  
$display_block "<h1>Add Driver to Division</h1>";

  
$display_block .= "
       <form method=\"post\" action=\"
$_SERVER[PHP_SELF]\">
       <p><strong> Select Division:</strong><br>
       <select name=\"sel_divid\">
       <option value=\"\">-- Go on, pick your division --</option>"
;

       while (
$divrecs mysql_fetch_array($get_list_res))
         {
          
$id $divrecs[id];
          
$div_name stripslashes($divrecs[div_name]);
          
$display_block .= "
          <option value=\"
$id\">$div_name</option>";
         }

   
$display_block .= "
   </select>
   <input type=\"hidden\" name=\"op1\" value=\"select1\">
   <p><INPUT type=\"submit\" value=\"Select\"></p>

   </form>"
;


   
$divid $sel_divid;
  }

elseif (
$_POST[op2] != "select2")

 {

echo 
$sel_divid;

  
$get_list "select id, driver_name from GPL_drivers";
  
$get_list_res mysql_query($get_list) or die(mysql_error());

  
$display_block "<h1>Add Driver to Division</h1>";
  
$display_block .= "
       <form method=\"post\" action=\"
$_SERVER[PHP_SELF]\">
       <p><strong> Select Drivers:</strong><br>
       <select name=\"sel_drvid[]\" multiple>
       <option value=\"\">-- Go on, pick your drivers --</option>"
;

       while (
$drvrecs mysql_fetch_array($get_list_res))
         {
          
$id $drvrecs[id];
          
$driver_name stripslashes($drvrecs[driver_name]);
          
$display_block .= "
          <option value=\"
$id\">$driver_name</option>";
         }

        
$display_block .= "
        </select>
        <input type=\"hidden\" name=\"op2\" value=\"select2\">
        <p><INPUT type=\"submit\" value=\"Select\"></p>

   </form>"
;
 echo 
$sel_divid;
  }

if (
$_POST[op2]= "select2")

  {

    
$selects sizeof($sel_drvid);

    
$i0;
echo 
$sel_divid;

    while (
$i $selects)
      { 
         
$did $sel_drvid[$i];
 echo 
$i;
         
$i++;
         
$make_link "INSERT INTO GPL_lsdd VALUES ('', '$sel_divid', '$did' )";
         
$make_link_res mysql_query($make_link) or die(mysql_error());

       
      }
  }
  
 
?>

<html>
<head>
<title>Add Drivers to Division</title>
</head>
<body>
<?php echo $display_block?>
</body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
web browser error handling ajaikuriank Visual Basic 0 04-26-04 12:54 PM
New to Java: weird main error msg hecresper Everything Java 2 02-10-04 04:03 PM
asp-iis-Server error nsuresh_rasr ASP.NET 3 02-08-04 01:47 AM
parse error... help? kappler0 PHP 2 01-21-04 04:57 AM
[php error] parse error | fatal error xeoHosting PHP 1 01-03-04 09:12 PM


All times are GMT -5. The time now is 11:56 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.