Jump to content
xisto Community

sonesay

Members
  • Content Count

    958
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by sonesay


  1. Hi,

    I have a MySQL database with the following fields:

    ID (speaks for itself), _sfm_form_submision_time_ (time form was submitted), _sfm_visitor_ip_ (visitor IP address), Name (Visitor's Name), Town (visitor's loacation), Emaiil (visitor's Email), Message (Text block to leave a message up to 500 chars).

    (And I now see I made an error in a field name, by using Emaiil instead of Email).

     

    However, I would like to display the submitted data, only for the fields Name, town and message in a table on my website.

     

    I have a bit of code, but then get hopelessly stuck.

    I would like the display to look something like the attached screenshot.

     

    I already have a bit of code, but then I get hopelessly stuck.

    This is what I have:

     

     

     

    (Not sure whether that is all 100% correct).

    But then, I get hopelessly stuck with the code to put those data in a table as in the screenshot below.

     

    Anyone who could help, please?

     

    Also, I have tha page with the form to enter the data, and I would like the display table to appear below the form.

    The code for that page is as follows:

     

     

     

    The "<iframe></iframe>" is the link to display the form, should I now, when I have the full code for formatting the table, use another iframe below it, or should I just put the PHP code below it, or should the code for the display table be written in HTML?

     

    Sorry if my questions seem somewhat stupid and/or if my coding is lousy, but I am a COMPLETE novice when it comes to PHP, and I would desperately love to learn more..

    Any help will be much appreciated.

     

    PS. In the mean time I have corrected the field name error from 'Emaiil' to the correct 'Email'.

     

    post-46682-064931800 1297275901_thumb.jpg

     


    Does your while loop work? That's the first time I've seen variables being assigned that way in your loop. There is also a problem with your 'localhost'. it should be a string not just localhost which is a constant undefined. no $ symbol means it will look for the constant localhost.

     

    This is how I would of done it

    <?php$username="mrdee";$password="**********";$database="mrdee_reloader";mysql_connect('localhost',$username,$password);@mysql_select_db($database) or die( "Unable to select database");$query="SELECT * FROM rouw";$result=mysql_query($query);// loop through array and output till its finishedwhile($row = mysql_fetch_assoc($result)) {    echo $row["Name"] . "<br />";    echo $row["Town"] . "<br />";    echo $row["Email"] . "<br />";}?>
    You will need to place the while loop where you desire the output to occur. This would be in your html page etc.

  2. I was using EasyPHP and I had made an application to show, edit and process data in a MySQL table.
    I used Xlinesoft's PHPRunner for that.

    However, when I executed the login page of that setup, I was greeted with loads of errors, all sounding the same, and, as far as I can see, only concerning two different PHP functions: the function set_magic_quotes_runtime() and the function split().

    Underneath are the first 2 errors I get after logging in:
    post-46682-015754700 1298507661_thumb.png

    Then, after that, repeated 26 times, is an error message, which looks exactly the same to me at every repeat:
    post-46682-056107500 1298507832_thumb.png

    And at the bottom of the page I get a table summing up the error:
    post-46682-084807900 1298507999_thumb.png

    I also get a similar looking, but slightly different error prior to logging in, but underneath, the login screen appears and allows me to log in, but then sends me to the page full of errors:
    post-46682-047469800 1298508327_thumb.png


    I then tried the same thing, this time using WAMP, but it lead to the same results.

    I was wondering if that has something to do with certain functions not being switched on in PHP.
    I seem to remember from the days when I was young :D this had something to do with un-commenting certain lines in the PHP setup, but I have forgotten the finer details.

    If anyone could give me some help and guidance here, I'd be extremely grateful.


    What version of php are you using? The warnings happen because your php version is much newer than what the script was designed for. Your script uses old methods so its not fully compatable or not supported with the current version of php.

    I'm still not 100% sure on what depreciation actually means but it could just mean it does still work but will probably not continue to work in further releases of php so the warning is displayed. I think you can try removing theses types of warning in your php settings. I did a quick search and one some examples you can try ..

    http://forums.cacti.net/about36427.html

    For all of you using PHP 5.3:Edit your php.ini and set error_reporting to:Code:error_reporting = E_ALL & ~E_DEPRECATEDAfter that edit /cacti/include/global.php and change line 196 fromCode:error_reporting(E_ALL);toCode:error_reporting(E_ALL ^ E_DEPRECATED);Do exactly the same in line 312 of file adodb-time.inc.php located in /cacti/lib/adodbNow restart your web server and you will see that all "deprecated" messages will be successfully suppressed.Best regards-Andreas-

    Try setting the error warnings to ignore deprecated errors. You can probably ignore the other lines where it tells you to find the error_reporting() to set as it only applies to their specific scripts so with your own you need to locate where ever your error reporting scripts are set specific to your scripts. So it should be in two places your php.ini and where ever it is set in your php script as it will overwrite the php.ini setting.

  3. Maybe to clarify a bit further:
    My website looks similar on all pages, I have just made 2 tables, one on the left, where the menu appears, and one on the right, where the main page (as chosen in the menu) appears.in the main table,
    I want to keep it like that, only, for my news pages (Dutch and English), I just want the layout left intact, except that, in the main table, I want the

    articles to appear as Wordpress blog posts, rather than just separate tables with text and pictures in it.

    I have made a screenshot to show what it looks like at the moment, sorry there is only one bit of a table visible in the main section (on the right), but it concerns a very long article here, but, anyway, anythig that appears below is just the same, ie. a table, with the date top left, the title of the article under neath, and then the main text of the article.

    The main reason why I am posting this here is because the Wordpress support is not always very clear to search, and the explanations are sometimes difficult to understand, and also, because the forums are not always very helpful neither.

    Anyway, here is a screenshot of my news page:
    post-46682-087736200 1298632966_thumb.png

    Hope that makes things a bit easier to understand.




    I had a look at the example link where you are using as a guide. Your main problem is it has no styles correct? I think this is probably due to a setting you've set in the first snipplet of code

    <?php    // turn off WordPress themes and include the WordPress core:    define('WP_USE_THEMES', false);    require($_SERVER['DOCUMENT_ROOT'] . '/wordpress/wp-blog-header.php');?>

    I'm guessing the WP_USE_THEMES = false will cause wp to output your content in just plain text. I have no personal experince of word press my self so I am only guessing that is what is happen. If that is the case then maybe you can try turn it on just to see the effect. If that still does not do what you need then it may look like you need to somehow create your own CSS to format it. You can probbaly do this by getting at your table container and selecting what ever child elements underneath it to style it as you please.

    Could you possible paste the entire html code generated by your page I would be interested to see what it actually outputs.

  4. This sounds like a very bad and common problem. I can give you some insight as I was once addicted to MMORPG myself. The more you let him get away with being a slob the worse it will get. Eventually it may get to the point where its so bad he will start giving up on everything all together or it might actually make him realize how much of a time hes wastes either way it will take too long and waste more valuable time. You say hes 24 that's the age you should be changing from a kid to and adult already. I know people are all different but generally by that age you should be old enough to take care of your self. I know a lot of people who grow up and are responsible when they are 20 and it amazes me. I wonder what makes them different from me and why at that age I was lost and messed up. It has to do with parenting I think. If you had raised your kid well and taught them good qualities like hard work and responsibilities then they would not end up like this. I have to say my parents were not the best being not very educated they still have no idea on how to be a parent or what parenting is. To this day it causes problems in the family when there is an argument and no one is willing to concede thinking they are the only ones right. You cannot go through live having kids and not teaching them good values and then expect them to turn out right when they are adults it does not work that way. I think a lot of parents fail this way because they don't know what parenting really is. My little brother has the same problem he is 11 and all he thinks about is games. I know its up to me to teach him because my parents wont do it. They are too concerned about their own life to really be parents. My only suggestion for you is to take it upon yourself to help your brother out. You have to find a way to make him see the light its not going to be easy but if you don't do it who will? Your his brother and true you may have your own life but it will take sacrifice if you love him enough you will do what ever it takes to help him. Your brother is probably also feeling a lot of helplessness and wondering why things arn't working out so he gives up trying. Nothing comes out good without putting in hard work and he should expect to fail many times before he success but if he does not change then the outcome surely will not be any different. Another problem is if your mum is letting him stay for free then its easy for him to be lazy. Kicking him out might sound bad but its probably the best thing and the only thing that will get him to do something about his situation. It may seem harsh to do such a thing to family but its not. I wish you the best of luck with your brother.


  5. My DVD drive on my laptop will not even receive power anymore. it wont let me even open it. so i took it out and fixed it with a little help from a step by step online manual. it started working fine again and then it just quit working all-together. What is wrong with it?can anyone help me?


    What did you do to fix it? If it was just a power cable issue where it was not connected properly then it should be a simple fix. By the looks of it, it seems like a power issue when you say it has no power. Either that or the cd unit has shorted and no longer functions but I've never heard of any cases where that's happen before.

  6. I like the idea but I think it should be up to them whether they are subject to testing or not. Even though they are prisoners they are still human and their rights should not be taken away. We should not be forcing anything on anyone and the day we start doing that is the day we begin losing our freedom (if we even had it to begin with). This world is already messed up as it is (probably has always been) and the only way to make things better is to educate more people so they aren't just sheep being manipulated and used by the elites but be able to think and speak out on their own.


  7. i get the below message when i try to use the script near the bottom which deletes from an sql database and the linked file but if i put the script on a page on it's own it works without a hitch. so it is something else on his page that is causing the problem i have tried removing everything but the main design but it is then indicating the error is because of the divs i have used and every time i remove the one it wants it changes to another.


    line 95 is this bit

    header('Location: index.php');
    and line ten is the stylesheet for uploadify

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/ xmlns="http://forums.xisto.com/no_longer_exists/ http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Testimonials</title><link href="../style.css" rel="stylesheet" type="text/css" /><link href="uploadify/uploadify.css" type="text/css" rel="stylesheet" />      <script type="text/javascript" src="uploadify/jquery-1.4.2.min.js"></script>      <script type="text/javascript" src="uploadify/swfobject.js"></script>      <script type="text/javascript" src="uploadify/jquery.uploadify.v2.1.4.min.js"></script>      <script type="text/javascript">      $(document).ready(function() {        $('#file_upload').uploadify({          'uploader'  : 'uploadify/uploadify.swf',          'script'    : 'uploadify/uploadify.php',          'cancelImg' : 'uploadify/cancel.png',          'folder'    : '../testimonial_files',          'auto'      : true        });      });      </script>      </head><body><div class="container">  <div class="header"><br /><br /><br /> </div>  <div class="sidebar1">    <ul class="nav"><b>      <li><a href="../">Home</a></li>      <li><a href="/admin/">Testimonials upload</a></li>      <li><a href="audio/">Audio Testimonials upload</a></li>      <li><a href="dvds/">Dvd's upload</a></li>      <li><a href="newsletter/">Newsletter upload</a></li>      <li><a href="news/">News box update</a></li>     </b></ul></div>  <div class="content">  <center><h2>Admin</h2></center>  <br /><center><p><input id="file_upload" name="file_upload" type="file" /></p><p><table width="200" border="0"><form action="insert_test.php" method="post">  <tr>    <td align="right">Name:</td>    <td><input type="text" name="Name" /></td>  </tr>  <tr>    <td align="right">Description:</td>    <td><input type="text" name="Message" /></td>  </tr>    <tr>    <td align="right">Download:</td>    <td><input name="Download" type="text" /></td>    </tr>    <tr>        <td colspan="2" align="center"><input type="submit" value="Submit" /></td>  </tr></form></table></p><br /><br /><p><?php// Set Global Vars$HOST = "";$USERNAME = "";$PASSWORD = "";$DATABASE = "";$TABLE = "";// Establish a connectionmysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());mysql_select_db($DATABASE) or die(mysql_error());//==================================================================// Check if anything is posted//==================================================================if (isset($_POST['delete'])) {    $sql = ("delete from $TABLE where ");    for ($i = 0; $i < count($_POST['checkbox']); $i++) {        if ($i != 0) {            $sql.= "OR ";        }        $sql .= " id='" . $_POST['checkbox'][$i] . "'";        //==================================================================        // Select file to unlink based on id posted        //==================================================================        $sql_file_unlink = "select Download from $TABLE where id = {$_POST['checkbox'][$i]}";        $result_file_unlink =  mysql_query($sql_file_unlink);        $row_file_link = mysql_fetch_assoc($result_file_unlink);        if($row_file_link) {             unlink('../testimonial_files/' . $row_file_link['Download']);        }        //==================================================================    }    $result = mysql_query($sql);    header('Location: index.php');    exit;} else {    // select sql here    $sql = "select * from `$TABLE` order by `id`;";    $result = mysql_query($sql);}?><table  align="center" width="400" border="0" cellspacing="1" cellpadding="0">     <tr>      <td colspan="6" align="center"><strong>Testimonials</strong> </td>    </tr>    <tr>        <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">                <table width="400" border="1" cellpadding="3" cellspacing="1">                    <tr>                        <td align="center"><strong>Select</strong></td>                        <td align="center"><strong>ID</strong></td>                        <td align="center"><strong>Name</strong></td>                        <td align="center"><strong>Description</strong></td>                        <td align="center"><strong>Download</strong></td>                        <td align="center"><strong>Last Modified</strong></td>                    </tr><?php $row = mysql_fetch_assoc($result); ?><?php do { ?>                        <tr>                            <td align="center">                                <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>">                            </td>                            <td align="center"><?php echo $row['id']; ?></td>                            <td align="center"><?php echo $row['Name']; ?></td>                            <td align="center"><?php echo $row['Message']; ?></td>                            <td align="center"><a href="../testimonial_files/<?php echo $row['Download']; ?>">Download</a></td>                            <td align="center"><?php echo date("j/n/y", strtotime($row["Modified"])) ?></td>                        </tr>                      <?php                      } while ($row = mysql_fetch_assoc($result)); ?>                        <tr>                            <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>                        </tr>                    </table>                </form>            </td>        </tr>    </table></p></center></div>  <div class="sidebar2">    <h4>Text here</h4>    <p> </p>  </div>  <div class="footer">    <center><p>Š Copyright 2010</p></center>    </div>  </div></body></html> 

    The reason for that error is because you have already began outputting HTML code so redirecting after that point is not possible. You can move your whole PHP code block to the top before you begin your HTML output and it should work.

    <?php// Set Global Vars$HOST = "";$USERNAME = "";$PASSWORD = "";$DATABASE = "";$TABLE = "";// Establish a connectionmysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());mysql_select_db($DATABASE) or die(mysql_error());//==================================================================// Check if anything is posted//==================================================================if (isset($_POST['delete'])) {    $sql = ("delete from $TABLE where ");    for ($i = 0; $i < count($_POST['checkbox']); $i++) {        if ($i != 0) {            $sql.= "OR ";        }        $sql .= " id='" . $_POST['checkbox'][$i] . "'";        //==================================================================        // Select file to unlink based on id posted        //==================================================================        $sql_file_unlink = "select Download from $TABLE where id = {$_POST['checkbox'][$i]}";        $result_file_unlink =  mysql_query($sql_file_unlink);        $row_file_link = mysql_fetch_assoc($result_file_unlink);        if($row_file_link) {             unlink('../testimonial_files/' . $row_file_link['Download']);        }        //==================================================================    }    $result = mysql_query($sql);    header('Location: index.php');    exit;} else {    // select sql here    $sql = "select * from `$TABLE` order by `id`;";    $result = mysql_query($sql);}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/ xmlns="http://forums.xisto.com/no_longer_exists/ http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Testimonials</title><link href="../style.css" rel="stylesheet" type="text/css" /><link href="uploadify/uploadify.css" type="text/css" rel="stylesheet" />      <script type="text/javascript" src="uploadify/jquery-1.4.2.min.js"></script>      <script type="text/javascript" src="uploadify/swfobject.js"></script>      <script type="text/javascript" src="uploadify/jquery.uploadify.v2.1.4.min.js"></script>      <script type="text/javascript">      $(document).ready(function() {        $('#file_upload').uploadify({          'uploader'  : 'uploadify/uploadify.swf',          'script'    : 'uploadify/uploadify.php',          'cancelImg' : 'uploadify/cancel.png',          'folder'    : '../testimonial_files',          'auto'      : true        });      });      </script>      </head><body><div class="container">  <div class="header"><br /><br /><br /> </div>  <div class="sidebar1">    <ul class="nav"><b>      <li><a href="../">Home</a></li>      <li><a href="/admin/">Testimonials upload</a></li>      <li><a href="audio/">Audio Testimonials upload</a></li>      <li><a href="dvds/">Dvd's upload</a></li>      <li><a href="newsletter/">Newsletter upload</a></li>      <li><a href="news/">News box update</a></li>     </b></ul></div>  <div class="content">  <center><h2>Admin</h2></center>  <br /><center><p><input id="file_upload" name="file_upload" type="file" /></p><p><table width="200" border="0"><form action="insert_test.php" method="post">  <tr>    <td align="right">Name:</td>    <td><input type="text" name="Name" /></td>  </tr>  <tr>    <td align="right">Description:</td>    <td><input type="text" name="Message" /></td>  </tr>    <tr>    <td align="right">Download:</td>    <td><input name="Download" type="text" /></td>    </tr>    <tr>        <td colspan="2" align="center"><input type="submit" value="Submit" /></td>  </tr></form></table></p><br /><br /><p><table  align="center" width="400" border="0" cellspacing="1" cellpadding="0">     <tr>      <td colspan="6" align="center"><strong>Testimonials</strong> </td>    </tr>    <tr>        <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">                <table width="400" border="1" cellpadding="3" cellspacing="1">                    <tr>                        <td align="center"><strong>Select</strong></td>                        <td align="center"><strong>ID</strong></td>                        <td align="center"><strong>Name</strong></td>                        <td align="center"><strong>Description</strong></td>                        <td align="center"><strong>Download</strong></td>                        <td align="center"><strong>Last Modified</strong></td>                    </tr><?php $row = mysql_fetch_assoc($result); ?><?php do { ?>                        <tr>                            <td align="center">                                <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>">                            </td>                            <td align="center"><?php echo $row['id']; ?></td>                            <td align="center"><?php echo $row['Name']; ?></td>                            <td align="center"><?php echo $row['Message']; ?></td>                            <td align="center"><a href="../testimonial_files/<?php echo $row['Download']; ?>">Download</a></td>                            <td align="center"><?php echo date("j/n/y", strtotime($row["Modified"])) ?></td>                        </tr>                      <?php                      } while ($row = mysql_fetch_assoc($result)); ?>                        <tr>                            <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>                        </tr>                    </table>                </form>            </td>        </tr>    </table></p></center></div>  <div class="sidebar2">    <h4>Text here</h4>    <p> </p>  </div>  <div class="footer">    <center><p>Š Copyright 2010</p></center>    </div>  </div></body></html>


  8. OK then,

    I can send you a few of the PHP scripts that come with the program.

     

    The program also creates an .xml file which is then read back and shown as a result in the program itself.

     

    However, the PHP is fully customisable, and all I want to store is the quiztaker's username, number of quizzes taken, and score. I will also upload my display script.

     

     

    Thank you for your help so far.

     

    Hey thanks for uploading the files. Unfortunately there has always been this problem with me not being able to download files from there.

     

    Posted Image

     

    Any ideas why it happens?


  9. Yeah your right. I didn't look at the entire code and just pasted the whole block in. the

    unlink('../admin/testimonial_files/' . $row['Download']);
    line you can delete I think because its not needed? if you look at http://php.net/manual/en/function.unlink.php this method deletes a file and I don't remember you mentioning there was any files you also needed deleting. If you do need to delete a file as well then you can paste that line back into the loop block.

    Edit: I just looked at your code again and by the looks of it you only want to be deleting (unlinking) the file if the user submits a delete post right? If that is the case then you would need to do:

    <?php// Set Global Vars$HOST = "database";$USERNAME = "sonint99";$PASSWORD = "C2sHF9Zxq3ULXCTV";$DATABASE = "Random";$TABLE = "Testimonials";// Establish a connectionmysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());mysql_select_db($DATABASE) or die(mysql_error());//==================================================================// Check if anything is posted//==================================================================if (isset($_POST['delete'])) {    $sql = ("delete from $TABLE where ");    for ($i = 0; $i < count($_POST['checkbox']); $i++) {        if ($i != 0) {            $sql.= "OR ";        }        $sql .= " id='" . $_POST['checkbox'][$i] . "'";        //==================================================================        // Select file to unlink based on id posted        //==================================================================        $sql_file_unlink = "select Download from $TABLE where id = {$_POST['checkbox'][$i]}";        $result_file_unlink =  mysql_query($sql_file_unlink);        $row_file_link = mysql_fetch_assoc($result_file_unlink);        if($row_file_link) {             unlink('../admin/testimonial_files/' . $row_file_link['Download']);        }        //==================================================================    }    $result = mysql_query($sql);    header('Location: index.php');    exit;} else {    // select sql here    $sql = "select * from `$TABLE` order by `id`;";    $result = mysql_query($sql);}?><table  align="center" width="400" border="0" cellspacing="1" cellpadding="0">     <tr>      <td colspan="6" align="center"><strong>Testimonials</strong> </td>    </tr>    <tr>        <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">                <table width="400" border="1" cellpadding="3" cellspacing="1">                    <tr>                        <td align="center"><strong>Select</strong></td>                        <td align="center"><strong>ID</strong></td>                        <td align="center"><strong>Name</strong></td>                        <td align="center"><strong>Description</strong></td>                        <td align="center"><strong>Download</strong></td>                        <td align="center"><strong>Last Modified</strong></td>                    </tr>                    <?php $row = mysql_fetch_assoc($result); ?><?php do { ?>                        <tr>                            <td align="center">                                <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>">                            </td>                            <td align="center"><?php echo $row['id']; ?></td>                            <td align="center"><?php echo $row['Name']; ?></td>                            <td align="center"><?php echo $row['Message']; ?></td>                            <td align="center"><a href="/admin/testimonial_files/<?php echo $row['Download']; ?>">Download</a></td>                            <td align="center"><?php echo $row['Modified']; ?></td>                        </tr>                      <?php                      } while ($row = mysql_fetch_assoc($result)); ?>                        <tr>                            <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>                        </tr>                    </table>                </form>            </td>        </tr>    </table><?php 

    I hope that's what you wanted. I removed some variables as it seems like they arnt being used like the delete id from the submit button.

  10. Yes, I do as a matter of fact.After you have taken the quiz, you get sent to the following place: Quiz Ranking, which shows the ranking of the people who have taken part, with their name, how many quizzes they have taken so far and the total of their score.

    The only thing I am looking for is the right PHP code so I wouldn't have to do it all by hand.

    Like I said, my problem has nothing at all to do with Flash or anything whatsoever, I know the PHP scripts in conjunction with the program work, I am only looking for the right code to achieve getting the data into the MySQL database, because I am not a fluent PHP programmer (yet, I am working on it).

    So, basically, all I want is the PHP code for adding 1 to a number (every time someone takes a quiz, the figure for the number of quizzes they took gets increased by 1), and the code for adding the score of the new quiz to the already existing score (a player had 80 points, takes the new part of the quiz and scores 20, so, that 20 gets added to his previous score, 80, making it 100).

    So, basically, all I am looking for is a few lines of PHP code, so I can complete the script.


    Can you give a full description of all tables involved? i.e the tables used by the Flash survey script and its records. Any other tables you intend to use. This will make writing example code more accurate and also provide us a better understanding of the database.

  11. that gives me the message

    the script is supposed to let me delete a selected row from my sql database and also delete the file from the download column


    Yeah I thought that's what you wanted but I wasn't too sure so I had to ask. all the code for the part where you delete needs to go in the correct if block in your statement. The part where you query for your result and use it in the mysql_fetch_assoc() needs to go in the else block.

    Try this:

    <?php// Set Global Vars$HOST = "XXXXXXX";$USERNAME = "XXXX";$PASSWORD = "XXXXX";$DATABASE = "XXXXX";$TABLE = "Testimonials";// Establish a connectionmysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());mysql_select_db($DATABASE) or die(mysql_error());if (isset($_POST['delete'])) {    // delete sql here    $DELETE_ID = mysql_real_escape_string($_POST['delete']);    unlink('../admin/testimonial_files/' . $row['Download']);    $sql = ("delete from $TABLE where ");    for ($i = 0; $i < count($_POST['checkbox']); $i++) {        if ($i != 0) {            $sql.= "AND ";        }        $sql .= " id='" . $_POST['checkbox'][$i] . "'";    }    $result = mysql_query($sql);   header('Location: index.php');   exit;} else {    // select sql here    $sql = "select * from `$TABLE` order by `id`;";    $result = mysql_query($sql);}?><table  align="center" width="400" border="0" cellspacing="1" cellpadding="0">    <tr>        <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">                <table width="400" border="1" cellpadding="3" cellspacing="1">                    <tr>                        <td colspan="6" align="center"><strong>Testimonials</strong> </td>                    </tr>                    <tr>                        <td align="center"><strong>Select</strong></td>                        <td align="center"><strong>ID</strong></td>                        <td align="center"><strong>Name</strong></td>                        <td align="center"><strong>Description</strong></td>                        <td align="center"><strong>Download</strong></td>                        <td align="center"><strong>Last Modified</strong></td>                    </tr><?php $row = mysql_fetch_assoc($result); ?><?php do { ?>                        <tr>                            <td align="center">                                <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>">                            </td>                            <td align="center"><?php echo $row['id']; ?></td>                            <td align="center"><?php echo $row['Name']; ?></td>                            <td align="center"><?php echo $row['Message']; ?></td>                            <td align="center"><a href="/admin/testimonial_files/<?php echo $row['Download']; ?>">Download</a></td>                            <td align="center"><?php echo $row['Modified']; ?></td>                        </tr>                        <tr>                            <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>                        </tr>                    </table>                </form>            </td>        </tr>    </table><?php } while ($row = mysql_fetch_assoc($result)); ?>


  12. What is your page suppose to be doing exactly? From the looks of it you are checking if there are any submissions for delete. If there are none which is mostly the case when you frist visit the page then that block is always going to execute. Which explains why the rest of the code fails because the block of code that assigns the $result1 variable never gets executed. You might want to change your if statements around appropriately.

    if(!isset($_POST['delete'])) {$sql = "select * from `$TABLE` order by `id`;";} else {$DELETE_ID = mysql_real_escape_string($_POST['delete']);echo("select * from `$TABLE` where `id` = '$DELETE_ID';");die();// Delete the file on the diskunlink('../admin/testimonial_files/'.$row['Download']);// Build your query, kind of weird but alright.$sql = ("delete from $TABLE where ");for($i=0;$i<count($_POST['checkbox']);$i++){if($i != 0) { $sql.= "AND "; }$sql .= " id='" . $_POST['checkbox'][$i] . "'";}

    if you do
    if(!isset($_POST['delete'])) {$sql = "select * from `$TABLE` order by `id`;";die("post delete not set");} else {$DELETE_ID = mysql_real_escape_string($_POST['delete']);echo("select * from `$TABLE` where `id` = '$DELETE_ID';");die("result should be set here");// Delete the file on the diskunlink('../admin/testimonial_files/'.$row['Download']);// Build your query, kind of weird but alright.$sql = ("delete from $TABLE where ");for($i=0;$i<count($_POST['checkbox']);$i++){if($i != 0) { $sql.= "AND "; }$sql .= " id='" . $_POST['checkbox'][$i] . "'";}

    that should tell you where its executing.

  13. still nothing


    That's very strange. Can you post your entire script again if its changed a lot? There should be some kind of output or error if something is wrong. Is anything being reported?
    The only other way to figure it out is to keep going back up a line and outing echo statements to make sure it the code actually reaches that point. You need to figure out exactly where it dying before you can resolve any issues.

  14. where do i put it i have tryed under the php but it doesn't echo anything


    Try it here.

    $DELETE_ID = mysql_real_escape_string($_POST['delete']);$result1 = mysql_query("select * from `$TABLE` where `id` = '$DELETE_ID';");$row = mysql_fetch_assoc($result1);mysql_close($result1);// change to $DELETE_ID = mysql_real_escape_string($_POST['delete']);echo("select * from `$TABLE` where `id` = '$DELETE_ID';");die();


  15. Hello, I am not similar with the flash survey tool you are using so I cant help as much. You say you created a separate table of your own to store the count for surveys taken and score. Does this mean that the flash survey tool it self does not store or keep track of this information already? To solve your problem you will need to locate the point where the flash survey does the save or insert to its database table if any. i.e. the end of a survey submission. If I can recall correctly flash can recall or redirect to php files I believe so locating such php files should be a start and you would obviously need to modify it here to do all your logic.


  16. nothing has changed it still shows the same messages


    Can you try a
    echo("select * from `$TABLE` where `id` = '$DELETE_ID';");

    The first thing you should do here is to try and verify you are building the sql correctly. There may be times where the value $DELETE_ID might not be as you expected so take the generated sql string and run it against your mysql database manually to verify it is valid. Any syntax errors you get you will need to fix.

  17. These are the errors i keep getting

    this is the code

    <?php// Set Global Vars$HOST = "XXXXXXXX";$USERNAME = "XXXXXXXXXXXX";$PASSWORD = "XXXXXXXX";$DATABASE = "testdocs";$TABLE = "docs";// Establish a connectionmysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());mysql_select_db($DATABASE) or die(mysql_error());// Query for resultsif(!isset($_POST['delete'])) {$sql = "select * from `$TABLE` order by `id`;";} else {$DELETE_ID = mysql_real_escape_string($_POST['delete']);$result1 = mysql_query("select * from `$TABLE` where `id` = '$DELETE_ID';");$row = mysql_fetch_assoc($result1);mysql_close($result1);// Delete the file on the diskunlink('../admin/testimonial_files/'.$row['Download']);// Build your query, kind of weird but alright.$sql = ("delete from $TABLE where ");for($i=0;$i<count($_POST['checkbox']);$i++){if($i != 0) { $sql.= "AND "; }$sql .= " id='" . $_POST['checkbox'][$i] . "'";}$result = mysql_query($sql);if(isset($_POST['delete'])) { header('Location: index.php');exit;}}?><table  align="center" width="400" border="0" cellspacing="1" cellpadding="0"><tr><td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"><table width="400" border="1" cellpadding="3" cellspacing="1"><tr><td colspan="6" align="center"><strong>Testimonials</strong> </td></tr><tr><td align="center"><strong>Select</strong></td><td align="center"><strong>ID</strong></td><td align="center"><strong>Name</strong></td><td align="center"><strong>Description</strong></td><td align="center"><strong>Download</strong></td><td align="center"><strong>Last Modified</strong></td></tr><?php $row = mysql_fetch_assoc($result); ?><?php do { ?>        <tr>                <td align="center">                        <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>">                </td>                <td align="center"><?php echo $row['id']; ?></td>                <td align="center"><?php echo $row['Name']; ?></td>                <td align="center"><?php echo $row['Message']; ?></td>                <td align="center"><a href="/admin/docs/<?php echo $row['Download']; ?>">Download</a></td>                <td align="center"><?php echo $row['Modified']; ?></td>        </tr>        <tr>        <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>        </tr></table></form></td></tr></table><?php } while($row = mysql_fetch_assoc($result)); ?>

    and these are the 2 lines the errors are referring to
    <?php $row = mysql_fetch_assoc($result); ?><?php do { ?><?php } while($row = mysql_fetch_assoc($result)); ?>


    It looks like the return from mysql_query() is not valid. You should first check its valid before performing anything on it such as mysql_fetch_assoc()


    Try this first:
    $result = mysql_query("select * from `$TABLE` where `id` = '$DELETE_ID';");if (!$result) {    die('Invalid query: ' . mysql_error());} else {// do what ever you need to do here.}

    Good luck.

  18. it is not picking up the field name so it is just giving links like example.com/""


    It's probably because your $row['Download'] is not a table field name (column) or the records just contain an empty string. Verify the field name and records for it in the database.

    Good luck

  19. <td><? echo <a href='/docs"$row['Download']"'>Download</a>; ?></td>

    Try not to mix standard HTML tags with your echo PHP statement. It makes it more organized and less prone to errors as what ever editor you may be using can highlight the HTML code.


    This is how I would write it but its really up to personal preference.
    <td><a href="/docs/<?php echo $row['Download']; ?>">Download</a></td>


  20. Hi, First of all what does the $row['Download'] output? If it is just the file name then you will need to build the anchor tag your self. You should know where the file is being uploaded to so build the anchor tag accordingly.

    while($row = mysql_fetch_array($result)){echo "<tr>";echo "<td width='150'>" . $row['Name'] . "</td>";echo "<td width='250'>" . $row['Message'] . "</td>";echo "<td width='100'>" . $row['Download'] . "</td>";echo "</tr>";}echo "</table>";

    Something like ?

    while($row = mysql_fetch_array($result)){echo "<tr>";echo "<td width='150'>" . $row['Name'] . "</td>";echo "<td width='250'>" . $row['Message'] . "</td>";echo "<td width='100'><a href='PATH_TO_FILE".$row['Download']."'>" . $row['Download'] . "</a></td>";echo "</tr>";}echo "</table>";

    Assuming $row['Download'] contains your file name...
    Good luck

  21. I cant say I agree with everything that's been said here. I guess from my own point of view the owners can do what they like. Ever hear of the saying don't expect anything from anyone and you wont get disappointed? The forums still work, sure there is spam but there is always going to be span its the internet. Just because the moderates don't remove it intimidate you will not die. I'm not sure how this would affect its search rankings but I'm pretty sure it would have little or no effect. I have searched up topics in the past on Google and it points me here so there are some good posts. I don't think you should be blaming the admins for the types of members we have who don't post good topics. The admins have no control over what you post so doesn't that seem unreasonable to you? I do not know fully what has become of this place over the last year but I can still post and reply to topics and still earn mycents. That is enough for me and I don't really expect anymore. I am how ever disappointed on the number of topics relating to the areas I'm interested in but then I remember this place is a forum for all topics to be discussed. I don't expect much to happen from the admins as I don't think its really their job to control what users post here and the quality. Its out of their hands. We can only hope more quality topics are started and continued by its members. Not everyone has the time to come here and post a really good topic. I'm seen half *bottom* tutorials and think to my self man these guys are lame but have a I posted anything good no.. I want to post a tutorial on an image gallery I made up which is unique but I have not had the time. Plus I am only half way through building it myself so when I do get time I will since I've not seen anything out there that's similar on the web. You have to remember not everyone out there is an expert in their field so you cant expect everyone to be posting high quality content all the time.


  22. Object Oriented just means you treat every entity in your code as objects. They have properties and methods (actions) you can perform on them to do various tasks.The GWT I remember is a toolkit to allow you to write web applications that uses a lot of JavaScript in Java so you will need to know a fair bit about java. Its purpose to allow you to write complex applications without worrying about cross browser compatibility issues. I have tried this before but not to the level of producing anything. To me it seem like a lot of over head before you got anything working and in the end when I wanted to change something small like the layout or style of something it wasn't so obvious where.

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.