Jump to content

rpjd

Members
  • Posts

    66
  • Joined

  • Last visited

    Never

Everything posted by rpjd

  1. On page 1, the user selects information by selecting various checkboxes. Those selected if any, are displayed on page 2 in another form which in turn when submitted, may require one or more rows to be added to various tables on page 3. Pages and 2 are both working fine, I just need to call the javascript function based on whats in $_POST from page 2. If I can get that working that would be great.
  2. The form is on a php webpage. After processing whats in $_POST in a seperate script, how/where do I then call the javascript function?
  3. I should have clarified that, yes, a html table. When a form on another page is submitted, depending on the contents of $_POST the php script checks the data submitted, calls the javascript function which adds a new row with $_POST data to a table on the action page before displaying the action page. At the moment, I only have an alert in the function, until I'm sure the javascript function is executing. But as yet, the javascript is not responding.
  4. I want to add a new row to a table.
  5. I am trying to call a javascript function from a php script. This is the approach I'm using. I have an alert in the function, just to confirm the function executes. echo "<script type='text/javascript' src='http://localhost/Project/JScript/File.js'>"; echo "<script type='text/javascript'>functionName();</script>"; Is this the correct approach?
  6. I tried file_get_html on the file insteasd on file_get_contents, but I got the same problem, Fatal error: Call to undefined method DOMDocument::file_get_html() Can anyone explain this?
  7. Just for curiousity sakes, I did file_get_contents() on the file, the file_get_html() on the contents. $source = file_get_contents( 'E:/wamp/www/Project/File.php' ); $document = new DOMDocument; $document->validateOnParse = true; $document->file_get_html($source); Fatal error: Call to undefined method DOMDocument::file_get_html()
  8. More of less yes, as references are also table id's References can be '1', '12', '11-1'.
  9. As I just eluded to, if a reference is submitted via the form ($_POST['Ref']) for the first time, then no table exists with that id(value) and a table is created with that id(value). If a reference has been previously submitted, the table does exist and a new row is appended to that table. What I'm trying to do is parse the html on the page and compare the existing table id's if any with submitted references, then call appropriate javascript to create and append the table/row, depending on the comparison result(s).
  10. $Ref = $_POST['Ref']; If a table exists on the page whose id is equal to any value in $Ref array, append new row to the table, else create new table whose id is that value.
  11. How then can I check if an id of a certain value exists on a page that is the same as a submitted form value in $_POST?
  12. User submits 1 or more refrerences via a form. On the action page I want to check if any id's on the page match any values submitted in $_POST. $Ref = $_POST['Ref']; $source = file_get_contents( 'E:/wamp/www/Project/File.php' ); $document = new DOMDocument; $document->validateOnParse = true; $document->LoadHTML($source); for($i=0; $i<count($Ref); $i++) { $ID = $document->getElementById('$Ref[$i]'); } I have a table on the source page with the same id as a reference contained in $Ref, but getElementById is not seeing/recognsing it. No idea why not.
  13. I'm using a php $_POST variable as the name of a file that I want to create. fopen() , according to my understanding open the file if it exists or creates it if it doesn't. $Ref = $_POST['Ref']; I using each reference element of $Ref as the name of a file in a certain directory. So if $Ref[$i] exists as a file name in a certain directory, append to the file, if it doesn't create the file in that directory and write to it. Do I use the file path of the file within fopen()? fopen(./References/$Ref,a) or fopen(./References/$Ref,w)?
  14. I am submitting $_POST data to a results page. The data comprises of references and text. Each reference has its own table on the results page. I need to check if an any of the table id's on the results page are the same as any of the references in $_POST, if any are, I am appending to the table, if not I am creatig a new table for the reference. How do I check if a table id exists in order to append, then create tables for those that don't Any help/guidance appreciated.
  15. It works! if(array_key_exists('Ref',$_POST) && ! empty($_POST['Ref'])) { include('E:/MySQLCon.php'); $Ref = $_POST['Ref']; $Con = mysql_connect($host, $user, $pass) or die("cannot connect to server" . mysql_error()); $db = mysql_select_db('database',$Con) or die("cannot connect to database" . mysql_error()); $Ref = array_map('mysql_real_escape_string', $Ref); $string = implode("', '", $Ref); $query = "SELECT Ref, Text FROM const WHERE Ref IN( '$string' )"; $result = mysql_query($query, $Con); while($Text = mysql_fetch_assoc($result)) { echo "Ref " . $Text['Ref'] . "Text " . $Text['Text'] . "<br>"; } } Thank you!
  16. Having executed the query this for loop while($Text = mysql_fetch_assoc($result)) { for ($i=0;$i<count($Text);$i++) { echo $Text[$i]; } } is giving this error Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given for the while() statememt. Can't see how its seeing a boolean value.
  17. I absolute hope not! In trouble otherwise. Applied yor suggestion $Ref = $_POST['Ref']; $Con = mysql_connect($host, $user, $pass) or die("cannot connect to server" . mysql_error()); $db = mysql_select_db('database',$Con) or die("cannot connect to database" . mysql_error()); $conRef = array_map('mysql_real_escape_string', $Ref); $string = implode("', '", $Ref); $query = "SELECT Text FROM table WHERE Ref IN( '$string' )"; $result = mysql_query($query,$Con); If I'm expecting the result to be an array of text strings, do I need to do the same escape and implode on the result as well in order to access them?
  18. I'm passing 1, 2, 3-1 to the query, the output are text strings (sentences/paragraphs).
  19. Ok I'm passing an array [1, 2, 3-1] into a query initially, which needs to be escaped and imploded into a string. Should I pass the elements of the array through a for loop to escape each one, then implode the array into a string. Is this correct, or should I go about it another way?
  20. I've changed it slightly $Ref = $_POST['Ref']; $Con = mysql_connect($host, $user, $pass) or die("cannot connect to server" . mysql_error()); $db = mysql_select_db('database',$Con) or die("cannot connect to database" . mysql_error()); for($i=0;$i<count($Ref);$i++) { $list = mysql_real_escape_string($Ref[$i]); } $emplodedList = "'".implode("','", $list)."'"; I'm getting this error Warning: implode() [function.implode]: Invalid arguments passed
  21. I have this code $Ref = $_POST['Ref']; $list = "'".implode("','", $_POST['Ref'])."'"; $Con = mysql_connect($host, $user, $pass) or die("cannot connect to server" . mysql_error()); $db = mysql_select_db('database',$Con) or die("cannot connect to database" . mysql_error()); $list = mysql_real_escape_string($list); $query = "select Ref, Text from table where Ref in($list)"; $result = mysql_query($query,$Con); while($Text = mysql_fetch_assoc($result)) I'm getting this error : Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given $_POST['Ref'] contains values of checked checkboxes. Can't understand why its $result contains boolean values?
  22. I have a table with two columns A and B. I'm submitting a form where the user selects different checkboxes. Column A contains the values of all the checkboxes. I want to, after the form is submitted, using the array of values of randomly checked checkboxes, search the table for the corresponding values in column B. Then display the values of selected checkboxes and their cosesponding values from column B. First I did an implode() on the array of submitted checkbox values, $list = "'".implode("','", $_POST['Ref'])."'"; then did a mysql_real_escape_string on that. for($i=0;$i<$count;$i++) { $list = mysql_real_escape_string($list[$i]); } I got a Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established for each row of $list. What am I doing wrong?
  23. Ok. How and where exactly show this information be stored?
  24. I don't mind doing the data processing on the same page as the display page, but I don't want the servername, user and password visible? Can/should I have the connection details listed in another security file perhaps?
  25. So how do I output it to page2.php?
×
×
  • 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.