Jump to content

Elven6

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Elven6's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the example, I hadn't heard of it before but it seems worthwhile. I'll definitely have to look into it for my plugin system.
  2. I think he means echoing out $num, so something like, $sql = mysql_query("SELECT id,user_email FROM users WHERE user_email = '$user_email' AND user_pwd = '$md5pass' AND user_activated='1'"); while($stuff = mysql_num_rows($sql) ) { echo $stuff; } See if it outputs anything and if the data is similar to what you require for the code to proceed.
  3. Hello, I changed the while statement to a foreach, unfortunately the same issue from my previous post still occurs. I even tried moving the code out of the main while loop but the same thing still happens.
  4. Patches? Sorry, can you give an example of what you mean. Valid point regarding that type of a system though.
  5. Whoops, I think what happened here was when I originally posted my browser started to hang so I resubmitted and you must have posted since then! But to answer your question, after modifying what you posted to match the $_POST variable I get the following, Array ( [0] => 8 [1] => 9 [2] => 6 ) Repeating for as many items there are within the array (in this case three, so the above message posted three times). I'm guessing the issue here is that the script is simply sending all the data at once for as many times as selected versus individually for as many times as selected?
  6. One method that I'm looking into is simply having a system that adds/replaces code on plugin install similar to how SMF, phpBB, etc do it (almost done, just need to get a code find/replace system setup). I don't know if this is the best method but I don't really know of any alternatives of this level. I think the benefit with this system would be you can create plugins that radically alter/add functionality. Another method I looked into was having a plugin activate via a database entry and then have a file with code for that plugin load using a function. This system in theory should work great if you wanted to add modules and such to your site/CMS but if you wanted more advanced functionality, like for example a CAPTCHA system, I don't think it would be very capable. These are pretty simple methods that I've played around with but I don't know how well they would reflect in the community.
  7. It simply outputs, 5 4 6 Which corresponds to the id value of a company in the database. There's also a script related message ("Form successfully submitted, click here to return to the main menu") but nothing else.
  8. It simply outputs, 5 4 6 Which corresponds to the id value of a company in the database. There's also a script related message ("Form successfully submitted, click here to return to the main menu") but nothing else.
  9. Hello, Thanks for your response, rewriting the old code to be more cleaner/efficient is something I'm definitely looking into/partially started with the submission part of the form. If the form isn't sending out the correct input elements, is there any reason why doing something like print_r() would output the selected form options correctly but not send them to the database? Ex, while(list(, $ic) = each ($_POST["company$val"])) { print_r($ic); mysql_query("INSERT INTO data VALUES (null, 'company', '".$ic."', '".$id."')"); } On submit this would output something like 567 while in the database the only thing submitted is Array for the three entries.
  10. Hello, Sure thing, here's the larger scope code (I ended up changing a few things since posting last night), while (list(, $pid) = each ($_POST['id'])) { $r = mysql_query("UPDATE ".$pre."content SET name = '".addslashes($_POST["name_$pid"])."' WHERE id = '".$pid."'") or die("<font color='red'><b>A fatal MySQL error occured</b></font>.<br><br><b>Query:</b> ".$r."<br><b>Error:</b> (".mysql_errno().")".mysql_error()); $result = mysql_query("SELECT * FROM ".$pre."fields WHERE cat = '".$_POST["cat_$pid"]."' OR cat = 'global' OR cat = '' ORDER BY `id` DESC"); while ($row = mysql_fetch_array($result)) { $name = "$row[name]"; $type = "$row[type]"; if ($row[name] == "company") { while(list(, $ic) = each ($_POST["company$pid"])) { mysql_query("INSERT INTO data VALUES (null, 'company', '".$ic."', '".$pid."')"); } } } } And here's the form, echo "<form action='index.php.php?view=manage&edit=2' name='form1' method='post'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"left\">"; while (list(, $pid) = each ($_POST['id'])) { $query="SELECT * FROM ".$pre."content WHERE id = '$pid'"; $result=mysql_query($query); while($row2 = mysql_fetch_array($result)) { $nameav = "$row2[name]"; $cat = "$row2[cat]"; $namea = htmlspecialchars(stripslashes($nameav)); echo "<input type=\"hidden\" name=\"id[]\" value=\"$pid\"><input type=\"hidden\" name=\"cat_$pid\" value=\"$cat\"><tr><td><b><center>Item #".$pid."</b></center></td></tr><tr><td><b>Name</b></td><td><input type='text' name=\"name_$pid\" value=\"$namea\"></td></tr>"; $query = mysql_query("SELECT * FROM ".$pre."fields WHERE cat = '".$cat."' OR cat = '' OR cat = 'global' ORDER BY `id` DESC") or die(mysql_error()); while($row = mysql_fetch_array($query)) { $name = "$row[name]"; $type = "$row[type]"; if ($type == "company") { echo "<link rel=\"stylesheet\" href=\"../js/css/common.css\" type=\"text/css\" /> <link type=\"text/css\" rel=\"stylesheet\" href=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/ui.all.css\" /> <link type=\"text/css\" href=\"../js/css/ui.multiselect.css\" rel=\"stylesheet\" /> <script type=\"text/javascript\" src=\"../js/jquery-1.4.2.min.js\"></script> <script type=\"text/javascript\" src=\"../js/jquery-ui-1.8.custom.min.js\"></script> <script type=\"text/javascript\" src=\"../js/plugins/localisation/jquery.localisation-min.js\"></script> <script type=\"text/javascript\" src=\"../js/plugins/scrollTo/jquery.scrollTo-min.js\"></script> <script type=\"text/javascript\" src=\"../js/ui.multiselect.js\"></script> <script type=\"text/javascript\"> $(function(){ $.localise('ui-multiselect', {/*language: 'en',*/ path: '../js/locale/'}); $(\".multiselect\").multiselect(); $('#switcher').themeswitcher(); }); </script>"; $data = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."data WHERE id2 = '".$row2[id]."' AND name = 'company'")); $woo = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."pr WHERE id = '".$data[0]."'")); echo "<tr><td>".$name."</td><td><select name='".$name.$pid."[]' multiple='multiple' class = 'multiselect'>"; if ($woo[0]) { echo "<option value='".$data."' selected>-- ".$woo[0]." --</option>"; } $sql2 = mysql_query("SELECT * FROM ".$pre."pr ORDER BY `name` ASC") or die(mysql_error()); while($row25 = mysql_fetch_array($sql2)) { echo "<option value='".$row25[id]."'>".$row25[name]."</option>"; } echo "</select></td></tr>"; } } } echo "<tr><td><input type=\"submit\" name=\"Add\" value=\"Submit Changes\"></td></tr></form></table>"; The js stuff at the beginning is simply for a script I'm using that makes selection easier to manage, I tried without it but the same issue still arises. Thanks,
  11. Hello, The code and what is stored in the database was already posted in my original post, unless you mean something else?
  12. Hi, Try moving connect.php to the very top of the file (where the top.php line is located)? I assume the only error you're seeing is, Try adding something like mysql_error(); to your code so you can see a more detailed error message.
  13. Hello, In my code I'm trying to get multiple items from a form submitted to a database. The database seems to receive the number of items sent and the id value just fine but the data itself only shows "Array" where it should show an actual value (ie, Microsoft, IBM, Universal, etc). The code that submits to the database is, while(list(, $ic) = each ($_POST["company$val"])) { mysql_query("INSERT INTO data VALUES (null, 'company', '".$ic."', '".$id."')"); } company is simply the name of the field while $ic is simply a random variable I assigned that holds the user value chosen in the form, $id is the id number of the form. An example of the database input, id name data fid 200 company Array 12 The issue is however that if I instead tell the form to print the array then I get a list of all the item names (as it should be) so I assume the form is fine. I've been focused on this problem for quite a while now but haven't been able to find a solution, the examples I've seen don't seem to address this type of an issue either, any help would be greatly appreciated. Thanks,
  14. Thanks for your response, I noticed now that if I use ../ in place of the $url the file now seems to load properly with a .php extension. Would you recommend I use the code you posted or keep the file_get_contents() intact now that it works? I guess one of the benefits of using your code is it would be easier to change if I wanted to implement a new way of loading the templates versus the current method where I would need to make individual changes to each instance.
  15. Hello, I'm working on a php template system where I use file_get_contents() to fetch the template files. The template files are .php but mostly consist of html code with some php. Using file_get_contents() I'm able to get the files to load perfectly, the issue arises when there is php code in the template, specifically, code that requires a function referenced in a different file. The problem is the functions file (functions.php) is referenced in the main index.php file but for some reason, the template code doesn't seem to recognize that. If it helps, I use file_get_contents() like this, $templ = file_get_contents("".$url."/templates/index.php"); I noticed if I change the extension to something else (.html or even something fictional like .asd) the code runs just fine and the functions.php file is recognized by the php code. This is certainly an option but for convenience I'm hoping to keep the .php extensions. I tried using include(), require(), and even require_once() but the same issue arises concerning .php files. I haven't seen anything that says I can't use this method to load the files but it's possible I may have missed something. Is there an alternative method I can use if there's no solution here? Any help would be appreciated, Thanks.
×
×
  • 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.