Jump to content

CWeaver

Members
  • Posts

    16
  • Joined

  • Last visited

CWeaver's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. I'm successful in refering to the input values within a form by using code like this:Input form: <Form action="TestimonialApproval.php" method=post> <input type='text' size=90 name=TA[Testimonial][2] value='Second Event' /> Processing file(TestimonialApproval.php): echo "<BR />Testimonial Approval."; $ApprovedCount = 0; foreach ($TA as $Key => $Value) { if ($Key == "Testimonial") { foreach ($TA["Testimonial"] as $TAKey => $TAValue) { if ($TA["ApprovedCB"][$TAKey] == true) { $query = "update testimonials set Testimonial = '" . $TAValue . "', PatientID = " . $TA["PatientID"][$TAKey] . ", Approved = 1 where TestimonialID = " . $TA["TestimonialID"][$TAKey]; $result = mysql_query($query); if ($result) { $ApprovedCount++; }; } else { //echo "<BR /> Not Approved"; } } } } echo "<br /> Testimonials approved: " . $ApprovedCount; But when the input elements are within a table, the arrays don't work the same.Input side: <form action='CalendarEventEditProcessing.php' method='post' enctype='multipart/form-data' name='CalendarEventsEdit'> <table cellspacing="1" rowspacing="2" border="0" align="left"> <tr><td align="left" valign="middle" colspan=2> <input type='text' size=90 name=CEA[EventTitle][1] value='Second Event' /></td></tr> Processing (CalendarEventEditProcessing.php): foreach ($CEA as $Key => $Value) { echo "<br />" . $Key . " : " . $Value; if ($Key == "EventTitle") { foreach ($CEA["EventTitle"] as $CEAKey => $CEAValue) { echo "<br />" . $CEAValue . "title"; } } } What this produces isname : Arraytype : Arraytmp_name : Arrayerror : Arraysize : ArrayIt never finds the "EventTitle" key even though it's one of the indices.How can I grab the values of the CEA array as I have done with the TA array? Does this have to do with the CEA array being within a table?Thank you.
  2. CWeaver

    PHP and MySQL

    OK, here's what the problem was, I think:I was incorrectly specifying the database, and superfluously as well! $result = mysql_query($query, $databasename); mysql_select_db("databasename", $connection); When I removed the incorrect inclusion of the databasename in the mysql_query call, everything worked fine. The second parameter in mysql_query is meant to specify the connection to use. By default, it uses the most recent connection.Thanks for your help, and sorry I didn't include the errant code the first time; just didn't see it.
  3. CWeaver

    PHP and MySQL

    Very good advice. I'm currently running Apache with PHP and MySQL for my localhost stuff. But on this project, my first using MySQL, I've developed the data on the host and not locally. Which brings up another issue, I don't know how to transfer data from one server to another -- hence the reason for putting it on the remote server; it's the only way I could be sure that my customer would be able to see what I was developing.
  4. CWeaver

    PHP and MySQL

    I think there's something else going on. Row retrieval that was working fine yesterday is not today. The only reason I didn't suspect my host sooner is that I have no trouble retrieving data through MySQL Client. I don't think it's my host. It just doesn't make sense that MySQL Client can get data and my PHP can't because of something on the server. Thanks for running my code on your system. As for the @ sign -- I took it from a template that I saw. I'm just getting started with this database connectivity stuff.
  5. CWeaver

    PHP and MySQL

    I like clarity in code as well. I've made this change in mine. This is a critical point! In other scripts the same code worked for other tables. I'm not certain how. Anyway, including the name of the database above did not make a functional difference.Can you see anything else wrong with my code? Is there another place that I should be naming the database to use?
  6. CWeaver

    PHP and MySQL

    Here's what I'm doing. The result is consistantly No records found. select * from patientsThere are two records in the table and I can access them through MySQL Client. <?phpsession_start();include ("Common.Inc.php");@ $db = mysql_pconnect('some ip address that works here', 'username', 'password');if (!$db){ echo "<BR />There's been a problem connecting with our server."; echo "<BR />Please try this service again later."; exit;} DisplayPatientSelection();?>//in Common.Inc.php:function DisplayPatientSelection(){ $query = "select * from patients"; $result = mysql_query($query); if ($result) { $num_results = mysql_num_rows($result); if ($num_results > 1) { echo $num_results . " patients found."; } else { echo $num_results . " patient found."; } } else { echo "<br/>"; echo "No records found."; echo "<br/>"; echo $query; }} Sorry that none of the indentations in my code come across here. Any ideas on what I'm doing wrong? Other similar queries to other tables on the same server within the same database work.
  7. CWeaver

    Call a Script?

    Thanks!The use of print is something I had never considered.
  8. CWeaver

    CSS with <td>

    Thanks. This was helpful.
  9. I've seen this recommended many times: $EncryptedPassword2 = md5($password); But doesn't all php run on the server? So what's the point since you're sending the password to the server and the server is encrypting it then processing a query with it? Seems like it should be encrypted on the client then sent to the server. Is there a way of doing so? Is there a point to encrypting it on the server?
  10. CWeaver

    Call a Script?

    Can I invoke a php script from the server as a href would be from the client? if (thisIsTrue){ RunThisScript.php?var=Stuff;}else{ RunThisScript.php?var=OtherStuff;} I can call functions OK, but I can't figure out how to redirect the process to another script, abandoning the one I'm in altogether. Can it be done? Seems really old school in a way, but I would like to know anyway.
  11. I like this example. It's simple and clean and a good basis from which to start.I have a couple of questions though. First, why $getdbpassword = mysql_query("SELECT * FROM password");while ($row = @mysql_fetch_assoc($getdbpassword)){ Instead of $getdbpassword = mysql_query("SELECT * FROM password WHERE password='".$password3."'"); And why aren't you asking for a user name and checking for the combination of user name and password?Thanks.
  12. CWeaver

    CSS with <td>

    I would like to no how to control the width and word wrap on a <td> using external CSS.
  13. I'm doing this, so far: <button name=edit value='Edit' class='SubmitButton' type=button onclick="javascript:window.location='TestimonialInput.php?Patient=<?php echo $Patient; ?>&Testimonial=<?php echo(trim($Testimonial));?>'">Edit</button> I'm having trouble with values for $Testimonial that include more than one line. Fact is, it doesn't work at all. Furthermore, when I do this: <?phpecho $Testimonial;?> all of $Testimonial is returned on one line, even though the user has input text through a <TEXTAREA> with multiple returns. I know I've seen this somewhere before, this business of passing a string with new line characters in it, but I can't remember where. Anyone have an answer or a link to the manual page that defines the issue? Or maybe I'm going about this in all the wrong way. Take a look at how this page works. The Post New Topic and the Preview Post buttons are both 'Submit' buttons within a <FORM>. The data is being passed through the post method but I can't figure out how the receiving php script knows whether it was preview or post that was clicked.I would like to know how to pass the parameters correctly, but I would also like to know if there's a better way to go about this.
  14. After I left to pick up lunch I thought of the answer: onclick="javascript:window.location='TestimonialInput.php?Patient=<?php echo $Patient; ?>&Testimonial=<?php echo $Testimonial;?>'" I'm extracting the parameters passed with this: <?phpif (!isset($PHP_SELF)) { function registerglobals($which){ global $$which; if(isset($$which)){ if(is_array($$which)){ reset($$which); while(list($key,$val)=each($$which)){ global $$key; $$key=$val; } } } } registerglobals("_GET"); registerglobals("_POST"); registerglobals("_COOKIE"); registerglobals("_SERVER"); registerglobals("_ENV"); registerglobals("_SESSION");}?> It's in an include file that handles all of the calls. Thanks for the input. If it hadn't hit me in the face while making a left hand turn, your response would have done it for me.BTW, don't ever forget the ';' at the end of each php command. The nasty thing about leaving them out is that nothing happens. I would like to find a php syntax checker. Know of any?
  15. I went with this:onclick="javascript:window.location='TestimonialInput.php?Patient=$Patient&Testimonial=$Testimonial'" And got to the page I wanted, but my parameters came through as literals. Are you conversant enough in PHP to see what I've done? I'm just getting started in this parameter passing business.
×
×
  • Create New...