Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. "best" for flexibility and protection against data loss would be putting them in a database. But if you want them in a file, there are 2 basic steps to the validation. 1. Read in the data from the file. This requires opening the file, reading in the lines and removing newline characters. 2. Check each number against the submitted number For #1 you could use a tutorial such as this one, found by googling for "php file read tutorial" : http://www.phphelps.com/8_How_to_read_file_in_PHP.shtml Then once you have a loop that reads in the file, you can add code to check each number. Keep in mind if there might be extra spaces or other invisible characters in either number. I wouldn't consider XML until you are comfortable with dealing with a plain text file.
  2. Can you post what you have tried? One approach is to cast the result to an array, eg: $result = (array) $result; This will only convert one level to an array, and must be repeated at each level. The other thing that would help us to help you is to post a var_dump() of the result. You can get that like this: print "<pre>"; var_dump($result);
  3. What you're asking is a bit general.. the short answer is yes, I believe you can use php to generate whatever html you are generating with jquery now. The long answer is it sounds like you want a more detailed answer, but I can't give anything more detailed from the description you've given me. Basically, php is capable of anything which produces static html. It isn't capable of anything which requires changing the html after the page has loaded. So if you want html generated for the initial page load, such as a few divs with different prices in them, php can do it.
  4. btherl

    php.ini

    Try this: $a['test'] = 1;
  5. If that's a microsoft soap server I would be looking at the MSDN soap documentation. AFAIK their soap servers expect the action in the headers. Which you appear to be doing.. maybe try SoapAction instead of SOAPAction?
  6. That looks like a bit of a mess. You've provided the action and other variables in 3 different places. The first step for soap debugging is to start out by seeing what the soap library is really sending. For that you can use these: http://www.php.net/manual/en/soapclient.getlastrequest.php http://www.php.net/manual/en/soapclient.getlastrequestheaders.php Also you can remove your authentication info from $options, SoapClient is not interested in them. The soap client options are listed here: http://www.php.net/manual/en/soapclient.soapclient.php These should either be in the headers or passed to the client in $params, depending on what is expected. Even then you can have other problems if the server is not written to expect php's soap library as a client.. and that's where you need to see the actual message to debug it.
  7. I would remove the call to checkExistence(). Removing the check from canView() doesn't make sense because that query is required to get "parent" and "hidden" anyway.
  8. Change this: $result =pg_query($q1); //or die(pg_last_error()); /* Don't comment out the "or die" - you need it to find the bug */ to this: $result =pg_query($q1) /* Remove ";" here when uncommenting the next line */ or die(pg_last_error()); /* Don't comment out the "or die" - you need it to find the bug */ Then the next thing to do is to print out the query which has the error. Add this line: echo "<br>Query is $q1<br>"; Add that after $q1 has been set, but BEFORE it use used in pg_query(). Then post what it prints here.
  9. If that is your whole sample.php, a few things are missing. Try this: $myid =$_GET[id]; /* Here you need the call to pg_connect(), so you can call pg_query() on that connection */ callme($myid); /* Don't put "$" in front of callme */ function callme($myid){ $sql2 =" SELECT * FROM employee WHERE empid = ($myid)"; $result=pg_query($sql2); or die(pg_last_error()); /* Don't comment out the "or die" - you need it to find the bug */ while($row=pg_fetch_array($result)){ /* Use pg_fetch_array() on $result, not on $sql2 */ echo $row[empid]; } }
  10. Inside your function callme(), $myid is not defined. You can pass it as an argument like this: callme($myid); function callme($myid) { ... } A good debugging technique for this situation is to print out the query which fails. Then you would see that $myid is missing.
  11. When you connect to the database, do you check for errors?
  12. btherl

    php4 to php5

    That's very much a postgres issue, it's probably not related to the php version. But the postgres version may also have changed. You can try these solutions: and O.delivery_date::text like '$order_year-$order_month-$order_day%' That casts the delivery date to text before doing the like. It'll work but it won't use any indexes on that column (unless the index happens to be in that exact form, which I doubt). Another option: and O.delivery_date >= '$order_year-$order_month-$order_day' AND O.delivery_date < '$order_year-$order_month-$order_day'::date + '1 day'::interval Making it a range like that using the native type of the column can give you better optimization. I'm guessing the column is a timestamp, because there's no need to use "like" if it's a date. Or you could calculate what the following day is and put it into the query directly, which may give better optimization. It really depends on your indexes and which version of postgres you have.
  13. btherl

    php4 to php5

    Hi, Does the query execute but return nothing? If that's the case the steps I would take in order are: 1. Display the query (eg echo $query) 2. var_dump($products) - see if this is "false" or if it's a resource. If it's false the query failed, and you should check pg_last_error() 3. If $products is a resource then check if pg_num_rows($products) == 0. If it does, then you have an empty result set. Probably because the query is not what you expect. In which case you need to go back through the code finding where the input data comes from.
  14. Well that sounds better than "credentials not supplied". A change of error message is usually a good thing Also I noticed your namespaces are different now.. Anyway, is it working now? It's a week since your last post.
  15. ns1 in your code is the same namespace as both impl and mod in the sample request, so the namespaces look ok. The obvious thing missing is ns1:principal, which is impl:principal in the sample - is it really optional like the sample says? I would try adding it in and see what happens.
  16. Sorry, I made a typo - it should be $st->errorInfo(), not $sth->errorInfo() There's nothing mysterious about it starting to fail - the code is specialized for a particular type of data, and when you modify the data it can start to fail. The solution is to add debugging so you can find exactly where it fails. Once you narrow it down to a single location it is much easier to find why that single location is not working anymore. Even generic (not specialized) code can start to fail when other code is modified, because it may start getting input it wasn't designed to get. Have you modified the books table at all? Or modfied any other tables?
  17. The code you're working with is too complex, you really should start with something simpler. What you should do is replace the original $st->execute() like this: public function insert() { // Does the Article object already have an ID? if ( !is_null( $this->id ) ) trigger_error ( "Article::insert(): Attempt to insert an Article object that already has its ID property set (to $this->id).", E_USER_ERROR ); // Insert the Article $conn = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD ); $sql = "INSERT INTO books ( booktitle, author, edition, category, module, price, condition, description, image, pdate ) VALUES ( :booktitle, :author, :edition, :category, :module, :price, :condition, :description, :image, FROM_UNIXTIME(:pdate) )"; $st = $conn->prepare ( $sql ); $st->bindValue( ":booktitle", $this->booktitle, PDO::PARAM_STR ); $st->bindValue( ":author", $this->author, PDO::PARAM_STR ); $st->bindValue( ":edition", $this->edition, PDO::PARAM_STR ); $st->bindValue( ":category", $this->category, PDO::PARAM_STR ); $st->bindValue( ":module", $this->module, PDO::PARAM_STR ); $st->bindValue( ":price", $this->price, PDO::PARAM_INT ); $st->bindValue( ":condition", $this->condition, PDO::PARAM_STR ); $st->bindValue( ":description", $this->description, PDO::PARAM_STR ); $st->bindValue( ":image", $this->image, PDO::PARAM_STR ); $st->bindValue( ":pdate", $this->pdate, PDO::PARAM_INT ); # Replaced code is here: if (!$st->execute()) { $arr = $sth->errorInfo(); print_r($arr); } # End of replaced code $this->id = $conn->lastInsertId(); $conn = null; }
  18. Ok, how about this: mail('fetch@domain.com', $subject, $message, "From: domain.com <noreply@domain.com>\r\nReply-To: {$_POST['email']}"); Then someone clicking "Reply" after receiving this email should have the reply sent to the email address entered in the form.. is that what you are looking for?
  19. The tutorial you are working from doesn't check if $st->execute() succeeded, which means you may not see errors. For example you could do this: if (!$st->execute()) { $arr = $sth->errorInfo(); print_r($arr); } http://www.php.net/manual/en/pdostatement.errorinfo.php
  20. The "From" address is specified as noreply@domain.com. If you want them to be able to reply then that should be the address you want them to reply to. Edit: Or, you can use a reply-to header. There is an example here: http://php.net/manual/en/function.mail.php
  21. You are setting $currentYMD only inside the "else" branch. If nothing is found in the database you only run this one line: $currentSRNum = 1;
  22. Whether that's acceptable depends on how the assignment question was worded
  23. Try calling your function like this: leap_year($year); And declaring it like this: function leap_year($year)
  24. Are there limits on how many access levels each user can have? Can they have 0, 1, or more? A left join is required if users can have 0 access levels AND you still want them listed. If all users have exactly 1 access level then you can use "JOIN" instead of "LEFT JOIN". The left join will still work but it limits what query plans the database can use, so it's better to use a plain "JOIN" if you don't need the left join.
×
×
  • 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.