Jump to content

benluke

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

benluke's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Its giving me the following error: [code] Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/n/v/nvq/public_html/nvq/hs31/knowledge_display.php on line 29 [/code] Thanks for your help gerkintrigg. Benluke
  2. Hi, Going back sometime now and after posting on php freaks you helped me out with the following code (much appreciated) [code] <?php   $sql = "SELECT knowledge_1 knowledge_2 knowledge_3 knowledge_4 knowledge_5 knowledge_6 knowledge_7 knowledge_8 knowledge_9 knowledge_10 knowledge_11 knowledge_12 knowledge_13 knowledge_14 FROM HS31 WHERE userid = $userid LIMIT 1";   if ($result = mysql_query($sql)) {     $row = mysql_fetch_assoc($result); $array = array();     $array = unserialize($row['knowledge_1']);     print_r($array);   } else {   echo "there was a problem";   } ?> [/code] Which displays [code] Array ( [0] => A [1] => B [2] => C [3] => D ) [/code] My question is this. What do i need to add / change so that it displays every array from each table row? Benluke
  3. Thanks for the help SemiApocalyptic much appreciated benluke
  4. Hi, ok so how would i go about doing that. Would i be looking at using the isset function? benluke
  5. Hi, I would like to learn how to validate arrays. I need to make sure that at least one check box has been selected from each set. I have the following html within a form [code] <input type="checkbox"  name="knowledge1[]" value="A"> <input type="checkbox"  name="knowledge1[]" value="B"> <input type="checkbox"  name="knowledge1[]" value="C"> <input type="checkbox"  name="knowledge1[]" value="D" > <input type="checkbox"  name="knowledge2[]" value="A"> <input type="checkbox"  name="knowledge2[]" value="B"> <input type="checkbox"  name="knowledge2[]" value="C"> <input type="checkbox"  name="knowledge2[]" value="D" > <input type="checkbox"  name="knowledge3[]" value="A"> <input type="checkbox"  name="knowledge3[]" value="B"> <input type="checkbox"  name="knowledge3[]" value="C"> <input type="checkbox"  name="knowledge3[]" value="D" > [/code] I then pass it and serialize it [code] $pc1=serialize($_POST['knowledge1']); //grab the array data and seaialize it to store in db $pc2=serialize($_POST['knowledge2']); $pc3=serialize($_POST['knowledge3']); [/code] Should i validate it before serializing? What is the best way to do this? Benluke
  6. Thanks to everyone, works perfectly now benluke
  7. hi, that does display the folllowing [code] Array ( [knowledge_1] => a:2:{i:0;s:1:"A";i:1;s:1: ) [/code] ben
  8. Hi Crimpage, Tahnks for your help with this. [code] <?php   $sql = "SELECT knowledge_1 FROM hsc WHERE userid = $userid LIMIT 1";   if ($result = mysql_query($sql)) {     $row = mysql_fetch_assoc($result);     $array = unserialize($row['knowledge_1']);     print_r($array);   } else {   echo "there was a problem";   } ?> [/code] unfortunately im still getting same blank screen. benluke
  9. Could the problem be that it has not been stored in the table correctly?? Im at a dead end with this at the mo. this is the data in the table [code] a:1:{i:0;s:1:"D";} [/code] this is the code that thorpe kindly supplied [code] <?php   $sql = "SELECT knowledge_1 FROM hsc WHERE userid = $userid LIMIT 1";   if ($result = mysql_query($sql)) {     $row = mysql_fetch_assoc($result);     $array = unserialize($row);     print_r($array);   } else {   echo "there was a problem";   } ?> [/code] Its returning a blank screen. Could anyone shed any lite on this for me please?? Benluke
  10. can Anybody help me out with this one?? ben
  11. Thanks thorpe, Just tried your code. Not getting any errors but it does not display any data. Just blank Checked the database to make sure data is stored and thats fine a:4:{i:0;s:1:"A";i:1;s:1: is stored in the knowledge_1 field Thanks benluke
  12. Hi, Im storing arrays in mysql and "trying" to unserialize the data. But im pretty much stuck! Can anybody help me? Im using 3 scripts/pages. form.php [code] <form action="submit.php" method="post"> <input type="checkbox" name="knowledge1[]" value="A"> <input type="checkbox" name="knowledge1[]" value="B"> <input type="checkbox" name="knowledge1[]" value="C"> <input type="checkbox" name="knowledge1[]" value="D"> <br> <input type="checkbox" name="knowledge2[]" value="A"> <input type="checkbox" name="knowledge2[]" value="B"> <input type="checkbox" name="knowledge2[]" value="C"> <input type="checkbox" name="knowledge2[]" value="D"> <br> <input type="checkbox" name="knowledge3[]" value="A"> <input type="checkbox" name="knowledge3[]" value="B"> <input type="checkbox" name="knowledge3[]" value="C"> <input type="checkbox" name="knowledge3[]" value="D"> <input name="pc" type="hidden"  value="pc"> </form> [/code] submit.php [code] <? $pc1=serialize($_POST['knowledge1']); $pc2=serialize($_POST['knowledge2']); $pc3=serialize($_POST['knowledge3']); $update = $_POST["pc"]; if ($update == 'pc'){          $query="UPDATE hsc SET knowledge_1 = '$pc1', knowledge_2 = '$pc2', knowledge_3 = '$pc3', submitted = '1', submitted_date=now()   WHERE userid = $userid LIMIT 1";     $result=mysql_query($query);         if ($result){            echo "<h3>Submitted</h3>       <p>This has been successfully submitted.<br><br>         <a href='index.php'>Click Here</a> to continue</p><br><br><br><br><br><br><br><br>";         }         elseif (!$result){                 echo "<h3>ERROR</h3><p> There was a Problem submitting .<br><br>                 If the problem persists please contact the support team.";     } } ?> [/code] The above 2 scripts seem to be working fine, the data is being stored in the database looking like this a:4:{i:0;s:1:"A";i:1;s:1: Im having problems with pulling the info and displaying it. Infact i cant work out how to do it? Im thinking this post should have gone in PHP newbie. Still, can anybody help. How do i pull the arrays from the DB and disp[ly them?? Benluke
×
×
  • 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.