Jump to content

Recommended Posts

I am not getting any errors but it's not working?! Can someone please help??

 

Edit checkboxes page

//SQL for Keywords
$result2 = mysql_query("SELECT DISTINCT keyword from keywordlist");


$i = 0;

while ($row1 = mysql_fetch_array($result2))
{ 
   if ($i++ > 0)
   {
        echo '<br> ';
   }

$Keyword = $row1['keyword'];
$Displayed = false; 

//SQL for Keywords
$result3 =  mysql_query("SELECT * FROM keyword INNER JOIN keywordlist 
ON keyword.keyword_id=keywordlist.keyword_id WHERE keyword.HeaderID=".$HeaderID);

while($row3 = mysql_fetch_array($result3))
{		 
	$Keyworduse = $row3['keyword'];
	$keyword_id = $row3['keyword_id'];
 	if ($Keyworduse == $Keyword)
   	{

		 $Displayed = true;
  		 $check = ' checked="checked"';
  		 echo '<input name="keyword_id[]" type="checkbox" value="'.$keyword_id.'" '.$check.' />';
		 echo $Keyword;
 	}
   	}
	if ($Displayed == false)
   	{
   		echo '<input name="keyword_id[]" type="checkbox" value="'.$Keyword.'"/>';
	 echo $Keyword;
    }

}

 

code page:

<?php
include_once('config.php');
$HeaderID = $_GET['HeaderID'];

$sql = "DELETE FROM keyword WHERE HeaderID = '$HeaderID'";
$result = mysql_query($sql,$link) or die('Error: ' . mysql_error() . '<br>SQL: ' . $sql);

if (is_array($_POST['keyword_id']))
{
    foreach ($_POST['keyword_id'] AS $keyword)
    {
        $keyword_id = mysql_real_escape_string(stripslashes($keyword));
         $sql1 = "INSERT INTO keyword (keyword_id,HeaderID) 
Values ('$keyword_id','$HeaderID')";
$result = mysql_query($sql1,$link) or die('Error: ' . mysql_error() . '<br>SQL: ' . $sql1);
    }
}  
header("Location: display.php"); 
mysql_close($link);
?> 

I put the debugging in and i got back:

 

INSERT INTO keyword (keyword_id,HeaderID) Values ('HIV-positive','25')Error: Incorrect integer value: 'HIV-positive' for column 'keyword_id' at row 1

SQL: INSERT INTO keyword (keyword_id,HeaderID) Values ('HIV-positive','25')

its a test.. dose it work without error.. (i'll assume so)

 

now change

echo '<input name="keyword_id[]" type="checkbox" value="'.$Keyword.'"/>';

to

echo '<input name="keyword_id[]" type="checkbox" value="'.$keyword_id.'"/>';

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.