Jump to content

lilwing

Members
  • Posts

    85
  • Joined

  • Last visited

    Never

Everything posted by lilwing

  1. Well, I figured it out. //Don't do $_POST['username'][0] //Instead do $contentowner[0] $contentowner = $_POST['username']; echo $contentowner[0];
  2. Hmm, well, it doesn't post array, but it doesn't post anything. I tried both of these: $contentowner = $_POST['username'][0]; $contentowner = $_POST['username'][1];
  3. Thanks for the quick responses, guys. That outputs this: Array ( [0] => user1 ) I guess that means use I should use 0, huh?
  4. I've got something like: <?php $query = mysql_query('SELECT username FROM users WHERE ID > 4 ORDER BY username, permissions ASC'); while($row = mysql_fetch_array($query)) { $list = $row['username']; echo("<li>"); echo('<input type="radio" name="username[]" value="'.$list.'" />' . $list); echo("</li>"); } ?> That works perfectly fine. The value in the html source is correct. However, this is part of a form, and that form tries to post to a table. Everything else posts fine, but this particular field posts "Array" instead of the values I want it to. The query looks like this: <?php $contenttype = $_POST['contenttype']; $contentid = $_POST['contentid']; $contentname = $_POST['contentname']; $contentowner = $_POST['username']; $insert = 'INSERT INTO content (ContentOwner, ContentID, ContentType, ContentName) VALUES ("'.$contentowner.'", "'.$contentid.'", "'.$contenttype.'", "'.$contentname.'")'; mysql_query($insert) or die(mysql_error()); ?> What have I done wrong? ???
  5. Anyone?... ...I'll give you a blow job
  6. Alright, I have the error down to one, and I have no idea what to do: Warning: Invalid argument supplied for foreach() in C:\WebServer\wamp\www\linkstest.php on line 143 It's talking about this: foreach ($parent_array as $pkey => $pval) { if (!empty($pval['count'])) { $menu .= " <li><a class=\"".$extra_style."\" href=\"".$pval['link']."?".$qs_val."=".$pkey."\">".$pval['label']."</a></li>\n"; } else { $menu .= " <li><a href=\"".$pval['link']."\">".$pval['label']."</a></li>\n"; } if (!empty($_REQUEST[$qs_val])) { $menu .= "<ul id=\"".$sub_id."\">\n"; foreach ($sub_array as $sval) { if ($pkey == $_REQUEST[$qs_val] && $pkey == $sval['parent']) { $menu .= "<li><a href=\"".rebuild_link($sval['link'], $qs_val, $sval['parent'])."\">".$sval['label']."</a></li>\n"; } } $menu .= "</ul>\n"; } }
  7. Yeah I figured it was a bracket syntax error... but I am not sure where to put it; the tutorial doesn't say if I should leave the loop open to include another loop, or close it after the loop. I put a bracket in after the loop: foreach ($parent_array as $pkey => $pval) { I get the following errors: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\WebServer\wamp\www\linkstest.php on line 108 Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in C:\WebServer\wamp\www\linkstest.php on line 119 Warning: Invalid argument supplied for foreach() in C:\WebServer\wamp\www\linkstest.php on line 143
  8. I was reading this tutorial: http://www.finalwebsites.com/tutorials/dynamic-navigation-list.php I set up the database and everything, did the tutorial, and when I try to execute, I get unexpected $end. I have a feeling that is not the only error in the tutorial. I'd rather just be referenced to a better tutorial, if available, but if you could help me figure out what is wrong, it is greatly appreciated. Help! <?php $sql = "SELECT id, label, link_url, parent_id FROM dyn_menu ORDER BY parent_id, id ASC"; $items = mysql_query($sql); while ($obj = mysql_fetch_object($items)) { if ($obj->parent_id == 0) { $parent_menu[$obj->id]['label'] = $obj->label; $parent_menu[$obj->id]['link'] = $obj->link_url; } else { $sub_menu[$obj->id]['parent'] = $obj->parent_id; $sub_menu[$obj->id]['label'] = $obj->label; $sub_menu[$obj->id]['link'] = $obj->link_url; $parent_menu[$obj->parent_id]['count']++; } } mysql_free_result($items); function dyn_menu($parent_array, $sub_array, $qs_val = "menu", $main_id = "nav", $sub_id = "subnav", $extra_style = "foldout") { $menu = "<ul id=\"".$main_id."\">\n"; foreach ($parent_array as $pkey => $pval) { if (!empty($pval['count'])) { $menu .= " <li><a class=\"".$extra_style."\" href=\"".$pval['link']."?".$qs_val."=".$pkey."\">".$pval['label']."</a></li>\n"; } else { $menu .= " <li><a href=\"".$pval['link']."\">".$pval['label']."</a></li>\n"; } if (!empty($_REQUEST[$qs_val])) { $menu .= "<ul id=\"".$sub_id."\">\n"; foreach ($sub_array as $sval) { if ($pkey == $_REQUEST[$qs_val] && $pkey == $sval['parent']) { $menu .= "<li><a href=\"".rebuild_link($sval['link'], $qs_val, $sval['parent'])."\">".$sval['label']."</a></li>\n"; } } $menu .= "</ul>\n"; } } $menu .= "</ul>\n"; return $menu; } foreach ($parent_array as $pkey => $pval) { if (!empty($pval['count'])) { $menu .= " <li><a class=\"".$extra_style."\" href=\"".$pval['link']."?".$qs_val."=".$pkey."\">".$pval['label']."</a></li>\n"; } else { $menu .= " <li><a href=\"".$pval['link']."\">".$pval['label']."</a></li>\n"; } if (!empty($_REQUEST[$qs_val])) { $menu .= "<ul id=\"".$sub_id."\">\n"; foreach ($sub_array as $sval) { if ($pkey == $_REQUEST[$qs_val] && $pkey == $sval['parent']) { $menu .= "<li><a href=\"".rebuild_link($sval['link'], $qs_val, $sval['parent'])."\">".$sval['label']."</a></li>\n"; } } $menu .= "</ul>\n"; } function rebuild_link($link, $parent_var, $parent_val) { $link_parts = explode("?", $link); $base_var = "?".$parent_var."=".$parent_val; if (!empty($link_parts[1])) { $link_parts[1] = str_replace("&", "##", $link_parts[1]); $parts = explode("##", $link_parts[1]); $newParts = array(); foreach ($parts as $val) { $val_parts = explode("=", $val); if ($val_parts[0] != $parent_var) { array_push($newParts, $val); } } if (count($newParts) != 0) { $qs = "&".implode("&", $newParts); } return $link_parts[0].$base_var.$qs; } else { return $link_parts[0].$base_var; } } ?>
  9. oops sorry You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET Content = 'Hello my name is admin. ' WHERE ='home'' at line 1
  10. Not sure what I typed wrong here. Maybe I am having dillusions from being up too late. <?php $contentedit = $_POST['contentedit']; $title = $_POST['title']; $content = $_POST['FCKeditor1']; $finalcontent = str_replace("'", "´", $content); $table = $_POST['table']; $link = $_POST['link']; mysql_query("UPDATE ".$table." SET Content = '".$finalcontent."' WHERE ".$link."='home'") or die(mysql_error()); header('location:http://www.[neah].org/auth/admin.php'); ?>
  11. Meh, don't know how I forgot the error function. Anyway, I figured it out before resorting to that... I was ordering by the wrong column.
  12. I get this message quite a lot. Especially when using loops. What's my mistake? <?php$query = mysql_query('SELECT Staff FROM biographies ORDER BY username ASC'); while($row = mysql_fetch_array($query)) { $list = $row['Staff']; echo('<li><a href="http://www.[neah].org/auth/admin.php?contentedit='.$list.'">'.$list.'</a></li>'); } ?>
  13. I am using $_GET values to create dynamic links. The variable is called $pageid. Obviously, when a user types the URL into his/her browser, the $_GET value is not set. In order to display the content on the homepage, I need $pageid = 'home' How can I set up a default value for $pageid? <?php $pageid= $_GET['pageid']; $query = mysql_query("SELECT Content FROM sfiscontent WHERE ContentID='$pageid'") or die(mysql_error()); while($row = mysql_fetch_array($query)) { $current = $row['Content']; echo $current; } ?>
  14. Well thanks for yourhelp guys. For anyone who has trouble with this dynamic menu sort of thing, check this out: http://www.finalwebsites.com/tutorials/dynamic-navigation-list.php
  15. this is what i have so far. not sure where i am making a mistake. any help? <?php $query = mysql_query('SELECT * FROM hyperlinks WHERE Category="primary" ORDER BY LinkOrder ASC') or die(mysql_error()); $row = mysql_fetch_array($query); $primaryName = $row['Name']; $primaryHREF = $row ['HREF']; echo ('<li class="off"><a href="'.$primaryHREF.'">'.$primaryName.'</a>'); $query2 = mysql_query('SELECT * FROM hyperlinks WHERE Category="secondary" AND PrimaryCategory="$primaryName" ORDER BY LinkOrder ASC') or die(mysql_error()); $row = mysql_fetch_array($query2); $secondaryName = $row2['Name']; $secondaryHREF = $row2['HREF']; $primaryCategory = $row2['PrimaryCategory']; echo ('<ul>'); echo ('<li><a href="'.$secondaryHREF.'"></a>'.$secondaryName.'</li>'); echo('</ul>'); echo ('</li>'); ?>
  16. I sure hope someone can help with this problem, I have been up all night trying to figure it out. Basically, I have a table called hyperlinks, with the columns: HREF, Name, Category, PrimaryCategory, and LinkOrder. I am trying to use a database for holding the links in the navigation bar. HREF is the source of the URL, Name goes between the a tags, category is either primary or secondary (primary would be the main navigation, and secondary would be the subnavigation... kind of like a dropdown) PrimaryCategory is the name of the primary category which a given set of secondary links falls under... it is null for all entries with 'primary' in the Category field. Link order is an integer entry, used to order the links. With some frustration, and help from the boards, I have finally gotten the primary navigation links to show. What I haven't been able to do, is get the secondary links to appear under the proper primary navigation link. For example, say I want the list to function something like this: <ul> <li><a href="#">home</a> <li><a href="#">what should be under home</a> </li> </ul> So I want it to be something like this: Where PrimaryCategory = PrimaryName; <ul> <li><a href="PrimaryHREF"">PrimaryName</a> <a href="SecondaryHREF">SecondaryName</a> </li> </ul> I've wasted quite a bit of time trying to figure this out. However it is very important. I hope you can help. Here is the source: <?php $query = mysql_query('SELECT * FROM hyperlinks ORDER BY LinkOrder ASC') or die(mysql_error()); while($row = mysql_fetch_array($query)) { while($row[Category] = 'primary') { $primaryName = $row[Name]; $primaryHREF = $row [hrEF]; $primaryCategory = $row['PrimaryCategory']; $secondaryName = $row['Name']; $secondaryHREF = $row['HREF']; echo ('<li class="off"><a href="http://www.sfisk12.org/index.php?pageid='.$primaryHREF.'">'.$primaryName.'</a>'); echo ('<ul>'); echo ('<li><a href="'.$secondaryHREF.'"></a>'.$secondaryName.'</li>'); echo('</ul>'); echo ('</li>'); ?>
  17. That worked. I changed it a little though. Now I have a horrible loop problem. <?php $query = mysql_query('SELECT * FROM hyperlinks WHERE Category="primary" ORDER BY LinkOrder ASC') or die(mysql_error()); while($row = mysql_fetch_array($query)) { while($row[Category] = 'primary') { $primaryName = $row[Name]; $primaryHREF = $row [hrEF]; while($row[Category] = 'secondary') { $primaryCategory = $row['PrimaryCategory']; $secondaryName = $row['Name']; $secondaryHREF = $row['HREF']; echo ('<li class="off"><a href="'.$primaryHREF.'">'.$primaryName.'</a>'); if($row[PrimaryCategory] != 0) { echo ('<ul>'); echo ('<li><a href="'.$secondaryHREF.'"></a>'.$secondaryName.'</li>'); echo('</ul>'); } echo ('</li>'); } } } ?>
  18. Not sure how to fix this problem... been cracking at it for a half hour. <?php $query = mysql_query('SELECT * FROM hyperlinks WHERE Category="primary" ORDER BY LinkOrder ASC') or die(mysql_error()); while($row = mysql_fetch_array($query)) { $primaryHREF = $row['ID']; } $query = mysql_query('SELECT * FROM hyperlinks WHERE Category="primary" ORDER BY LinkOrder ASC') or die(mysql_error()); while($row = mysql_fetch_array($query)) { $primaryName = $row['Name']; } echo ('<li><a href="'.$primaryHREF.'">'.$primaryName.'</a>'); ?>
  19. Hmm, maybe it's just better if I store the links in a database, huh?
  20. Well yes, but I want to process to be automatic.
  21. Say you want to create a PHP script that takes the Post information of a form with fields for URL and rollover text, and adds a hyperlink to your navigation structure. In this case, you have most of the script complete. But how would you go about writing the new link to the dynamic webpage?
  22. I am not sure how to do this path-like thing. Any tutorials on that? What's it even called?
  23. Clearly there are a lot of ways to go about this. I am going to have to do some studying before I am able to use any of those methods.
  24. Stublackett, how did you give teachers access to just their pages? That is what I am unsure about.
×
×
  • 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.