Re: [PHP-DB] Really weird problem: cross-server databasing *g*
Hi Markus-- It sounds like the provider that only allows local connections to their database went through some pains to protect their database. I suggest talking to them about your needs and not trying to circumvent their security measures. Maybe they have a system to open up their database for you for a monthly fee? Doug At 04:42 AM 9/2/01 +0200, Markus Mayer wrote: Hi folks! Let's say you have two servers, on the first one (A) you have your website containig all those nice php scripts and co but only a crazy small database (2 megs), on the second one (B) you have a really big database available but the problem, that the provider won't allow you to access the database from any other place than from your account on B. That wouldn't be the problem, but B opens pop ups each time, you open a website there - and that couldn't be the solution. Has anyone an idea how to access the database on B without opening a webpage there (and with this, without opening a popup) from server A? ANY help much appreciated! Markus Mayer --Doug's Signature File ~ ~ ~ I'm proud to work for GLISnet, Michigan's best ISP ~ ~ ~ --1.888.445.4763---8am to 8pm every day---http://www.glis.net-- The views and opinions expressed in this email are my own and may not be those of my employer. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Searching sql database using php
Yes. If you have a specific question, please post it and I'm sure folks will be willing to try to help you out. Doug At 12:50 PM 9/3/01 +1000, Devon wrote: As per topic anyone know how to do it? Cheers --Doug's Signature File ~ ~ ~ I'm proud to work for GLISnet, Michigan's best ISP ~ ~ ~ --1.888.445.4763---8am to 8pm every day---http://www.glis.net-- The views and opinions expressed in this email are my own and may not be those of my employer. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Simple database error (SPACE)
DW was correct, Nagasea. The way to do what you want to do is to use the urlencode (and perhaps the urldecode) PHP command(s). They are in the PHP manual. I don't understand what it was that DB told you to do, so I cannot comment on that, but the correct solution to your problem lies with urlencode. Additionally, you will want to put quotes around the HREF in your anchor tag. Perhaps if you rewrote your echo to something like this (WARNING:untested!): echo a href=\m_template.php?nick=; echo urlencode($myrow[3]); echo \; echo $myrow[3]; echo /a; Oh, yeah, and I broke it apart for easy reading. You could concatenate it all in one big echo, but think maintainability. Hope this helps, Doug At 05:01 PM 8/30/01 -0700, Nagasea wrote: it's still not working :( maybe u need my script to see $db = mysql_connect(localhost, ,pass); mysql_select_db(mydatabase_com,$db); $result = mysql_query(SELECT * FROM big_member WHERE position='Squads' ORDER by first LIMIT 0,300,$db); while ($myrow = mysql_fetch_row($result)) { echo( a href=m_template.php?nick=$myrow[3]. $myrow[3] ./a); } [--snip--] --Doug's Signature File ~ ~ ~ I'm proud to work for GLISnet, Michigan's best ISP ~ ~ ~ --1.888.445.4763---8am to 8pm every day---http://www.glis.net-- The views and opinions expressed in this email are my own and may not be those of my employer. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Database Transactions and HTTP statelessness
Hi BP-- 0. User A loads Record R. 1. User B loads Record R. 2. User B edits and saves Record R. (Saving involves starting a transaction, retrieving R from the DB, comparing the values with the original values to make sure it is the same record, and then the UPDATE and then commiting the transaction). 3. User A edits and saves Record R. (Saving involves starting a transaction, retrieving R from the DB, comparing the values with the original values to make sure it is the same record, and when it's not, rolling back the transaction and notifying the user that the record has already been modified by another user or process). Hope this helps! Doug At 02:02 AM 8/29/01 GMT, Bopolissimus Platypus wrote: hello all, I've got a question about what's got to be a common problem. I'm sort of doing a survey to see how others have solved this problem before so that I can choose one that's best for me. Basics: The software is a web based data entry system. Sessions are maintained (so that users don't have to login after every database operation, and for security - users can only perform actions that are allowed to their login or group0. Use Case: 0. User A loads Record R. 1. User B loads the same Record R. 2. User B edits and saves Record R. 3. User A edits and saves Record R. [--snip--] --Doug's Signature File ~ ~ ~ I'm proud to work for GLISnet, Michigan's best ISP ~ ~ ~ --1.888.445.4763---8am to 8pm every day---http://www.glis.net-- The views and opinions expressed in this email are my own and may not be those of my employer. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Database Transactions and HTTP statelessness
Hi BP-- There's also named cursors, but then you're going to have the problem of time. That is if you create a cursor FOR UPDATE and the user never saves the record or never cancels the edit (just closes her browser, for instance), then you're messed up and have locks floundering around in the db. In the HTTP stateless scenario, you really do want to do everything within the timespan of a single page-view. Dave Watkinson's suggestion for a column in the table to store some kind of version info (a timestamp or some other identifier that is updated every time the record changes) is a good one because it makes detecting an updated row a lot easier than comparing all of the original values from the originally loaded record to what's there when you finally go to save it. However, there may be times when Dave's suggestion can be overly restrictive. Let's say User A changes one column of Record R and User B changes a different column of Record R. In that case, the changes do not step on each other and probably should be allowed. Dave's suggestion for a per-record version identifier would kick out the 2nd person to save the record's edits with the this record has been changed by another user or process message. Perhaps that's correct for your application, perhaps it is not. You and your customer have to decide. That's why I tend to compare the originally loaded values of the fields that have been changed by the user with the fields as they appear in the record during the transaction that UPDATEs the record. If they're different then those fields really have been modified by another user or process and the transaction should be abandoned until the user gets a chance to review the situation. Hope this helps, Doug At 12:13 PM 8/29/01 GMT, Bopolissimus Platypus wrote: On Wed, 29 Aug 2001 03:18:01 -0400, [EMAIL PROTECTED] (Doug Semig) [--snip--] thanks. that was one of the alternatives i'd been considering. heh, i was trying to avoid the complexity. after all, if the database already has locking and data consistency built-in, why reinvent the wheel, right? but that denial of service thing is a problem (and it would be a SELF-denial-of-service :). thanks for voting for this alternative. i'll wait a few days for others to comment and maybe provide alternatives before committing to one approach :). tiger [--snip--] --Doug's Signature File ~ ~ ~ I'm proud to work for GLISnet, Michigan's best ISP ~ ~ ~ --1.888.445.4763---8am to 8pm every day---http://www.glis.net-- The views and opinions expressed in this email are my own and may not be those of my employer. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] SELECT giving too much :)
Hi Beau-- This is just a wild guess (I've only glanced at your SQL), but do you have two locations in your locations table? You might want to try yanking locations out of the join since you're not using it in your WHERE clause or showing any info from it. Doug At 12:06 PM 8/30/01 +0800, Beau Lebens wrote: Hi guys, I have a set-up to query a database by allowing the user to build a query from selecting fields, restrictions etc etc. It produces the following; SELECT students.fname, courses.title AS course FROM students, courses, course_enrolments, groups, locations, staff WHERE (students.studentID=course_enrolments.studentID AND course_enrolments.courseID=courses.courseID) AND (students.groupID=groups.groupID) AND (staff.staffID=courses.staffID) ORDER BY fname ASC [--snip--] --Doug's Signature File ~ ~ ~ I'm proud to work for GLISnet, Michigan's best ISP ~ ~ ~ --1.888.445.4763---8am to 8pm every day---http://www.glis.net-- The views and opinions expressed in this email are my own and may not be those of my employer. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] SELECT giving too much :)
Hi Beau-- Alternatively you could probably include an AND for the location ID to link up with whatever it is supposed to link up to in the WHERE clause. But I have no idea how you responded to my message in 2 minutes flat! Are you a remarkably complex AI autoresponder that knocks the socks off of ELIZA (or whatever it was) style programs? Dang! 2 minutes! Good job grin. Doug At 12:33 PM 8/30/01 +0800, Beau Lebens wrote: Actually yes I do :) thanks for that - it fixes it when i remove the FROM locations although I didn't want to have to pull it, because it is going to mean some ugly testing and stuff that I wanted to avoid - oh well, looks like I have no choice now :) Cheers beau [--snip--] --Doug's Signature File ~ ~ ~ I'm proud to work for GLISnet, Michigan's best ISP ~ ~ ~ --1.888.445.4763---8am to 8pm every day---http://www.glis.net-- The views and opinions expressed in this email are my own and may not be those of my employer. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] MySQL DB CleanUp Help!
Or of course one could compile PHP as a standalone and simply cron the script itself. No matter how PHP is invoked, though, IMHO scripts like this that require no human interaction should be a bit more robust than interactive systems. For example, one would probably want to code it to make sure the two instances of the same script cannot run simultaneously (and if an instance tries to run simultaneously, it should send an email to the admin and quit instead of performing its duties). Also error checking should email problems to the admin. As an alternative to emailing the admin, you could log status messages and errors to syslog or a file or a db table. Good luck! Doug At 03:30 PM 8/23/01 +0800, Jason Wong wrote: - Original Message - From: Arcadius A. [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 23, 2001 9:28 PM Subject: [PHP-DB] MySQL DB CleanUp Help! Hello ! I'd like to automatically delete old entries from my MySQL ...[snip]... Arcad. Here's one way to do it: Create a php page which when accessed will do deletions you require. Create a cron job which uses wget to access that page. regards -- Jason Wong Gremlins Associates www.gremlins.com.hk --Doug's Signature File ~ ~ ~ I'm proud to work for GLISnet, Michigan's best ISP ~ ~ ~ --1.888.445.4763---8am to 8pm every day---http://www.glis.net-- The views and opinions expressed in this email are my own and may not be those of my employer. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] 2 Tables- 1 Insert Problem
Beyond that excellent answer, this is exactly the kind of situation where transactions would be helpful (and in a lot of cases, mission critical). So an expanded quasi-pseudocode rendition of olinux's answer could be: $result_bt = mysql_query('[whatever it takes to begin a transaction]'); $result_1 = mysql_query($sql1); if (!$result_1) { $result_rb = mysql_query('[whatever it takes to rollback a transaction']); /* whatever else you want to do, such as show an error message */ } else { $result_2 = mysql_query($sql2); if (!$result_2) { $result_rb = mysql_query('[whatever it takes to rollback a transaction']); /* whatever else you want to do, such as show an error message */ } else { $result_et = mysql_query('[whatever it takes to commit a transaction']); } } If your implementation of MySQL supports transactions (and if it doesn't then either change databases or web hosts), use them. It helps ensure the integrity of the data. Please feel free to be more elegant in the error checking...the above is just an example and would undoubtedly not be used, even fixed up for syntax, on a production site. Doug At 10:25 PM 7/28/01 -0500, olinux wrote: Not possible. do this $result_1 = mysql_query($sql1) or die('Insert 1 failed'); do this $result_2 = mysql_query($sql2) or die('Insert 2 failed'); olinux -Original Message- From: Steve Fitzgerald [mailto:[EMAIL PROTECTED]] I'm trying to insert data into two separate tables using 1 INSERT. ... snip ... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Re: enum !!
I applaud your efforts to learn SQL. I wonder, though, if the PHP-DB list the best place to learn SQL. I would think that a book or a web-based tutorial on SQL would be more conducive to your efforts. In the example you have given below, you would probably want to use LIKE. For example, SELECT * FROM test WHERE cat LIKE '%c%'; or similar ought to do it. Of course, I hope that the example is merely an example because if you really designed a production table like that then you wouldn't be taking advantage of the relational part of your relational database management system. So please keep learning SQL...it's a fantastic skill to have. If you have a specific SQL problem every once in a while there are those on this list who would undoubtedly enjoy helping out. Several beginner-level questions back-to-back, though, is way beyond the charter of this mailing list. The overall purpose of this particular mailing list is for discussions about PHP's ability to interface with databases. There may possibly be an SQL beginners mailing list on egroups or someplace similar...you might find an environment like that better than the PHP-DB list to help you with this stuff. Doug At 02:56 PM 7/16/01 -0400, McShen wrote: ok. I use set to make a table. here is my table 'test' +---+--+ | name | cat | +---+--+ | shen | a,c | | shen1 | b,c | +---+--+ How can I find all records that contain 'c'? i tried select * from test where cat='c'; ...snip... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] sql problem
A quick glance suggests to me that it is a nonstandard proprietary extension to SQL that provides a way to set a kind of a variable and use it in a subsequent nonstandard proprietary SQL-looking statement that is awfully procedural. You'll probably want to either consult the documentation for the RDBMS you use or ask your question on a mailing list tailored to users and/or developers of the RDBMS you're using for a definitive answer. I can verify for you that it's not standard SQL, though. And it looks to me like they've gone and made what appears to be an extension that extends SQL so it has some procedural capabilities. There are problems on many levels with using SQL as a procedural language. The most obvious problem with using nonstandard proprietary procedural extensions to SQL is that (for example) you couldn't change backend database without recoding all your nonstandard SQL-looking statements. But I suppose they can be helpful because you couldn't possibly do the same thing with PHP (or perl, or a C program, or...) and standard SQL. Oh, wait. You can do procedural things with de-facto standard and standard procedural languages? Well, I'm sure there's a reason to have nonstandard proprietary extensions that add procedural capabilities to SQL or they wouldn't have them. (Note the clever way I mentioned PHP, since this is a PHP mailing list and both the question and the answer have nothing to do with PHP. It still doesn't bring it on topic, but at least I tried.) Doug At 11:54 AM 6/26/01 +0800, Fai wrote: SELECT @A:=SUM(salary) FROM table1 WHERE type=1; UPDATE table2 SET summmary=@A WHERE type=1; What does @A: mean? Thank you very much! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Treelike data: adjacency list or nested sets?
I almost always use "adjacency lists" along with another table for the actual categorization of the info (in your case, published articles). I find the "nested sets" design limiting unless you have complete foreknowledge of your tree/categories when initially populating the table. If you have to modify the tree/categories later on, it can get hairy. Doug At 02:40 PM 4/20/01 +0200, Toms GarcY+0=a Ferrari wrote: Hello, I'm developing a system (with PHP-MySQL) in which I will have different articles published. Any given article can correspond to a category (or sub-category (or sub-sub-category)). Something like this: Cat 1 Sub 1.1 Sub-Sub 1.1.1 Sub-Sub 1.1.2 Sub 1.2 Sub 1.3 Cat 2 Sub 2.1 Sub 2.2 Sub-Sub 2.2.1 Sub-Sub 2.2.2 [etc] As per my research on this topic of publishing 'treelike information', there are two posibilities: a) Adjacency list id | parent | label 1 0 Cat 1 2 1 Sub 1.1 3 2 Sub 1.1.1 [so on...] b) Nested sets (as explained in the book JOE CELKO'S SQL FOR SMARTIES (Morgan-Kaufmann, 1999, second edition), that I don't have...) label | lft | rgt Cat 11 12 Sub 1.1 27 Sub 1.1.1 3 4 Sub 1.1.2 5 6 Sub 1.2 8 9 Sub 1.3 10 11 [so on...] Anybody is doing something like this that can share experience with us? I can not find a clue yet if one system is better than the other for what I need. I realized that the 'Nested Sets' system have a very good approach and is very easy to get all the sub (and sub-sub) categories on a given category (any record where lft is between lft and rgt: SELECT e1.* FROM example as e1, example as e2 WHERE e1.lft BETWEEN e2.lft AND e2.rgt AND e2.label = 'Cat 1'; ) But I'm having problems trying to find -as example- which are all the Categories (in the other system are all the records where parent = 0)... Any ideas? Regards, Tomas Garcia Ferrari Bigital http://bigital.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Concurrent update to database (PostgreSQL or MySQL) ??
As others have mentioned, this is a tricky thing to do. What others haven't mentioned is a way to do it. Let's say you just showed the update form to two users. It contains the fields that they are allowed to update and the values in those fields had been retreived from the database. Both users see a form like this: Today's High Temperature City: Detroit Temp (degrees F): 47 ( Submit ) The city field is not available for update (presumably the editor/user selected it off of a previous menu), and their task is to update today's high temperature for Detroit. One of the editors has information that the high temperature reached 49 degrees F, and the other editor has information that the high temperature has reached 50. (Perhaps one of the editors is overworked and hadn't gotten to enter the new high, or the temperature is changing very quickly.) So one of the people enter 50 and the other enters 49. Both hit submit. What needs to be done right at that moment to protect it from changing the value to 50 degrees (which is the correct, most recent, data) and then immediately changing the value to 49 degrees (which is now out of date)? Basically, you have to pass the original value to the script that is the ACTION of the HTML form. This way, you have the original value that may have been updated and the new value. The first thing the HTML form's ACTION script has to do is get the record from the database again. (Use SELECT ... FOR UPDATE if available, so the RDBMS might lock the row.) If the value you get from the SELECT is the same as the original value, go ahead and run the UPDATE to change the value to the new value. If not, then generate and display a screen telling the editor that the value has been updated by someone else...you can show the value and ask if they want to proceed with the update, but that's all up to you and/or your interface designers. This is all similar to how folks design old fashioned screen-oriented database systems (like with CICS). Good luck, Doug At 01:47 PM 4/18/01 +0200, Nicolas Guilhot wrote: Hi, How can I avoid two or more users to update the same record at the same time ? Ideally, I would like to lock the record when a user open it for modification. So if another user try to open the same record he'll be warned or get record values as read only. Is this possible and how to do it with PHP ?? How can I know that the user that has locked the record has finished with it, if he never commits his changes ? Is there an FAQ about this ? Regards, Nicolas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] php with mysql or interebase?
[In a deadpan voice...] Oh, what a fascinating twist. http://marc.theaimsgroup.com/?l=php-db is where this particular list is archived. That's where you can learn a lot about the individual programs, and you may find out little bits of wisdom like: each database has strengths and weaknesses, you really should pick the platform based upon your needs, even the best database will not help you if you start with a poorly designed schema. Doug At 02:33 PM 4/17/01 -0400, [EMAIL PROTECTED] wrote: I'm trying to decide whether to use interbase or mysql with php. Both are free and both have a php api. So with is better to use with php? Or does it matter? [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] SELECT query
Have you thought about normalizing your data model? It could make your task a lot easier. Doug At 11:33 PM 4/13/01 +0530, Sharmad Naik wrote: I have three table called table1, table2, table3 all having fields like: table1 contain id and username and id referencing table4 table2 contains id and parallel_username and id referencing table4 table3 contains id and other_username and id referencing table4 table4 is the main table containing id as primary key I want to develop a search engine which shows unique record after searching all the three table but shouldn't contain multiple answers for same SEARCH for username Pls help me, -Regards Sharmad -- The secret of the universe is @*!'^#+ NO CARRIER ___ _ _ _ |_|_||_||_||\/||_|| \ _|| || || \| || ||_/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Postgres auto increment.
Just off the top of my head...so please forgive any typos or blatant mistakes... CREATE SEQUENCE sequencename; CREATE TABLE mytable ( id int DEFAULT NEXTVAL('sequencename'), whatever varchar(32), PRIMARY KEY(id) ); Doug At 11:28 PM 4/13/01 -0600, John Starkey wrote: I've been using mysql too much lately. Can anyone tell me how to set up an auto increment in postgres? I need to select a row based on a user's menu selection. Requiring them to type in a text entry and get it right would obviously be pretty inefficient. Thanks, John -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Best way to check if a query succeeded
I see you there's been lots of responses already, but there's an important related bit of news folks might want to know. Everyone who uses the mysql_affected_rows() should know that a bug was fixed in 3.23.36 that evidentally reports affected rows incorrectly if MySQL was compiled without support for transactions. Go to http://www.mysql.com/documentation/mysql/bychapter/manual_News.html and scroll down to section F.2.2. It's the 8th item in the list. So shy away depending on mysql_affected_rows() for anything unless you're absolutely sure you're running at least 3.23.36 or have transaction support compiled in. Doug At 12:00 PM 3/29/01 +0100, Jordan Elver wrote: Hi, i was just wondering what you guys do to check if a wquery suceeded or not? I know about mysql_num_rows() and mysql_affected_rows(), just wondered what you guys do? I normally do something like: $sql = "SELECT something FROM table"; $result = mysql_query($sql); if(@mysql_num_rows($result) 0) { echo'Query Suceeded'; } else { echo'Query failed'; } Cheers, Jord -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] help with a parse error
You didn't mention if the parse error was coming from PHP or from MySQL. The PHP syntax looks okay to me at first glance (that is, a quick look through indicates that there appears to be appropriate numbers of semicolons and closing braces). So perhaps the thing issuing the parse error is MySQL? In that case, I'd hazard a guess that you don't have a table named products. Check the spelling, capitalization, whether it's the plural "products" or the singular "product." What helps me say this is that the INSERT statement above your line 52 inserts into a table called "JShistbau" and your SELECT statement appears to pull data from a table called "products." I'm not saying that that's necessarily wrong, because it could very well be perfectly valid. But without knowing more about your database layout, that's all I can think of. By the way, (and it shouldn't matter...) but have you also tried removing the space in the "end if;" (part of your larger if:-else:-endif; statement)? I personally don't use that alternative syntax, so I don't know if the space matters. Doug At 01:22 PM 3/29/01 +1000, Petra wrote: hi I just subsribed to this list with the hope you can help me. I am working on this code and I get a parse error in line 52 which is ... I been going through it over and over and can't find a glue. Has anyone out there a solution for me please? I am a beginner in PHP and like to hear about anything I need to know. Kindest Regards Petra [EMAIL PROTECTED] ? else: // Connect to the database server $dbcnx = @mysql_connect("localhost", "root", ""); if (!$dbcnx) { echo( "PUnable to connect to the " . "database server at this time./P" ); exit(); } //Select the products database if (! @mysql_select_db("JShistbau") ) { echo ( "PUnable to locate the Product " . "database at this time./P" ); exit(); } // If a Product has been submitted, // add it to the database. if ("SUBMIT" == $submitproduct) { $sql = "INSERT INTO JShistbau SET " . "cdescription='$productdescription', " . "cdateavailable=CURDATE()"; if (mysql_query($sql)) { echo("PYour Product has been added./P"); } else { echo("PError adding submitted product: " . mysql_error(). "/P"); } } echo("P Here are all the products in our database: /P:); // Request the text of all the products $result = mysql_query( "select * from products"); !this is line 52!! if (!$result) { echo("PError performing query: " . mysql_error() . "/P"); exit(); } // Display the text of each product in a paragraph while ( $row = mysql_fetch_array($result) ) { echo("P" . $row["cdescription"] . "/P"); } //When clicked, this link will load this page //with the product submission form displayed. echo("PAHREF='$PHP_SELF?addproduct=1'" . "Add a Product!/A/P"); end if; ? /BODY /HTML -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] help with a parse error
Gee...all I looked at were the semicolons and the braces (those are what I mess up on the most). I guess it's a good thing I mentioned the space in the endif! It turns out that if you use that syntax, you cannot have a space there. Doug At 01:19 PM 3/29/01 +0930, Timothy Aslat wrote: Petra wrote: I just subsribed to this list with the hope you can help me. We can try snip echo("P Here are all the products in our database: /P:); add a " before the ; here // Request the text of all the products $result = mysql_query( "select * from products"); !this is line 52!! Your problem is the previous line, you are missing a " on the end of it Cheers Tim -- | Disclaimer:| Timothy Aslat [EMAIL PROTECTED] | | The sender of this email is a figment | http://www.goodiesruleok.com | | of a deranged imagination and leaves it| Spyderweb Consulting | | to your own devices to decide whose... | P: 82270800M: 0401088479 | -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] simple sql question
There is no date that was before Jan 4th and on or after March 1st simultaneously--not even March 27th. Today might be a special day to individuals for varying reasons (birthdays, anniversaries, new jobs, promotions, whatever) but it's not THAT special that it simultaneously exists in two mutually exclusive sets of dates. http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#DAT ETIME How about "...WHERE startDate = '2001-03-01' AND startDate '2001-04-01'" to pull out all of the March events? Doug At 06:49 PM 3/27/01 -0600, Paulson, Joseph V. \"Jay\" wrote: Hello- I'm running MySQL and php and when I run the query below I don't get any return rows. As you can see I search for events that are happening between a certain date. The "startDate" field is type DATE in MySQL and the date in the database that should be returned in "2001-03-27" but I'm not getting any results. select * from events where startDate='2001-03-01' and startDate'2001-01-04' Any help on what I could be doing wrong would be great! Thanks, Jay Paulson Developer, Web Technologies Viatel, Inc. http://www.viatel.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] upperCase
Your personal dancing monkey says: strtoupper()http://www.php.net/manual/en/function.strtoupper.php RTFM. Doug At 06:01 PM 3/11/01 +0800, Hoo Kok Mun wrote: Hi, I am using mysql-3.22.32 with php4. I have a little problem with the uppercase. I wanted to display a user input field in CAPS. This is what I did and it did not work. $userfield = upper('$userfield'); echo "User Field - $userfield"; Errors (tried both ucase and upper) Call to undefined function: upper() Call to undefined function: ucase() Really appreciate any help that I can get. *** "Don't be afraid to ask dumb questions, they are a lot easier to handle than dumb mistakes." Email : [EMAIL PROTECTED] Home Page : http://www.familyhoo.net *** -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] case insensitive search
You could use the UPPER function. Fortunately you're using PostgreSQL, which conforms with much of the ANSI standard. UPPER and LOWER are implementations of the fold functions required by ANSI SQL. This would be the most standard way to solve your problem (with the notable exception of support for this on MySQL, don't get me started on how brain dead MySQL is about string comparisons...though it is a tiny little bit better with its glaringly non-standard BINARY keyword). You could alternatively use the much older ~* syntax that PostgreSQL inherited from its ancestors. But that's completely non-standard, and there's only one reason to use it since PostgreSQL has the UPPER function and a LIKE predicate that very closely conforms to the ANSI SQL standard. That reason is if you want to use regex-like pattern specifiers instead of SQL-like pattern specifiers. If you're running a brand-spanking-new 7.1 (beta), you could use the popular (but non-standard, as far as I can tell--at least I couldn't find any mention of it in ANSI SQL '92 and I haven't looked at '99 yet) ILIKE. (Actually, '92 gives ILIKE reserved word status, but does not specify anything else for it.) To sum it up, try these: ... WHERE UPPER(blah) LIKE UPPER('%blah%') ... WHERE blah ~* '*blah*' (Note the regex-like pattern specifiers) ... WHERE blah ILIKE '%blah%' (Only on the next version) Doug At 06:36 PM 2/10/01 +1000, Cameron wrote: im trying to do a case insensitive search in pgsql with a "WHERE blah LIKE '%blah%'" the problem is that currently if something contains Blah not just blah it wont return that. suggestion? i know i can suck out every row and then eregi them but that is majorly slow and inefficent . . . Cameron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]