[PHP-DB] Creating Directory Search Engine
Hi All, I am trying to build a search engine for a directory. So far I have setup a table of keywords [ id | category_id | keyword ] with a single keyword and the category that it refers to. Then I have a table of categories [ cat_id | parent_id | cat_name ] and a table of vendors linked to the corresponding category_id. Basically the trouble arises when searching for multiple keywords because there is only one word in each record. I am trying to do this in a single query, but it seems that there must be a better way. For example TABLE keywords [ id | category_id | keyword ] ex. records 1 | 10 | auto 2 | 10 | car 3 | 10 | repair 4 | 20 | auto 5 | 20 | car 6 | 20 | new 7 | 20 | sales These keywords refer to the categories 'auto repair' (cat_id = 10) and 'new auto sales' (cat_id = 20) So a search for 'auto' should return vendors in both categories while a search for 'auto repair' should return just category 10 Make sense? Please let me know of a good strategy for this - I imagine that it is quite common. Thanks much, olinux __ Do You Yahoo!? Send FREE Valentine eCards with Yahoo! Greetings! http://greetings.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] multiple entries in database
I have worked my problem down to the mysql database. I have a table like so: Field Type Attributes Null Default Extra username varchar(16) No commID int(9) No auto_increment commState char(2) No commCity varchar(25) No commZip int(5) No 0 commName varchar(255) No commID is primaryKey. when I do an insert to this table without giving the ID a value inside the insert statement it duplicates the entry or increments another blank entry. the insert statement is not in a loop or recursive function. I have found out that if I take out the auto_increment that it adds it just fine if the ID value is added to the statement..without the ID value it enters the ID as '0'. I have another insert statement with another table that is doing the exact same thing. I'm kinda new and kinda not..so..any help is appreciated.. Justin Hall JD Media www.jdmedia.net [EMAIL PROTECTED]
Re: [PHP-DB] Session management
On 7 Feb 2002, at 18:36, Danny Kelly wrote: > Hello, > I am trying to set up a session management system for my site. Check > out my site (under development) > http://www.planttel.com/newsite2/home.php I have a user auth system > installed already. What I want is when a customer clicks on log in > that it will prompt them for a user name and password (which I have > established) with a check box that says "Remember my password" So when > the user comes to the site they will already be logged.. Can some one > shed some lite on that for me.. A TOTAL NEWBIE!!! You should read the following. The example code is in Perl but the concepts are the same: > Basic Cookie Management http://www.stonehenge.com/merlyn/WebTechniques/col61.html Randal really slams bad cookie management. Me, I don't like using cookies at all anyhow. I like putting it in the url. Perl has more than a few CPAN modules to handle this. But it would be a lot of work to re-write any of those in PHP. I'm pretty much a PHP newbie myself. I often look here for "classes": http://phpclasses.upperdesign.com/ And here are some for session management: http://phpclasses.upperdesign.com/browse.html/class/21/ I just recently put Sessionara on a site I'm developing but the docs are skimply and it didn't work for me out of the box as I would have liked. But you might want to look at it. One thing is that it uses global and I HATE using global. This does not use cookies. I think you want a system that uses cookies. Try phpbuilder.net http://phpbuilder.net/search/?sort=Score&method=and&config=forum&restri ct=&exclude=&words=sessions Lots of stuff there. They probably have an article. Peter --- "Reality is that which, when you stop believing in it, doesn't go away". -- Philip K. Dick -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] substr() Split record into seaprate pages
Does anyone know how to limit a long record, like a news article that has 5 > pages? > I want to limit it so it displays the first page then at the bottom it > prints: > > <<1 2 3 4 5 6 7>> > > then when you click 2 or the right arrow it displays the second page of > the record? I have been trying to use the following script but I can't get it to work: echo(substr($article, ($i - 1) * $pagesize, $pagesize); for ($i = 1; $i < strlen($article) / $pagesize; $i++) echo(""); > > Thanks > > --Will
[PHP-DB] Re: File deletion
ammendment: use the unlink() function once you have confirmation of a successful update :) HTH Joe :) Todd Williamsen <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I created a couple of forms where one inserts new contact data with a file, > in this case its a resume. Now, I want to create a form where a user can > update the information by inserting their updated information and if there > is a new resume then it would be uploaded. > > I got the upload part down, but i would like to delete the old resume when > the update is done, only if there is an update done to the resume. This > more for file management than anything. > > I am sure this is possible, but I thought I would ask all you PHP experts > first since I am a semi-newbie at this... > > thanks! > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: File deletion
Try looking at the unlink() function. It removes files off of the web server. HTH Joe :) Todd Williamsen <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I created a couple of forms where one inserts new contact data with a file, > in this case its a resume. Now, I want to create a form where a user can > update the information by inserting their updated information and if there > is a new resume then it would be uploaded. > > I got the upload part down, but i would like to delete the old resume when > the update is done, only if there is an update done to the resume. This > more for file management than anything. > > I am sure this is possible, but I thought I would ask all you PHP experts > first since I am a semi-newbie at this... > > thanks! > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Need to delete charcters from a string
Why couldn't you use something like this: $mystr = substr($mystr, -3); Joe Jeroen Timmers <[EMAIL PROTECTED]> wrote in message 003001c1b026$97373cb0$7f6440d4@jeroen">news:003001c1b026$97373cb0$7f6440d4@jeroen... > you can take the function substr from php in combination with strlen (lenght > of a string) > > example > > $string = "1234567890"; > $rest = substr($string, 0, strlen($string)-3); // returns "1234567" > > Success Jeroen Timmers > > > - Original Message - > From: "Renaldo De Silva" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Thursday, February 07, 2002 8:56 PM > Subject: [PHP-DB] Need to delete charcters from a string > > > > I need to delete the last 3 character of a string, what command can i use > o > > do this. > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: duplicate entries in db
Hi. Post up some code so the ng can help you out. :) Justin Hall <[EMAIL PROTECTED]> wrote in message 01c1b015$54445250$fdd80918@CT41311A">news:01c1b015$54445250$fdd80918@CT41311A... > I have a script that calls a function to perform a query using the > arguments sent to the function via http form processing. > > I get two entries into the MySQL database for one query. > > I only want one entry. > > Can someone point me in the right direction? > > Thanks in advance. > > Justin Hall > JD Media > www.jdmedia.net > [EMAIL PROTECTED] > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Resource link errors
Hi Ken, The %s is a method of formatting a string. Why not try echo or print command instead? As for the other problem on line 26, the mysql_query returns a resource id # (an integer). You'll have to use that number in your loop to retrieve the results after. Here's an example: $connectionid = msql_connect("mydatabaseserver") or die("unable to connect!"); msql_select_db("db", $connectionid) or die("unable to select records from the db!"); $result = msql_query("SELECT * FROM table WHERE someid=$my_id_variable", $connectionid); //if the query fails if (!$result) { die("problemo: Your query failed"); } //now loop through the rows :) while ($row = msql_fetch_array($result)) { echo $row["0"]; } Hope this helps you out :) Joe :) Ken Thompson <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... > Hello all, > I'm very new to php and have been beating my head on the wall over this for 2 > days. I've searched through the php documentation but I guess I either don't > know where or what to look for or don't understand what I'm seeing. > I think this has to be an array but the original doesn't seem to think > so.(see below) > I've tried ($myrow = mysql_fetch_array($result)) and still get the same > errors. > The original that I used as an example works OK showing the results of Name, > Position. They didn't include a data cell for $myrow[3] ... > = > THIS WORKS: > > $title = "Welcome to the Web-Site of"; /*I commented this out and finaly > removed it cuz I don't want the title echoed in the final page.*/ > > include("header.inc"); > > $result = mysql_query("SELECT * FROM employees",$db); > > echo "\n"; > > echo "NamePosition\n"; > > while ($myrow = mysql_fetch_row($result)) { > > echo("%s %s%s\n", $myrow[1], $myrow[2], > $myrow[3]); > > } > > echo "\n"; > include("footer.inc"); > > ?> > === > What I am trying to do is to return the results of the query into a table > with these items: > +---+-+--+-+-++ > | Field | Type| Null | Key | Default | Extra | > +---+-+--+-+-++ > | id| tinyint(4) | | PRI | NULL| auto_increment | > | year | int(4) | YES | | NULL|| > | make | varchar(20) | YES | | NULL|| > | model | varchar(20) | YES | | NULL|| > | engine| varchar(20) | YES | | NULL|| > | fuel | varchar(8) | YES | | NULL|| > | trans | varchar(10) | YES | | NULL|| > | condition | varchar(20) | YES | | NULL|| > | price | varchar(10) | YES | | 0 || > | location | varchar(20) | YES | | NULL|| > +---+-+--+-+-++ > These are the errors that show up when I run the page in the browser. > The database is local and I'm on Linux-Mandrake 8.1 using Apache web server. > I can get the results I want from the command line, that is I can make > queries and get the proper info returned. > what have I done to cause it not to work? > > > Warning: Supplied argument is not a valid MySQL-Link > resource in /var/www/html/list.php3 on line 26 > > Warning: Supplied argument is not a valid MySQL result > resource in /var/www/html/list.php3 on line 32 > > THIS DOESN'T: > I get the table and the item name e.g. Year, Make etc. > Once I get the 3 cells returning the proper info, I want to add the rest of > the cells needed to display all the info in the web page. I don't think it > should be a problem, comments on this? > > > include("header.inc"); > > //(Line 26 below, everything above " $result = mysql_query("SELECT * FROM autos",$db); > > echo "\n"; > > echo "YearMakeModel\n"; > > //(Line 32 below) > while ($myrow = mysql_fetch_row($result)) { > > //What does the '%s' mean? I read it someplace in the tutorial > //but can't find it now. > > printf("%s %s%s\n", $myrow[1], $myrow[2], > $myrow[3]); > > } > > echo "\n"; > include("footer.inc"); > > ?> > -- > > Ken Thompson, North West Antique Autos > Payette, Idaho > Email: [EMAIL PROTECTED] > http://www.nwaa.com > Sales and brokering of antique autos and parts. > > Linux- Coming Soon To A Desktop Near You > Registered Linux User #183936 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] addslashes()
Hi. addslashes() going in to db, stripslashes() coming out :) HTH Joe :) Todd Williamsen <[EMAIL PROTECTED]> wrote in message 002601c1b033$382a4700$f6b2d83f@goofy1">news:002601c1b033$382a4700$f6b2d83f@goofy1... > Paul, > > It is being inserted into a database > > -Original Message- > From: Paul DuBois [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 07, 2002 5:41 PM > To: Todd Williamsen; [EMAIL PROTECTED] > Subject: Re: [PHP-DB] addslashes() > > > At 16:54 -0600 2/7/02, Todd Williamsen wrote: > >Ok.. > > > >i tried it out... and it almost works like I want it... weird though > > > >1. when I put in this is BLUE > > > >it prints it in like a bright green. but if i use the RGB # then its > fine. > >weird > > > >2. if there is an apostrophe in the notes, then it will add slashes it > to > >that as well > > > >so if I type blah blah blah I am going over to my friend's website > later on > >and here is the address... > > > >http://friends.com>Friends > > > >it will look like > > > >friend\\\'s > > > >Friends(link) > > addslashes() is for escaping values that you're going to insert into a > database. > > If you're generating HTML, use htmlspecialchars() instead. > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Session management
Hi Danny, you could use a cookie to store the user's username and password once they first successfully login the first time or even better upon signing up to your site. Then, on the login page(or whatever page is displayed prompting a login) you could check for the cookie at the top and redirect them to the appropriate page. If they don't have the cookie, prompt for a login action. Hope this helps, Joe :) Danny Kelly <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hello, > I am trying to set up a session management system for my site. Check out > my site (under development) http://www.planttel.com/newsite2/home.php > I have a user auth system installed already. What I want is when a > customer clicks on log in that it will prompt them for a user name and > password (which I have established) with a check box that says "Remember > my password" So when the user comes to the site they will already be > logged.. Can some one shed some lite on that for me.. A TOTAL NEWBIE!!! > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] addslashes()
Paul, It is being inserted into a database -Original Message- From: Paul DuBois [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 5:41 PM To: Todd Williamsen; [EMAIL PROTECTED] Subject: Re: [PHP-DB] addslashes() At 16:54 -0600 2/7/02, Todd Williamsen wrote: >Ok.. > >i tried it out... and it almost works like I want it... weird though > >1. when I put in this is BLUE > >it prints it in like a bright green. but if i use the RGB # then its fine. >weird > >2. if there is an apostrophe in the notes, then it will add slashes it to >that as well > >so if I type blah blah blah I am going over to my friend's website later on >and here is the address... > >http://friends.com>Friends > >it will look like > >friend\\\'s > >Friends(link) addslashes() is for escaping values that you're going to insert into a database. If you're generating HTML, use htmlspecialchars() instead. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] addslashes()
At 16:54 -0600 2/7/02, Todd Williamsen wrote: >Ok.. > >i tried it out... and it almost works like I want it... weird though > >1. when I put in this is BLUE > >it prints it in like a bright green. but if i use the RGB # then its fine. >weird > >2. if there is an apostrophe in the notes, then it will add slashes it to >that as well > >so if I type blah blah blah I am going over to my friend's website later on >and here is the address... > >http://friends.com>Friends > >it will look like > >friend\\\'s > >Friends(link) addslashes() is for escaping values that you're going to insert into a database. If you're generating HTML, use htmlspecialchars() instead. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] addslashes()
Ahha, i see. Hmm well you can make your own addslashes function like this. Add the following line at the beginning of the php code function superaddslashes($input) { return ereg_replace ('"', '\"', $input); } Then you can do $Notes = superaddslashes($Notes); - Original Message - From: "Todd Williamsen" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, February 07, 2002 11:54 PM Subject: Re: [PHP-DB] addslashes() > Ok.. > > i tried it out... and it almost works like I want it... weird though > > 1. when I put in this is BLUE > > it prints it in like a bright green. but if i use the RGB # then its fine. > weird > > 2. if there is an apostrophe in the notes, then it will add slashes it to > that as well > > so if I type blah blah blah I am going over to my friend's website later on > and here is the address... > > http://friends.com>Friends > > it will look like > > friend\\\'s > > Friends(link) > > . > "Acealex" <[EMAIL PROTECTED]> wrote in message > 002001c1b027$ec33b7b0$e4d22fc2@acealex">news:002001c1b027$ec33b7b0$e4d22fc2@acealex... > > Try > > $Notes = addslashes($Notes); > > > > You where almost right :) > > > > /Alexander > > > > - Original Message - > > From: "Todd Williamsen" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Thursday, February 07, 2002 11:32 PM > > Subject: [PHP-DB] addslashes() > > > > > > > I have a "Notes" field where users can add notes. Now, there will be > > times > > > when they use quotes "" or maybe even HTML, what is the correct way of > > using > > > this function? > > > > > > I have tried: > > > > > > addslashes($Notes); > > > > > > and > > > > > > $Notes addslashes($Notes); > > > > > > neither work.. > > > > > > I thought I would ask this great newsgroup! > > > > > > Thanks > > > > > > > > > > > > -- > > > PHP Database Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Session management
Hello, I am trying to set up a session management system for my site. Check out my site (under development) http://www.planttel.com/newsite2/home.php I have a user auth system installed already. What I want is when a customer clicks on log in that it will prompt them for a user name and password (which I have established) with a check box that says "Remember my password" So when the user comes to the site they will already be logged.. Can some one shed some lite on that for me.. A TOTAL NEWBIE!!! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] addslashes()
Ok.. i tried it out... and it almost works like I want it... weird though 1. when I put in this is BLUE it prints it in like a bright green. but if i use the RGB # then its fine. weird 2. if there is an apostrophe in the notes, then it will add slashes it to that as well so if I type blah blah blah I am going over to my friend's website later on and here is the address... http://friends.com>Friends it will look like friend\\\'s Friends(link) . "Acealex" <[EMAIL PROTECTED]> wrote in message 002001c1b027$ec33b7b0$e4d22fc2@acealex">news:002001c1b027$ec33b7b0$e4d22fc2@acealex... > Try > $Notes = addslashes($Notes); > > You where almost right :) > > /Alexander > > - Original Message - > From: "Todd Williamsen" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, February 07, 2002 11:32 PM > Subject: [PHP-DB] addslashes() > > > > I have a "Notes" field where users can add notes. Now, there will be > times > > when they use quotes "" or maybe even HTML, what is the correct way of > using > > this function? > > > > I have tried: > > > > addslashes($Notes); > > > > and > > > > $Notes addslashes($Notes); > > > > neither work.. > > > > I thought I would ask this great newsgroup! > > > > Thanks > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] addslashes()
Try $Notes = addslashes($Notes); You where almost right :) /Alexander - Original Message - From: "Todd Williamsen" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, February 07, 2002 11:32 PM Subject: [PHP-DB] addslashes() > I have a "Notes" field where users can add notes. Now, there will be times > when they use quotes "" or maybe even HTML, what is the correct way of using > this function? > > I have tried: > > addslashes($Notes); > > and > > $Notes addslashes($Notes); > > neither work.. > > I thought I would ask this great newsgroup! > > Thanks > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] addslashes()
I have a "Notes" field where users can add notes. Now, there will be times when they use quotes "" or maybe even HTML, what is the correct way of using this function? I have tried: addslashes($Notes); and $Notes addslashes($Notes); neither work.. I thought I would ask this great newsgroup! Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Need to delete charcters from a string
you can take the function substr from php in combination with strlen (lenght of a string) example $string = "1234567890"; $rest = substr($string, 0, strlen($string)-3); // returns "1234567" Success Jeroen Timmers - Original Message - From: "Renaldo De Silva" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, February 07, 2002 8:56 PM Subject: [PHP-DB] Need to delete charcters from a string > I need to delete the last 3 character of a string, what command can i use o > do this. > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Query with numbers like 1, 3, 5..........
Thank's a lot guys for helping me out here! Now I can sleep well to night ; ) "Mike Gohlke" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > $qry = mysql_query("select * from tablename order by id"); > while ( $ref1 = mysql_fetch_object($qry) ) { > $ref2 = mysql_fetch_object($qry) > ?>$ref1->id $ref2->id } > ?> > > > btw, the is to keep the internal cell borders from not appearing > using netscape. (keeps it from being empty). > > Hope this helps > Mike... > > Raymond Lilleodegard wrote: > > >Hi again Rick! : ) > > > >It is because I am trying to list all products that I have in a database > >into a "menu page". And I would like to have two products beside eachothers. > >So... is it possible to get two datarows in one: > > > >do { > > > >} while (mysql_fetch_array() ); > > > >?? or is this a stupid way to do it? > > > >Reagrds Raymond > >- Original Message - > >From: "Rick Emery" <[EMAIL PROTECTED]> > >To: "'Raymond Lilleodegard'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > >Sent: Thursday, February 07, 2002 8:55 PM > >Subject: RE: [PHP-DB] Query with numbers like 1, 3, 5.. > > > > > >>Yes, but the question is why? > >> > >>-Original Message- > >>From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] > >>Sent: Thursday, February 07, 2002 1:22 PM > >>To: [EMAIL PROTECTED] > >>Subject: [PHP-DB] Query with numbers like 1, 3, 5.. > >> > >> > >>Hi! > >> > >>Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, > >> > >6, > > > >>...? > >> > >> > >>Best regards Raymond > >> > >> > >> > >>-- > >>PHP Database Mailing List (http://www.php.net/) > >>To unsubscribe, visit: http://www.php.net/unsub.php > >> > >> > >"Rick Emery" <[EMAIL PROTECTED]> wrote in message > >[EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > >>Yes, but the question is why? > >> > >>-Original Message- > >>From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] > >>Sent: Thursday, February 07, 2002 1:22 PM > >>To: [EMAIL PROTECTED] > >>Subject: [PHP-DB] Query with numbers like 1, 3, 5.. > >> > >> > >>Hi! > >> > >>Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, > >> > >6, > > > >>...? > >> > >> > >>Best regards Raymond > >> > >> > >> > >>-- > >>PHP Database Mailing List (http://www.php.net/) > >>To unsubscribe, visit: http://www.php.net/unsub.php > >> > > > > > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Resource link errors
The following means you have not opened a link to your database. Concerntrate your efforts there. Warning: Supplied argument is not a valid MySQL-Link resource in /var/www/html/list.php3 on line 26 -Original Message- From: Ken Thompson [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 3:23 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Resource link errors Hello all, I'm very new to php and have been beating my head on the wall over this for 2 days. I've searched through the php documentation but I guess I either don't know where or what to look for or don't understand what I'm seeing. I think this has to be an array but the original doesn't seem to think so.(see below) I've tried ($myrow = mysql_fetch_array($result)) and still get the same errors. The original that I used as an example works OK showing the results of Name, Position. They didn't include a data cell for $myrow[3] ... = THIS WORKS: \n"; echo "NamePosition\n"; while ($myrow = mysql_fetch_row($result)) { echo("%s %s%s\n", $myrow[1], $myrow[2], $myrow[3]); } echo "\n"; include("footer.inc"); ?> === What I am trying to do is to return the results of the query into a table with these items: +---+-+--+-+-++ | Field | Type| Null | Key | Default | Extra | +---+-+--+-+-++ | id| tinyint(4) | | PRI | NULL| auto_increment | | year | int(4) | YES | | NULL|| | make | varchar(20) | YES | | NULL|| | model | varchar(20) | YES | | NULL|| | engine| varchar(20) | YES | | NULL|| | fuel | varchar(8) | YES | | NULL|| | trans | varchar(10) | YES | | NULL|| | condition | varchar(20) | YES | | NULL|| | price | varchar(10) | YES | | 0 || | location | varchar(20) | YES | | NULL|| +---+-+--+-+-++ These are the errors that show up when I run the page in the browser. The database is local and I'm on Linux-Mandrake 8.1 using Apache web server. I can get the results I want from the command line, that is I can make queries and get the proper info returned. what have I done to cause it not to work? Warning: Supplied argument is not a valid MySQL-Link resource in /var/www/html/list.php3 on line 26 Warning: Supplied argument is not a valid MySQL result resource in /var/www/html/list.php3 on line 32 THIS DOESN'T: I get the table and the item name e.g. Year, Make etc. Once I get the 3 cells returning the proper info, I want to add the rest of the cells needed to display all the info in the web page. I don't think it should be a problem, comments on this? \n"; echo "YearMakeModel\n"; //(Line 32 below) while ($myrow = mysql_fetch_row($result)) { //What does the '%s' mean? I read it someplace in the tutorial //but can't find it now. printf("%s %s%s\n", $myrow[1], $myrow[2], $myrow[3]); } echo "\n"; include("footer.inc"); ?> -- Ken Thompson, North West Antique Autos Payette, Idaho Email: [EMAIL PROTECTED] http://www.nwaa.com Sales and brokering of antique autos and parts. Linux- Coming Soon To A Desktop Near You Registered Linux User #183936 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Query with numbers like 1, 3, 5..........
I like Mike's WHILE-loop better than my solution. thanks, Mike -Original Message- From: Mike Gohlke [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 3:56 PM To: Raymond Lilleodegard; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Query with numbers like 1, 3, 5.. $ref1->id $ref2->id btw, the is to keep the internal cell borders from not appearing using netscape. (keeps it from being empty). Hope this helps Mike... Raymond Lilleodegard wrote: >Hi again Rick! : ) > >It is because I am trying to list all products that I have in a database >into a "menu page". And I would like to have two products beside eachothers. >So... is it possible to get two datarows in one: > >do { > >} while (mysql_fetch_array() ); > >?? or is this a stupid way to do it? > >Reagrds Raymond >- Original Message - >From: "Rick Emery" <[EMAIL PROTECTED]> >To: "'Raymond Lilleodegard'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> >Sent: Thursday, February 07, 2002 8:55 PM >Subject: RE: [PHP-DB] Query with numbers like 1, 3, 5.. > > >>Yes, but the question is why? >> >>-Original Message- >>From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] >>Sent: Thursday, February 07, 2002 1:22 PM >>To: [EMAIL PROTECTED] >>Subject: [PHP-DB] Query with numbers like 1, 3, 5.. >> >> >>Hi! >> >>Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, >> >6, > >>...? >> >> >>Best regards Raymond >> >> >> >>-- >>PHP Database Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php >> >> >"Rick Emery" <[EMAIL PROTECTED]> wrote in message >[EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > >>Yes, but the question is why? >> >>-Original Message- >>From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] >>Sent: Thursday, February 07, 2002 1:22 PM >>To: [EMAIL PROTECTED] >>Subject: [PHP-DB] Query with numbers like 1, 3, 5.. >> >> >>Hi! >> >>Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, >> >6, > >>...? >> >> >>Best regards Raymond >> >> >> >>-- >>PHP Database Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php >> > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Query with numbers like 1, 3, 5..........
$ref1->id $ref2->id btw, the is to keep the internal cell borders from not appearing using netscape. (keeps it from being empty). Hope this helps Mike... Raymond Lilleodegard wrote: >Hi again Rick! : ) > >It is because I am trying to list all products that I have in a database >into a "menu page". And I would like to have two products beside eachothers. >So... is it possible to get two datarows in one: > >do { > >} while (mysql_fetch_array() ); > >?? or is this a stupid way to do it? > >Reagrds Raymond >- Original Message - >From: "Rick Emery" <[EMAIL PROTECTED]> >To: "'Raymond Lilleodegard'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> >Sent: Thursday, February 07, 2002 8:55 PM >Subject: RE: [PHP-DB] Query with numbers like 1, 3, 5.. > > >>Yes, but the question is why? >> >>-Original Message- >>From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] >>Sent: Thursday, February 07, 2002 1:22 PM >>To: [EMAIL PROTECTED] >>Subject: [PHP-DB] Query with numbers like 1, 3, 5.. >> >> >>Hi! >> >>Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, >> >6, > >>...? >> >> >>Best regards Raymond >> >> >> >>-- >>PHP Database Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php >> >> >"Rick Emery" <[EMAIL PROTECTED]> wrote in message >[EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > >>Yes, but the question is why? >> >>-Original Message- >>From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] >>Sent: Thursday, February 07, 2002 1:22 PM >>To: [EMAIL PROTECTED] >>Subject: [PHP-DB] Query with numbers like 1, 3, 5.. >> >> >>Hi! >> >>Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, >> >6, > >>...? >> >> >>Best regards Raymond >> >> >> >>-- >>PHP Database Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php >> > > >
RE: [PHP-DB] Query with numbers like 1, 3, 5..........
I think you're on the right path. It sounds like what you REALLY want is two equal length columns of products. In that case, instead of 1,3,5,7,... which will become upset when you add and delete products; use mysql_num_rows($result). That is: $query="SELECT * FROM products WHERE "; $result = mysql_query($query) or die(mysql_error()); $numrows = mysql_num_rows($result); $length = floor($numrows/2); if( mod($numrows,2)==1) $numrows++; for( $i=0; $i<$numrows; $i++ ) { $rowLeft = mysql_fetch_array($result); $rowRight = mysql_fetch_array($result); ... print your data side-by-side ... } NOTE: you'll have to format for the situation where there are more left-side rows than right-side; that is, there ae an odd number of products to be displayed. -Original Message- From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 3:37 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Query with numbers like 1, 3, 5.. Hi again Rick! : ) It is because I am trying to list all products that I have in a database into a "menu page". And I would like to have two products beside eachothers. So... is it possible to get two datarows in one: do { } while (mysql_fetch_array() ); ?? or is this a stupid way to do it? Reagrds Raymond - Original Message - From: "Rick Emery" <[EMAIL PROTECTED]> To: "'Raymond Lilleodegard'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, February 07, 2002 8:55 PM Subject: RE: [PHP-DB] Query with numbers like 1, 3, 5.. > Yes, but the question is why? > > -Original Message- > From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 07, 2002 1:22 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Query with numbers like 1, 3, 5.. > > > Hi! > > Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, > ...? > > > Best regards Raymond > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > "Rick Emery" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Yes, but the question is why? > > -Original Message- > From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 07, 2002 1:22 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Query with numbers like 1, 3, 5.. > > > Hi! > > Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, > ...? > > > Best regards Raymond > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Query with numbers like 1, 3, 5..........
Hi again Rick! : ) It is because I am trying to list all products that I have in a database into a "menu page". And I would like to have two products beside eachothers. So... is it possible to get two datarows in one: do { } while (mysql_fetch_array() ); ?? or is this a stupid way to do it? Reagrds Raymond - Original Message - From: "Rick Emery" <[EMAIL PROTECTED]> To: "'Raymond Lilleodegard'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, February 07, 2002 8:55 PM Subject: RE: [PHP-DB] Query with numbers like 1, 3, 5.. > Yes, but the question is why? > > -Original Message- > From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 07, 2002 1:22 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Query with numbers like 1, 3, 5.. > > > Hi! > > Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, > ...? > > > Best regards Raymond > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > "Rick Emery" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Yes, but the question is why? > > -Original Message- > From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 07, 2002 1:22 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Query with numbers like 1, 3, 5.. > > > Hi! > > Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, > ...? > > > Best regards Raymond > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Resource link errors
Hello all, I'm very new to php and have been beating my head on the wall over this for 2 days. I've searched through the php documentation but I guess I either don't know where or what to look for or don't understand what I'm seeing. I think this has to be an array but the original doesn't seem to think so.(see below) I've tried ($myrow = mysql_fetch_array($result)) and still get the same errors. The original that I used as an example works OK showing the results of Name, Position. They didn't include a data cell for $myrow[3] ... = THIS WORKS: \n"; echo "NamePosition\n"; while ($myrow = mysql_fetch_row($result)) { echo("%s %s%s\n", $myrow[1], $myrow[2], $myrow[3]); } echo "\n"; include("footer.inc"); ?> === What I am trying to do is to return the results of the query into a table with these items: +---+-+--+-+-++ | Field | Type| Null | Key | Default | Extra | +---+-+--+-+-++ | id| tinyint(4) | | PRI | NULL| auto_increment | | year | int(4) | YES | | NULL|| | make | varchar(20) | YES | | NULL|| | model | varchar(20) | YES | | NULL|| | engine| varchar(20) | YES | | NULL|| | fuel | varchar(8) | YES | | NULL|| | trans | varchar(10) | YES | | NULL|| | condition | varchar(20) | YES | | NULL|| | price | varchar(10) | YES | | 0 || | location | varchar(20) | YES | | NULL|| +---+-+--+-+-++ These are the errors that show up when I run the page in the browser. The database is local and I'm on Linux-Mandrake 8.1 using Apache web server. I can get the results I want from the command line, that is I can make queries and get the proper info returned. what have I done to cause it not to work? Warning: Supplied argument is not a valid MySQL-Link resource in /var/www/html/list.php3 on line 26 Warning: Supplied argument is not a valid MySQL result resource in /var/www/html/list.php3 on line 32 THIS DOESN'T: I get the table and the item name e.g. Year, Make etc. Once I get the 3 cells returning the proper info, I want to add the rest of the cells needed to display all the info in the web page. I don't think it should be a problem, comments on this? \n"; echo "YearMakeModel\n"; //(Line 32 below) while ($myrow = mysql_fetch_row($result)) { //What does the '%s' mean? I read it someplace in the tutorial //but can't find it now. printf("%s %s%s\n", $myrow[1], $myrow[2], $myrow[3]); } echo "\n"; include("footer.inc"); ?> -- Ken Thompson, North West Antique Autos Payette, Idaho Email: [EMAIL PROTECTED] http://www.nwaa.com Sales and brokering of antique autos and parts. Linux- Coming Soon To A Desktop Near You Registered Linux User #183936 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] SSL - PAGE CANNOT BE DISPLAYED
Hi all. I have the following configuration: I'm running a Cobalt RAQ4i with Linux Apache Web Server PHP Version 4.0.3pl1 We have an application which is used via ssl. There are occassions when a user presses on a submit button to post information to a database. The script itself is fine, there is no problem with the php scripts at all. The problem comes in, and I've seen this at other websites while using ssl, that sometime, when they click on the submit button the error message: "Page Cannot Be Displayed" comes up. If the user hits the Refresh button, the page is displayed just fine. Again, this doesn't always happen at the same place. Some users experience it more often than others. And ONLY Internet Explorer users get this message. It never happens with Netscape. I had hear somewhere an issue like this with SSL/Apache/PHP combination, but am not aware of the solution. Can anyone enlighten me or have any ideas? Thanks in Advance, Jeffrey Cleary -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] duplicate entries in db
Ya haven't given us much to go on. So... SELECT DISTINCT * FROM mytable WHERE ; -Original Message- From: Justin Hall [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 2:24 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] duplicate entries in db I have a script that calls a function to perform a query using the arguments sent to the function via http form processing. I get two entries into the MySQL database for one query. I only want one entry. Can someone point me in the right direction? Thanks in advance. Justin Hall JD Media www.jdmedia.net [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Need to delete charcters from a string
$str = substr($str,0,-3); -Original Message- From: Renaldo De Silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 1:57 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [PHP-DB] Need to delete charcters from a string I need to delete the last 3 character of a string, what command can i use o do this. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Can't get left join to work
And the answer is: mysql> select e.id,fname,sum(m.miles) from employees e -> left join mileage m on m.id=e.id && month(trip_date)=3 -> && substring(year(m.trip_date),3,2) = '02' -> group by e.id; yeilds: +---++--+ | id| fname | sum(m.miles) | +---++--+ | 021021021 | Sam| 0.00 | | 121212121 | George | 0.00 | | 121212122 | George C. | 0.00 | | 121212123 | George | 0.00 | | 123123124 | Jake | 0.00 | | 123412342 | Paul | 0.00 | | 138501999 | Sherman| 0.00 | | 2 | Sam| 0.00 | | 3 | Fred Robert| 0.00 | | 4 | Paul | 0.00 | | 893458009 | Joan H | 0.00 | | 6902D | Ian| 1372.00 | | ABCABCABC | Ian|80.00 | | B | Bob| 0.00 | | Q | Joan Billy Bob | 7.00 | +---++--+ 15 rows in set (0.00 sec) -Original Message- From: paul wilczynski [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 1:26 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Can't get left join to work Here are the 2 tables and selected columns from each. Note there are only 4 employees who have trips (3 of those employees active, 1 inactive). If I do the following select, I only get 4 rows returned (or 3 if I say 'where active = 'A'). In addition to those, I want 1 row returned for each of the employees with 0 miles if there are no rows in the 'mileage' table for them. To put it another way, I always want the number of rows returned to be equal to the number of employees rows whose active_sw = 'A'. select e.id,lname,sum(m.miles) from employees e left join mileage m on e.id=m.id where month(m.trip_date) = 3 and substring(year(m.trip_date),3,2) = '02' group by e.id; CREATE TABLE IF NOT EXISTS employees ( id varchar(30) NOT NULL, fname varchar(25) NOT NULL, lname varchar(30) NOT NULL, password varchar(12) NOT NULL, accum_miles_for_year real(7,2), active_sw varchar(1) NOT NULL, registration varchar(10), engine_sizesmallint unsigned, fuel_reimburse_ratereal(3,2) default 0, PRIMARY KEY (id)) ID FNAME ACTIVE_SW 2SamA 3Fred RobertA 4Paul A 121212121George A 121212122George C. A 121212123George A ABCABCABCIanA BBobA QJoan Billy Bob A 123123124Jake A 021021021SamA 893458009Joan H A 6902DIanA 123412342Paul A 138501999ShermanI CREATE TABLE IF NOT EXISTS mileage ( recno mediumint not null auto_increment, id varchar(30) NOT NULL, trip_date date NOT NULL, trip_from varchar(30) NOT NULL, trip_to varchar(30), purpose varchar(30), miles real(7,2) unsigned NOT NULL, PRIMARY KEY (recno)) ID TRIP_DATEMILES 138501231 2002-03-01 5200.00 ABCABCABC 2002-03-0180.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0180.00 6902D 2002-03-0180.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0114.00 6902D 2002-03-0140.00 6902D 2002-03-0144.00 6902D 2002-03-0144.00 6902D 2002-03-01 800.00 6902D 2002-03-01 5.00 6902D 2002-03-01 148.00 Q 2002-03-01 7.00 --- Rick Emery wrote ... Show us your table structures and the data they contain. It appears your WHERE clause probably acting correctly. But without data, we can determine that. -Original Message- From: paul wilczynski [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 11:49 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Can't get left join to work I've got 2 MySQL tables: Employees, and Mileage. Mileage records trips for employees and there may be 0 or more Mileage rows for each Employee row. The Mileage table has a trip_date column. For testing purposes, the trip_date column in all rows is set to 2002-03-01. There are currently 15 rows in the Employees table. I want the result of the following select to be 15 rows (1 for each employee, whether or not there are any rows in the Mileage table for that employee). If I take the "where" clause out, I get all 15 rows (including a number of rows where sum(m.miles) = 0 (which is what I want).
[PHP-DB] duplicate entries in db
I have a script that calls a function to perform a query using the arguments sent to the function via http form processing. I get two entries into the MySQL database for one query. I only want one entry. Can someone point me in the right direction? Thanks in advance. Justin Hall JD Media www.jdmedia.net [EMAIL PROTECTED]
Re: [PHP-DB] trying to quote keys in arrays causes error, Why
On Friday 08 February 2002 03:30, Peter J. Schoenster wrote: > Hi, > > Someone pointed out that I should quote "key" in arrays. What someone forgot to point out was that within double-quoted strings you should not quote the keys. > If I do this: > > > > or just this: > $input[REQUEST_URI] > in a heredoc > > I get the following > > > Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or > > `T_NUM_STRING' in > > /usr/local/etc/httpd/htdocs/readbrazil.com/htdocs/login.php on line 49 > > but this works fine: > > As you have discovered yourself :) -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* It is far better to be deceived than to be undeceived by those we love. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Query with numbers like 1, 3, 5..........
Yes, Even Numbers: SELECT * FROM table WHERE MOD(id,2) = 0; Odd Numbers: SELECT * FROM table WHERE MOD(id,2) != 0; - Jonathan -Original Message- From: Jeremy Peterson [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 11:59 AM To: Raymond Lilleodegard; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Query with numbers like 1, 3, 5.. select * from table where id in (1,3,5,10,'etc') At 08:22 PM 2/7/2002 +0100, Raymond Lilleodegard wrote: >Hi! > >Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, >...? > > >Best regards Raymond > > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Query with numbers like 1, 3, 5..........
select * from table where id in (1,3,5,10,'etc') At 08:22 PM 2/7/2002 +0100, Raymond Lilleodegard wrote: >Hi! > >Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, >...? > > >Best regards Raymond > > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Need to delete charcters from a string
I need to delete the last 3 character of a string, what command can i use o do this. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Query with numbers like 1, 3, 5..........
Yes, but the question is why? -Original Message- From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 1:22 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Query with numbers like 1, 3, 5.. Hi! Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, ...? Best regards Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Can't get left join to work
Here are the 2 tables and selected columns from each. Note there are only 4 employees who have trips (3 of those employees active, 1 inactive). If I do the following select, I only get 4 rows returned (or 3 if I say 'where active = 'A'). In addition to those, I want 1 row returned for each of the employees with 0 miles if there are no rows in the 'mileage' table for them. To put it another way, I always want the number of rows returned to be equal to the number of employees rows whose active_sw = 'A'. select e.id,lname,sum(m.miles) from employees e left join mileage m on e.id=m.id where month(m.trip_date) = 3 and substring(year(m.trip_date),3,2) = '02' group by e.id; CREATE TABLE IF NOT EXISTS employees ( id varchar(30) NOT NULL, fname varchar(25) NOT NULL, lname varchar(30) NOT NULL, password varchar(12) NOT NULL, accum_miles_for_year real(7,2), active_sw varchar(1) NOT NULL, registration varchar(10), engine_sizesmallint unsigned, fuel_reimburse_ratereal(3,2) default 0, PRIMARY KEY (id)) ID FNAME ACTIVE_SW 2SamA 3Fred RobertA 4Paul A 121212121George A 121212122George C. A 121212123George A ABCABCABCIanA BBobA QJoan Billy Bob A 123123124Jake A 021021021SamA 893458009Joan H A 6902DIanA 123412342Paul A 138501999ShermanI CREATE TABLE IF NOT EXISTS mileage ( recno mediumint not null auto_increment, id varchar(30) NOT NULL, trip_date date NOT NULL, trip_from varchar(30) NOT NULL, trip_to varchar(30), purpose varchar(30), miles real(7,2) unsigned NOT NULL, PRIMARY KEY (recno)) ID TRIP_DATEMILES 138501231 2002-03-01 5200.00 ABCABCABC 2002-03-0180.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0180.00 6902D 2002-03-0180.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0114.00 6902D 2002-03-0140.00 6902D 2002-03-0144.00 6902D 2002-03-0144.00 6902D 2002-03-01 800.00 6902D 2002-03-01 5.00 6902D 2002-03-01 148.00 Q 2002-03-01 7.00 --- Rick Emery wrote ... Show us your table structures and the data they contain. It appears your WHERE clause probably acting correctly. But without data, we can determine that. -Original Message- From: paul wilczynski [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 11:49 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Can't get left join to work I've got 2 MySQL tables: Employees, and Mileage. Mileage records trips for employees and there may be 0 or more Mileage rows for each Employee row. The Mileage table has a trip_date column. For testing purposes, the trip_date column in all rows is set to 2002-03-01. There are currently 15 rows in the Employees table. I want the result of the following select to be 15 rows (1 for each employee, whether or not there are any rows in the Mileage table for that employee). If I take the "where" clause out, I get all 15 rows (including a number of rows where sum(m.miles) = 0 (which is what I want). If I leave the "where" clause in, however, I don't get employees with sum(m.miles) = 0 (even though the "where" clause should include all of the Mileage rows). (Only 3 Employees actually have corresponding rows in the Mileage table, and I only get 3 rows back.) select e.id,lname,sum(m.miles) from employees e left join mileage m on e.id=m.id where month(m.trip_date) = 3 and substring(year(m.trip_date),3,2) = '02' group by e.id; I need to select by month/year from the Mileage table. Any idea how the "select" can be modified to include rows for all of the Employees? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Query with numbers like 1, 3, 5..........
Hi! Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, ...? Best regards Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] trying to quote keys in arrays causes error, Why
Hi, Someone pointed out that I should quote "key" in arrays. If I do this: or just this: $input[REQUEST_URI] in a heredoc I get the following > Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or > `T_NUM_STRING' in > /usr/local/etc/httpd/htdocs/readbrazil.com/htdocs/login.php on line 49 but this works fine: But that violates the rule. Peter -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Viewing Session Varibles
hmmm... If I was you.. I would make your cart an object.. build a simple class like: class Cart { var $items; function Cart() { $this->items=Array(); } function Add_To_Cart($item) { if(!in_array($item,$this->items) { Array_Push($this->items,$items; } } function Remove_From_Cart($item) { if(in_array($item,$this->items) { unset($this->item[$items); } } } So in your script: session_start(); if (!session_is_registered("cart")) { $cart = new Cart; session_register("cart"); } /* now you should be able to get everything like this */ $cart->Add_To_Cart($whatever); $cart->Remove_From_Cart($whatever); /* where $whatever is the array of item data... first of which would be the id */ then you can manipulate it how ever you like.. just make the function inside the cart clas and call it by $cart->function_name(); This way the only thing stored in the session is the object.. which contains it all in place you can handle it. This is the only way I got reliable use out sessions :p I just whipped this off the top of my head.. so may not work :) JD -Original Message- From: Robert Weeks [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 10:41 AM To: php Subject: Re: [PHP-DB] Viewing Session Varibles Ok, This is driving me nuts. I'm sure its something simple but I can't seem to find the glitch. I'm trying to make a simple shopping cart using Session varibles to store the item => quantity pairs, then I loop thru the cart and query the db to get the item details, etc.. Most of it works fine but whenever I add a new item to the cart I lose the $qty value for the other items. Here is the code in question: ++ $qty) { if ($$id == "0") { unset ($cart[$id]); }else{ $cart[$id] = $$id; } $items = calculate_items($cart); foreach ($cart as $id => $qty){ $db = mysql_connect("localhost", "$databaseuser", "$databasepasswd") or die ("Unable to connect to database!"); mysql_select_db ("$databasename",$db) or die ("Unable to connect to database $db!"); $result = mysql_query ("SELECT * from products WHERE id = '$id'") or die ("Error in query. " . mysql_error()); if ($result){ extract(mysql_fetch_array($result)); echo "Title: $title"; echo "Description: $p_desc"; echo "Price: $price"; echo "Quantity: $qty"; echo ""; } } #print varibles to screen for debugging echo""; print_r($HTTP_SESSION_VARS); echo""; ?> + If one item is in the cart I get this from the $HTTP_SESSION_VARS: Array ( [cart] => Array ( [10] => 12 ) [items] => 12 [total_price] => 0.00 ) That would indicate to me that the cart pair has been saved. But as I add items I lose the earlier quantities: Array ( [cart] => Array ( [10] => [16] => [13] => 6 ) [items] => 6 [total_price] => 0.00 ) The $id is still there and I can query the db just fine, but no quantity. I don't know why this is eluding me but any help would be greatly appreciated. Thanks, Robert -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Can't get left join to work
Show us your table structures and the data they contain. It appears your WHERE clause probably acting correctly. But without data, we can determine that. -Original Message- From: paul wilczynski [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 11:49 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Can't get left join to work I've got 2 MySQL tables: Employees, and Mileage. Mileage records trips for employees and there may be 0 or more Mileage rows for each Employee row. The Mileage table has a trip_date column. For testing purposes, the trip_date column in all rows is set to 2002-03-01. There are currently 15 rows in the Employees table. I want the result of the following select to be 15 rows (1 for each employee, whether or not there are any rows in the Mileage table for that employee). If I take the "where" clause out, I get all 15 rows (including a number of rows where sum(m.miles) = 0 (which is what I want). If I leave the "where" clause in, however, I don't get employees with sum(m.miles) = 0 (even though the "where" clause should include all of the Mileage rows). (Only 3 Employees actually have corresponding rows in the Mileage table, and I only get 3 rows back.) select e.id,lname,sum(m.miles) from employees e left join mileage m on e.id=m.id where month(m.trip_date) = 3 and substring(year(m.trip_date),3,2) = '02' group by e.id; I need to select by month/year from the Mileage table. Any idea how the "select" can be modified to include rows for all of the Employees? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Cant create temporary tables on linux
On Friday 08 February 2002 00:18, Andy wrote: > Hi there, > > my app works fine on win2k and os x. After porting to linux I get > following errormsg: > > Occured during executing CREATE TEMPORARY TABLE IF NOT EXISTS ranking ( > user_id INTEGER, ranking INTEGER ) statement > > Error: 3 Error writing file '/tmp/#sql451_86_0.frm' (Errcode: 28) > > I have no clue how to solve this. > Can anybody give a hint? > > Thanx for any help > > Andy You've probably run out of space in /tmp. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Love is in the offing. -- The Homicidal Maniac */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Viewing Session Varibles
Ok, This is driving me nuts. I'm sure its something simple but I can't seem to find the glitch. I'm trying to make a simple shopping cart using Session varibles to store the item => quantity pairs, then I loop thru the cart and query the db to get the item details, etc.. Most of it works fine but whenever I add a new item to the cart I lose the $qty value for the other items. Here is the code in question: ++ $qty) { if ($$id == "0") { unset ($cart[$id]); }else{ $cart[$id] = $$id; } $items = calculate_items($cart); foreach ($cart as $id => $qty){ $db = mysql_connect("localhost", "$databaseuser", "$databasepasswd") or die ("Unable to connect to database!"); mysql_select_db ("$databasename",$db) or die ("Unable to connect to database $db!"); $result = mysql_query ("SELECT * from products WHERE id = '$id'") or die ("Error in query. " . mysql_error()); if ($result){ extract(mysql_fetch_array($result)); echo "Title: $title"; echo "Description: $p_desc"; echo "Price: $price"; echo "Quantity: $qty"; echo ""; } } #print varibles to screen for debugging echo""; print_r($HTTP_SESSION_VARS); echo""; ?> + If one item is in the cart I get this from the $HTTP_SESSION_VARS: Array ( [cart] => Array ( [10] => 12 ) [items] => 12 [total_price] => 0.00 ) That would indicate to me that the cart pair has been saved. But as I add items I lose the earlier quantities: Array ( [cart] => Array ( [10] => [16] => [13] => 6 ) [items] => 6 [total_price] => 0.00 ) The $id is still there and I can query the db just fine, but no quantity. I don't know why this is eluding me but any help would be greatly appreciated. Thanks, Robert -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Converting upper case letters to lower case because of db??
On Friday 08 February 2002 00:14, Raquel Rice wrote: > On Thu, 7 Feb 2002 17:07:35 +0100 > > Andy "Andy" <[EMAIL PROTECTED]> wrote: > > Hi there, > > > > I have a tabel with 250 entries showing a country code lik "CA" > > > > Now my application does not work on linux, because they have to be > > in lower > > case. > > > > Can I make anyhow an bufix, or even better creating a php function > > to change > > all 250 entries to lower case. > > > > I could not find the propper function on the php site. > > > > Can anybody please help on changing this thing into lower case? > > > > Thanx > > > > ANdy > > How about "strtolower()"? You can run a query directly on the db. Something like: update mytable set myfield = LOWER(myfield) WHERE 1; -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Distrust all those who love you extremely upon a very slight acquaintance and without any visible reason. -- Lord Chesterfield */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Can't get left join to work
I've got 2 MySQL tables: Employees, and Mileage. Mileage records trips for employees and there may be 0 or more Mileage rows for each Employee row. The Mileage table has a trip_date column. For testing purposes, the trip_date column in all rows is set to 2002-03-01. There are currently 15 rows in the Employees table. I want the result of the following select to be 15 rows (1 for each employee, whether or not there are any rows in the Mileage table for that employee). If I take the "where" clause out, I get all 15 rows (including a number of rows where sum(m.miles) = 0 (which is what I want). If I leave the "where" clause in, however, I don't get employees with sum(m.miles) = 0 (even though the "where" clause should include all of the Mileage rows). (Only 3 Employees actually have corresponding rows in the Mileage table, and I only get 3 rows back.) select e.id,lname,sum(m.miles) from employees e left join mileage m on e.id=m.id where month(m.trip_date) = 3 and substring(year(m.trip_date),3,2) = '02' group by e.id; I need to select by month/year from the Mileage table. Any idea how the "select" can be modified to include rows for all of the Employees? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: new php developer
> I am a student a the University of Pittsburgh, and a new php developer. Is > it possible to have a mysql database that is made up of html documents that > can be accessed using php? This question may sound strange, but I'm not > sure of any other way to say it. Yes! That's how I have my website set up and it works great! You can set up a form to input the html into the database -- use a form textbox for the html. I use a couple different versions . . . one that you can use to input straight text with embedded html into the database. Another that non html programmers can use to input content into the database. I just convert their line-breaks into tags. It's basic but it works. Rita. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Viewing Session Varibles
Like so: echo""; print_r($_SESSION); echo"": I think for PHP less 4.04, you need $HTTP_SESSION_VARS Instead. JD -Original Message- From: Robert Weeks [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 8:45 AM To: php Subject: [PHP-DB] Viewing Session Varibles Is there an easy way to get a dump to the page of all session varibles? I'm trying to create an associtave array in a session varible named cart ($item1 =>$qty1, $item3=>$qty2, etc.) and i can't seem to wrap my brain around it this morning. I get the item set but can't get the $qty to set. Thanks, Robert Weeks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Ok another update
Jennifer... $query="select name, days from wt_users where uid=$uid"; change to: $query="SELECT name, days FROM wt_users WHERE uid=\"$uid\" "; You also need to make sure the page that is calling this script has a valid value of $uid otherwise it won't work. "Jennifer Downey" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi Everyone, > > I want to first thank you for helping with the last question I had. It > didn't help but I finally figured it out. This one though has me stumped. > > I have started using a portal script thinking I might be able to see a > little better how php works. It will do fine for me as far as my site will > go. But here is the problem. I want to tell a user how many days they have > left until a certain thing happens. The portal is phpwebthings so if anyone > is familiar with it... > > > > The problem is I can't figure out how to get the username from the database > here is the code I am trying to make work. > > > $db["days"]=("UPDATE wt_users set days = days - 1 where uid=$uid"); > $result=mysql_query($db["days"]); > > $query="select name, days from wt_users where uid=$uid"; > $ret = mysql_query($query); > while(list($name, $days) = mysql_fetch_row($ret)) > > > print("$name you have $days days to complete your questionnaire"); > ?> > > I can't get it to work unless I specify a specific user. Like $query="select > name, days from wt_users where uid=1"; > > How do I pull the user from the session? Also when I do specify a user and > refresh the page it updates the count down how do I get it to only update > once > a day. > > Any help would be appreciated! > Thanks > Jennifer Downey > > > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: THIS IS TRUE !!!
Yes you can, i forget how though... I dropped the ODBC and MS databases a year ago... I wish I remembered! "Kerem Can Karakas" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > how can you do that > > Francisco Aquino wrote: > > > Can I access a Database like MsAccess without ODBC (DSNLess) > > FAST! > > > > > > Francisco Aquino > > (Brasil - We're Not Indians) > > > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] File deletion
I created a couple of forms where one inserts new contact data with a file, in this case its a resume. Now, I want to create a form where a user can update the information by inserting their updated information and if there is a new resume then it would be uploaded. I got the upload part down, but i would like to delete the old resume when the update is done, only if there is an update done to the resume. This more for file management than anything. I am sure this is possible, but I thought I would ask all you PHP experts first since I am a semi-newbie at this... thanks! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Viewing Session Varibles
Is there an easy way to get a dump to the page of all session varibles? I'm trying to create an associtave array in a session varible named cart ($item1 =>$qty1, $item3=>$qty2, etc.) and i can't seem to wrap my brain around it this morning. I get the item set but can't get the $qty to set. Thanks, Robert Weeks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Converting upper case letters to lower case because of db??
strtolower() -Original Message- From: Andy [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 8:08 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Converting upper case letters to lower case because of db?? Hi there, I have a tabel with 250 entries showing a country code lik "CA" Now my application does not work on linux, because they have to be in lower case. Can I make anyhow an bufix, or even better creating a php function to change all 250 entries to lower case. I could not find the propper function on the php site. Can anybody please help on changing this thing into lower case? Thanx ANdy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Cant create temporary tables on linux
Hi there, my app works fine on win2k and os x. After porting to linux I get following errormsg: Occured during executing CREATE TEMPORARY TABLE IF NOT EXISTS ranking ( user_id INTEGER, ranking INTEGER ) statement Error: 3 Error writing file '/tmp/#sql451_86_0.frm' (Errcode: 28) I have no clue how to solve this. Can anybody give a hint? Thanx for any help Andy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Converting upper case letters to lower case because ofdb??
Andy, You can do it with PHP's strtolower() function.. See: http://www.php.net/manual/en/function.strtolower.php Gurhan -Original Message- From: Andy [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 11:08 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Converting upper case letters to lower case because of db?? Hi there, I have a tabel with 250 entries showing a country code lik "CA" Now my application does not work on linux, because they have to be in lower case. Can I make anyhow an bufix, or even better creating a php function to change all 250 entries to lower case. I could not find the propper function on the php site. Can anybody please help on changing this thing into lower case? Thanx ANdy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Converting upper case letters to lower case because of db??
On Thu, 7 Feb 2002 17:07:35 +0100 Andy "Andy" <[EMAIL PROTECTED]> wrote: > Hi there, > > I have a tabel with 250 entries showing a country code lik "CA" > > Now my application does not work on linux, because they have to be > in lower > case. > > Can I make anyhow an bufix, or even better creating a php function > to change > all 250 entries to lower case. > > I could not find the propper function on the php site. > > Can anybody please help on changing this thing into lower case? > > Thanx > > ANdy How about "strtolower()"? -- Raquel Americans cannot teach democracy to the world until they restore their own. --William Greider, journalist and author -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Converting upper case letters to lower case because of db??
Hi there, I have a tabel with 250 entries showing a country code lik "CA" Now my application does not work on linux, because they have to be in lower case. Can I make anyhow an bufix, or even better creating a php function to change all 250 entries to lower case. I could not find the propper function on the php site. Can anybody please help on changing this thing into lower case? Thanx ANdy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: THIS IS TRUE !!!
how can you do that Francisco Aquino wrote: > Can I access a Database like MsAccess without ODBC (DSNLess) > FAST! > > > Francisco Aquino > (Brasil - We're Not Indians) > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] difference !!??
Bart, See this page for an explanation of quotes inside array brackets: http://www.php.net/manual/en/language.types.array.php Basically, the correct way to do it is to _always_ use quotes (single quotes for strings without variables, and double quotes for strings with variables). So your example below should use format #2 since there are no variables to expand. Format #1 below is deprecated, and I can attest to weird behavior when you use $row[$column_name] without double quotes. Hope this helps! Daniel Ems On Thu, 7 Feb 2002, B. Verbeek wrote: > Hello, > > What's the difference between: > > 1.- $row[column_name]; > 2.- $row['column_name']; > 3.- $row["column_name"]; > > ? > > ragards Bart > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Creating a dynamic querry ??
Hi there, I am building a picture search engine with a gui where the user can choose categories and then choose from those categories several points. It is almost impossible to build a querry out of that. I am having a problem keeping it dynamic. It works if I am naming the category, but I would like to make it dynamic Here is an example what I am trying to get: assuming there are following values: $glacier = array("g_one", "g_two"); $lake = array ("l_one", "l_two"); $mountain = array ("m_one", "m_two"); // this returns the value for glacier echo $glacier[1]; // g_two // This code is creating a querry. User has a gui where he can choose between the categories. // It should loop through all possibilities Thats why I tryed to make the $glacier $$category But somehow this does not work // The problem is, that I want to loop through all. So I do not know if it is a glacier, lake or mountain the user selected building the querry: if ($glacier[0] == 'empty'){ // show all glaciers $search = "glacier IS NOT NULL"; } else{ // show particular $search = "glacier ="; for($i=0; $ihttp://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] difference !!??
Hello, What's the difference between: 1.- $row[column_name]; 2.- $row['column_name']; 3.- $row["column_name"]; ? ragards Bart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Ok another update
Hi Everyone, I want to first thank you for helping with the last question I had. It didn't help but I finally figured it out. This one though has me stumped. I have started using a portal script thinking I might be able to see a little better how php works. It will do fine for me as far as my site will go. But here is the problem. I want to tell a user how many days they have left until a certain thing happens. The portal is phpwebthings so if anyone is familiar with it... The problem is I can't figure out how to get the username from the database here is the code I am trying to make work. I can't get it to work unless I specify a specific user. Like $query="select name, days from wt_users where uid=1"; How do I pull the user from the session? Also when I do specify a user and refresh the page it updates the count down how do I get it to only update once a day. Any help would be appreciated! Thanks Jennifer Downey -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php