Re: [PHP-DB] Regular Expressions? URGENT
Hi Aaron, I found this on a little useful when I started learning regex. Good luck 2 ya! adam http://www.devshed.com/Server_Side/Administration/RegExp/ Hi All, Sorry for OT post but need some info. Does anyone know a good tutorial that explains regular expressions in DUMMY terms? I have a list of characters that I need to check to see if they are in a string. I tried creating an array of the characters but some of them are like ' " and ` which seem to cause some problems. Any good turotials for regular expressions? Thanks a bunch! Aaron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PHP script execution - display issue
This is neither a PHP nor database question. This is client side. Anyway, a simple fact is that tables won't render until the whole table has been loaded into memory (ie. it won't show until it reaches the tag). If you have your whole site inside one big table, then this is what is causing your problems. Unfortunately, sometimes this unavoidable. To make it run sequentially, you could do this, or use divs with absolute positioning. just a thought. Adam Hello, I have a display problem with one of my sites. Because there is an big amount of information in the pages, which is extracted from database, using IE browser I see only the background of the site, and then, after a time, the whole page. My client has recently requested to make something to improve the site speed and display time. So because all the site is done using the classes, and the information is extracted through them, I reduced the instruction numbers, and I compacted as much as I could the classes. But I still have the display problem using IE browser : I see the background, and just after that I see the whole site. I mention that the classes are included, and the class function is called through $this_class->function($parameters); Not all the classes used in the page are called In the beginning; and another mention is that the site pages contains 4 sections. Top, left, middle, & right. My question is: Is there a way to display sequentially the site. After the background, to display the first section (top), then left part, middle part and right part after that ? Again, the site loads like this : the background, then the whole page. This doesn't matter if I use dial-up or T1. My client saw, for example, that cnn or yahoo site loads sequentially. Knowing that yahoo is done in php, I'm wondering how they did it. Thanks Petre Nicoara -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: adding to an array variable using a loop...?
I assume the field 'date' in your database is a date field, and in your code you are trying to do a date + 1, but you are not specifying *what* you are adding to the date (ie. 1 day, 1 week, 1 month), therefore the whole variable is being replaced (with a 1). Try looking at the various date functions (or string functions) to work out how to do this. Depending on how your date is setup you would use strtotime() or mktime() (or both). Adam --- Original Message --- I want to create an array from results returned from a mysql query. I want it to go through each row in the returned result, and if the variable in the array staff exists add 1 to the total, if it doesnt exist, set it as one and carry on. But when i run this and do var_dump, it just returns "1" in the array for every date. I don't think my logic for this is correct, please help. Cheers, Dave. == $query = "SELECT * FROM Rota WHERE date >= $start and date <= ($start + INTERVAL 6 DAY) "; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ $x = 1; $date = $row['Date']; if ( isset($staff[$date] ) ){ $staff[$date] = $staff[$date] + $x ; } else{ $staff[$date] = $x ; } } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Dynamic Variable names
It's probably better to use arrays. $tips[0] = "value"; $tips[1] = "value"; $tips[2] = "value"; Although, if you REALLY want dynamic variable names. $i = 1; $varname = 'tips_'.$i; $$varname = "value"; this will make a variable like below: $tips_1 = "value"; But like I said before, it's better to use arrays - they are much more flexible (and PHP arrays are especially cool). http://www.php.net/manual/en/ref.array.php adam Just a quick question about dynamic variables would like to end up with a variable called $tips_1 $tips_2 ... $tips_n where "n" is the value of the variable $sid i have tried $tips . '$sid'; and other variants, but i can't get one that doesn't return a parse error or T_VARIABLE error. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Processing Page
I have seen an example using JavaScript where javascript commands are flushed every so often (from PHP) which indicates a status bar process. It was used to monitor mailouts. The javascript commands were simply telling an image to increase it's width. Of course you have to have a system where you can gauge percentages of things done. Alternatively, you could simply use same method (without image), and after db stuff is done, output a javascript redirect. The above is probably confusing, but ask me if you need more explanation. Adam -Original Message- From: Aspire Something [mailto:[EMAIL PROTECTED] Sent: Thursday, February 27, 2003 2:56 PM To: php-db Subject: Re: [PHP-DB] Processing Page Thanks every one ... All the method you told me are static it does not look if the sql statemet being exec by php along with backend has finished its job . I only wanted to show the processig page till the time the query does it's work . let me add here that the time for execution of the script here is unpridictable and it is expected that it may vary according to the job given thus I cannot hardcode the refresh time . Regads, V Kashyap
[PHP-DB] Re: Using results from one mysql query to make another
SELECT b.name FROM apliexperts a LEFT JOIN experts b ON a.expid = b.id WHERE softid = 2 I have a table that includes the ids of software aplications and experts (apliexperts). My page is loaded with the variable of the software id (softid), which it uses to match the experts for that software. But instead of returning just the expert id (expid), to use that expid to get the full row entry from the "experts" table. So if my apliexperts table has the rows: [softid] [expid] [id] 3 0 0 2 1 1 2 2 3 And the experts table has: [id] [Name] 0paul 1john 2mark It needs to return john and mark if the softid is 2. thanks, Jay
[PHP-DB] Re: Recordsets and associative arrays
Hi Don, Use this process: $value){ $data[$row][$key] = $value; } $row++; } ?> The array structure would be something like this: $data[0]['Name'] = 'Name 1'; $data[0]['Address'] = 'Address1'; $data[0]['City'] = 'City1'; $data[1]['Name'] = 'Name 2'; $data[1]['Address'] = 'Address2'; $data[1]['City'] = 'City2'; $data[2]['Name'] = 'Name 3'; $data[2]['Address'] = 'Address3'; $data[2]['City'] = 'City3'; etc etc HTH Adam - Original Message - Message-ID: <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] From: "Don Briggs" <[EMAIL PROTECTED]> Date: Mon, 17 Feb 2003 16:42:51 -0600 Subject: Recordsets and associative arrays Hello. I am having a problem with syntax. Here is what I am doing. I have the follwing table |Name|Address |City| = |Name 1 | Address1 | City1 | |Name 2 | Address2 | City2 | |Name 3 | Address3 | City3 | |Name 4 | Address4 | City4 | = I can fetch a single record into an associative array. But I need to put these records into an multi-dimentional associatave array. I have tried to figure out what the syntax should be, but it has not worked. The only thing is that the key names will be different from the field names, and we won't be putting all of the record fields into the table. So we can't just make an array of the associative arrays returned by mysql_fetcharray($result). Hope you can help me out. Don! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Web Page Caching
This may not be true in your case, but I remember another user on this list claiming a similar thing, and his problem was actually code-related. He had his db update code *AFTER* the results were displayed (ie. doing edit and save on same page). Check your programming logic. Just a note to people out there who may not have much programming experience - try doing all of your server-side processing (or at least db and filesystem calls, etc) before you output any data, this way you can implement error checking etc and still use the header() function, etc. Adam --- Original Message --- Hello, I don't know if this is the right list to send this question to. It appears that the browser caches the result after a PHP page updates the database. I have to manually reload it in order to see the updates. Does anyone know how to overcome this? Thanks, Philip
RE: [PHP-DB] A little JOIN help please...
SELECT B.Title FROM phpCalendar_Details AS B, phpCalendar_Daily AS A WHERE A.CalendarDetailsID = B.CalendarDetailsID AND CURDATE( ) BETWEEN A.StartDate AND A.StopDate Also, you don't need to use the backticks around field names unless they contain spaces or other reserved words and characters. Adam
[PHP-DB] Re: Images-weird!!
Hi Mihai, Didn't try your code, but noticed your comment on colours. RBG values go from 0 - 255, not 1 - 256, so this may be your problem. Adam
[PHP-DB] Re: Using strlen and substr to Shorten DB Results
Try this. PHP arrays are cool! Of course there are tidier ways to implement this, but this is just an example. Adam <-- Code --> $getscname = mysql_query("SELECT * FROM subcat WHERE subcatid = '$subcatid'") or die ("Couldn't get the info.".mysql_error()); while($sub_cat = mysql_fetch_array($getscname)){ $subcat_id = $sub_cat['subcatid']; $subcat_name = $sub_cat['subcatname']; $arrCats[] = ''.$subcat_name.''; } echo implode('|',$arrCats); <-- Code --> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Email to a list of address in your database.
This should work. You were on the right track, although you might want to use better var names so you don't get confused. You can see I have changed them to what I would normally use. Adam mail To all my list -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] javascript and submitting forms
Hi Mignon, This should work, never closing the window without submitting (foolproof). Just add some error checking, and you'll be sweet as a nut! All I did was add the echo statement underneath the data insert. Adam include ('dbconn.php'); if(isset($submit)) { $query = "INSERT INTO `comments` ( `track_id`, `cat_comments` ) VALUES ( '0', '$comm' );"; mysql_query ($query, $link ); echo 'window.close();'; } ?> Enter your details here: -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: mysql_errno() list?
Just use a combination of mysql_errno() and mysql_error(): echo mysql_errno() . ": " . mysql_error(). "\n"; Adam PS. Documentation always rocks! Hi guys, I've been playing with PHP for a while now, and love the mysql functions, but there's one thing I'd like to know... I want to check if a mysql error is a certain number, and thats all fair enough because every time i encounter an error I can write down what that error was. However, it would be handy if I could have my own define file with all the errors in. Can I ask if anyone has a list of errors and their numbers for mysql_errno? I've looked on the web and found a load of errors for the mysql daemon (the page told me to look in /usr/share/mysql/mysql_errors.txt) but this isnt the file I want as the errors there relate to the server and not errors with a query I'm running Thanks in advance for any help James Booker EMPICS Sports Photo Agency http://www.empics.com
[PHP-DB] Re: File Upload ---Thanks!
Yep. Been using Mac OS X (10.1 - 10.2.3) with mySQL no problems. I built it from source first time, but now I just use Mac OS X packages from Mark Liyanage. You can find them here. Also he has a good pre-compiled PHP4 you can download and use. http://www.entropy.ch/software/MacOSx/mysql/ Adam Thanks folks - persistence pays off and so does group discussions . I had chmodded the uploads directory to 777 but it was within the public_html directory with different file permissions so I guess public_html permissions were taking presidence. After reading all of your suggestions... a little light turned on and I moved the uploads directory outside of the public-html directory and Volia! Uploading file... File uploaded successfully Preview of uploaded file contents: THIS IS A TEST. Thanks Again. Anyone using a Macintosh with MySql? That is my next goal. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Finding zipcode within radius of another zipcode.
There are databases / packages you can buy which already have this information in them. A simple search for 'purchase postcode database' on Google gave me a few leads. Adam Hi folks, I'm building a PHP/MySQL database for a customer. It's an advanced mailing list for a band. They want to be able to send e-mails targetted to people around where a gig takes place. For instance, if a concert is taking place somewhere in the 42071 zipcode, they want to e-mail everyone within 500 miles of 42071. The database will have around 10,000 members, with e-mail and mailing addresses. Does anyone have a good idea for this? Thanks a ton, John Thile (gilrain) http://lunarpolicy.net -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Delay Confirmation....
Use: set_time_limit(0); // let script run forever Have a look at output control functions, particularly: ob_start(); ob_flush(); They might help you Adam --- Original Message --- Hi, I'm still new in PHP..., I have some problem in using sleep() function. Actually, I want to make a script that confirm the user to wait for 10 seconds before proceed to the next step. First the message "Please wait for 10 seconds while we're processing your request..." will be shown to user, then at the same time I want to delay the processing for 10 seconds with sleep() function. This is my script : But the result juz not like I wanted. The sleep runs before the message shown up..., not before the query... I think, sleep() is delayed a whole scriptboth, the message and the query result are printed out after 10 seconds... It makes me so confused How could I fix it ??? Please help me... --www.kapsul.org-- DuFronte
[PHP-DB] Re: Check Automaticaly
I would imagine your game would have two frames (one hidden frame), and the hidden frame would contain scripts to check and update page. In the bottom frame i see you might have two choices: 1. have a meta refresh which checks every 5 (or so) secs if a move has been made, and if detects a move, sends a refresh command to the top frame 2. have a php script which continually checks if a move has been made ( using sleep() function and set_time_limit() ), and if detects a move, sends a javascript command to browser, then continue detecting if changes have been made.. the implications of #2 (i would image), is the explorer icon will be constantly loading a page, so if you click stop, the game will cease hope that helps adam
[PHP-DB] Re: -- table name prefix in result set after join --
SELECT tblA.col1 as 'tblA.col1', tblB.col2 as 'tblB.col2', tblB.col3 as 'tblB.col3' FROM tblA, tblB Is there a way in SQL to have the column names prefixed by the table name in a result set after a join? Table A has column col1 and table B has columns col2 and col3 After the join I want the result set to have columns named A.col1B.col2 B.col3 Such that I can tell from which table each column came from. Is this possible? Matt Friedman -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Check data exists in MySQL
Sorry about previous post (some stupid shortcut key made it send) Your row: $sql = "INSERT INTO count VALUES('$dept', '$deptsub', '0'); should be: $sql = "INSERT INTO count VALUES('$dept', '$deptsub', '0')"; You missed the double quotes. Adam --- Original Message --- Hi, for some reason i'm getting an error when I try to run this query: __ $sql="SELECT num FROM count where dept='$dept' AND deptsub='$deptsub'"; $page_count = mysql_query($sql,$db); # If does not exist in the database, insert a new entry if (!mysql_num_rows($page_count)){ $sql = "INSERT INTO count VALUES('$dept', '$deptsub', '0'); $result = mysql_query($sql,$db); } #Update the count in the database $page_count = $page_count + 1; $sql="UPDATE count SET num='$page_count' WHERE dept='$dept' AND deptsub='$deptsub'"; $result = mysql_query($sql, $db); __ My table looks like this: count: dept VARCHAR(32) deptsub VARCHAR(32) num INT(10) __ I'm getting the following error message: Parse error: parse error in /home/./public_html/public/index.php on line 25 (Which is the line: $sql="UPDATE count...) Any thoughts would b most helpful. Thanks, Gav
RE: [PHP-DB] php sessions using mysql (or any db)
Hi, Just wondering, which is the better method: 1. Using PHP sessions ($_SESSION['var'] = "val";) 2. Using mySQL-based sessions (as described in this thread) I know if you're using multiple servers, a DB-based session would be handy. Any comments, anyone? Adam
[PHP-DB] Re: how to put all rows into an array
No built-in function, but this can be handy (i have it inside a getData() function, which also lets me output data in a number of ways) HTH, Adam $sql = "SELECT * FROM ."; $DB_RESULT = mysql_query($sql); $arrData = array(); $rowCount = 0; while ($r = mysql_fetch_array($DB_RESULT,MYSQL_ASSOC)){ foreach ($r as $key => $value){ $arrData[$rowCount++][$key] = $value; } }
[PHP-DB] Re: Displaying a single picture...
You could do something as simple as this: I think most browsers will convert the spaces in the link (when clicked) to '+' or '%20', but this may not be true with some less popular browsers (i don't know). Then displayPic.php might be something like this (if you have latest PHP version): displayPic.php -- Hope this helps Adam --- Original Message --- I have several thumbnail images spread out in my website. I thought it would be cool to write a single PHP script so that when they click on the thumbnail, the name of the larger pic would be passed to a PHP script that displays it on its own page...I don't even care about a link back, they can just click the browser's back arrow. How do I get the name stored when they click on the thumbnail? My confusion is, I'm seeing this one dimensionally. You click on an image, it calls a link. But I need to click on the image, store the name of the pic I want to display, then call the PHP link. I've looked at some of the free Image Lib PHP scripts out thereand they all go wy overboard on what I'm looking to do. Any suggestions? Thanks
[PHP-DB] Re: Polls?
Hello, I created a (very) simple class for a polling system. I only developed it to a certain stage (took me a few hours). This was how you used it: $poll = new easyPoll("poll_name"); $poll->PrintVotingPanel(); ?> and if you wanted to show all the results of all polls $poll = new easyPoll(); $pollNames = $poll->GetAllPolls(); for ($i=0; $i $poll = new easyPoll($pollNames[$i]); $poll->PrintResults(); echo ""; } ?> Here is my table structure, and a few of my SQL statements. // for the voting panel $sql = "SELECT * FROM tblPoll, tblPollItems WHERE pollName = '".$this->PollName."' AND pollID = pollID_FK ORDER BY itemOrder"; // getting the actual amounts for displaying data $sql = "SELECT pollQuestion, itemText, count(voteID) as numVotes FROM tblPoll, tblPollItems as t1 LEFT JOIN tblVotes as t2 ON t1.itemID = t2.itemID_FK WHERE pollID = pollID_FK AND pollName = '".$this->PollName."' GROUP BY itemID ORDER BY itemOrder"; -- -- Table structure for table 'tblPoll' -- CREATE TABLE tblPoll ( pollID bigint(20) NOT NULL auto_increment, pollName tinytext NOT NULL, pollQuestion tinytext NOT NULL, startDate date NOT NULL default '-00-00', endDate date NOT NULL default '-00-00', PRIMARY KEY (pollID) ) TYPE=MyISAM; -- -- Table structure for table 'tblPollItems' -- CREATE TABLE tblPollItems ( itemID bigint(20) NOT NULL auto_increment, pollID_FK bigint(20) NOT NULL default '0', itemText tinytext NOT NULL, itemOrder tinyint(4) NOT NULL default '0', PRIMARY KEY (itemID) ) TYPE=MyISAM; -- -- Table structure for table 'tblVotes' -- CREATE TABLE tblVotes ( voteID bigint(20) NOT NULL auto_increment, itemID_FK bigint(20) NOT NULL default '0', voteTime bigint(20) NOT NULL default '0', voterIP tinytext, PRIMARY KEY (voteID) ) TYPE=MyISAM; Hope this helps BTW - if you want, i can give you all the source code for the class, but currently it is not very customizable - lots of things are hard-coded. Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] .htaccess and db authentication
I was wondering about people's thoughts on file security through php using database authentication. Take the following example: I have a folder (in webroot) called /videos/ which contains a heap of files like so: video_1_14-06-2002.mpg video_2_15-06-2002.mpg video_3_16-06-2002.mpg video_4_17-06-2002.mpg Now, in a database I have table with a heap of users, with some sort of security identifier which allows them to access only the files they are given access to. Now, doing this in PHP is no problem, but I want to be able to stop them from 'predicting' what the next filename would be and just typing that in. I thought about using .htaccess, where if they try to access one of the files, it sends it off to a php page which authenticates and displays a list of files they are allowed to view, although I would like it if they had the opportunity to type in the url of the file if they are actually authorized to do so. I would prefer not to keep a file listing of allowed usernames and passwords using .htaccess, as this information could potentially be updated frequently with a large amount of users (or would this not be a problem). Has anyone implemented this type of system before? are there any good resources people know of for this type of thing? Thanks, Adam. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Accessing data from next row? (mysql)
Also, if you're not sure how to get the values from $arrThisRow / $arrNextRow: echo $arrThisRow['columnName']; or $arrData[$i]['columnName'] if you want to access it manually without the other two arrays adam On Monday, October 14, 2002, at 06:05 PM, Adam Royle wrote: > Create an array and go through the array as needed. > > Here is some code from one of my db functions: > > $DB_RESULT = @mysql_query($sql) or die("Error executing query: " . > mysql_error()); > > // create an empty array to fill with data > $arrData = array(); > > $rowCount = 0; > while ($r = mysql_fetch_array($DB_RESULT, MYSQL_ASSOC)){ > foreach ($r as $key => $value){ > $arrData[$rowCount][$key] = $value; > } > $rowCount++; > } > > then simply instead of your code: > while($array = mysql_fetch_array($result)){ > > use this: > for ($i=0;$i $arrThisRow = $arrData[$i]; > $arrNextRow = $arrData[$i+1]; > } > > obviously, if you are trying to access a variable which index does not > exist, you will need to implement some sort of error checking, etc > > adam > > >> Using mysql, how do I access the data of the next row using code >> something like this: >> $result = mysql_query("select column from table where >> whatever='whatever'"); >> while($array = mysql_fetch_array($result)){ >> //Whatever >> } > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Accessing data from next row? (mysql)
Create an array and go through the array as needed. Here is some code from one of my db functions: $DB_RESULT = @mysql_query($sql) or die("Error executing query: " . mysql_error()); // create an empty array to fill with data $arrData = array(); $rowCount = 0; while ($r = mysql_fetch_array($DB_RESULT, MYSQL_ASSOC)){ foreach ($r as $key => $value){ $arrData[$rowCount][$key] = $value; } $rowCount++; } then simply instead of your code: while($array = mysql_fetch_array($result)){ use this: for ($i=0;$i Using mysql, how do I access the data of the next row using code > something like this: > $result = mysql_query("select column from table where > whatever='whatever'"); > while($array = mysql_fetch_array($result)){ > //Whatever > } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Advanced search scripts
Well, for this example, you could use mySQL, but really, I would be looking to utilise this on any database. Personally, I don't think this would be database dependent (unless you have other ideas). Adam On Wednesday, October 9, 2002, at 08:46 PM, John W. Holmes wrote: > What database are you using? > > ---John Holmes... > >> -Original Message----- >> From: Adam Royle [mailto:[EMAIL PROTECTED]] >> Sent: Wednesday, October 09, 2002 2:09 AM >> To: [EMAIL PROTECTED] >> Subject: [PHP-DB] Advanced search scripts >> >> I was wondering if anyone has some resources (links or scripts) on >> 'advanced site searches'. Something that is similar to the way regular >> search engines process requests. >> >> ie. "phrase or two" word +required -"not included" >> >> Also, returning details of that search, say for example returning 10 > words >> before and 10 words after and displaying it in search results. The > ability >> to search similar words (eg. ignoring punctuation) would be cool > aswell. >> >> I am interested in this for database (all text fields), and also > searching >> text files on filesystem. >> >> Now, I'm not trying to recreate Google or anything, and this is just > for >> my own research (at this time), but I eventually would like to be able > to >> create a smarter site searching engine. >> >> Can anyone give suggestions? or any links to tutorials (or books) >> >> I have used regex a little bit before, but not in PHP (only ASP and >> JavaScript). >> >> Adam > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Advanced search scripts
I was wondering if anyone has some resources (links or scripts) on 'advanced site searches'. Something that is similar to the way regular search engines process requests. ie. "phrase or two" word +required -"not included" Also, returning details of that search, say for example returning 10 words before and 10 words after and displaying it in search results. The ability to search similar words (eg. ignoring punctuation) would be cool aswell. I am interested in this for database (all text fields), and also searching text files on filesystem. Now, I'm not trying to recreate Google or anything, and this is just for my own research (at this time), but I eventually would like to be able to create a smarter site searching engine. Can anyone give suggestions? or any links to tutorials (or books) I have used regex a little bit before, but not in PHP (only ASP and JavaScript). Adam
[PHP-DB] Re: password function
When using aggregate functions in sql, it is good to name that expression using the AS keyword. Try this: $result = mysql_query("select password(".$_POST['password'].") AS pword"); while ($p = mysql_fetch_array($result, MYSQL_ASSOC)){ $pswrd=$p['pword']; } Also, like David said, you should also have exception handlers (need not be advanced). If you're like me and hate having to type too much, chuck your db stuff in a function. A very simple one would be doing this (this is not tested, by the way): function query($sql){ return @mysql_query($sql) or die("Error: ". mysql_error()); } Then to call it, simply $sql = "select password(".$_POST['password'].") AS pword"; $result = query($sql); Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: assist with SORT array
Bartosz was correct in saying that you should use your query to sort, rather than sorting array. And the array is actually sorted, although it keeps its index. See the manual reference on arrays to see how they work. To iterate over sorted arrays, use the foreach() construct. Anyway, the better way to do it (using only 1 sql query), would be using the following code. $rest_IDs = implode("','", $restaurants); $sql = "SELECT name FROM restaurants WHERE id IN ('$rest_IDs') ORDER BY name"; $result = mysql_query($sql) or die($sql . mysql_error()); while($row=mysql_fetch_object($result)) { $rest_array[] = ucwords(stripslashes($row->name)); } And its sorted!!! If you want to check what values an array holds, use a combination of header("Content-Type: text/plain"); and print_r($rest_array); Have fun! Adam > I have a head scratcher.. prob just a glitch on my side, but somehow > I am confused with the results. > > I have a php script pulling from a mysql database for id/names which > is getting choices through a check box form. All of that works just > fine, but I wanted to display the results sorted by title. My snippet > of code is: > > // $restaurants = array() of ids back from form > for($i=0;$i $rest_id = $restaurants[$i]; > $sql="select name from restaurants where id=$rest_id"; > $result=mysql_query($sql) or die($sql . mysql_error()); > while($row=mysql_fetch_object($result)) { > $rest_name .= ucwords(stripslashes($row->name)) . ";"; > } > } > $rest_array=explode(";",$rest_name); > > $rest_sort=sort($rest_array); // <-- the problem line > > die("checking: $rest_name size = ".sizeof($rest_array) > . " sorted: " . sizeof($rest_sort)); > > the results come back with 6 in the $rest_array but only 1 in the > $rest_sort array! How is that?? > > checking: Hi-Ho Tavern;Village Inn;Speak Easy;Duane's House Of > Pizza;Atomic Coffee; > size = 6 sorted: 1 > > What I am trying to accomplish is an array('Atomic Coffee', 'Duane's > House Of Pizza','Hi-Ho Tavern','Speak Easy','Village Inn') > > Help?? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [mysql] freeing resources
Yes, PHP is very cool, and handles memory management for you. mySQL resultsets and connections are cleaned up once the page has finished executing (is in manual). The reason why you would want to use these functions is if you have a script that does not finish (such as one that handles port access from the command line). Adam
Re: [PHP-DB] full text search and how to underline keyword in results
The first argument passed to eregi_replace is " ".$keywords[$i]." " You are concatenating the string and a space on the end and front. This was obviously used as a hack to make sure only full words were highlighted. A fix for this? A simple hack would be to take out the spaces, so it is simply $keywords[$i], although you could figure out a proper regex if you don't want partial words higlighted. Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Date Subtraction
Use getdate() with mktime() and this is your solution. http://www.php.net/manual/en/function.getdate.php http://www.php.net/manual/en/function.mktime.php Adam
[PHP-DB] Re: undefined variable? how could it be?
You have error reporting set to a value other than 0. Use this function at the top of your script (or change the values in php.ini). error_reporting(0); For more reference: http://www.php.net/manual/en/features.error-handling.php http://www.php.net/manual/en/function.error-reporting.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Need Advice on Installing PHP & MySQL on Mac OSX
You need to uncomment two lines in the httpd.conf file then restart apache there are many places on the internet where it shows which lines (you could do it yaself, it has php4 in the lines) also, make sure apache is turned on, you can do this inside system preferences apple has some good info on their ste http://developer.apple.com/internet/macosx/php.html Adam
[PHP-DB] Re: Multiple select ?
Try using parentheses inside your sql: Select * from table_name where (col1=1 OR col2=1) and col3=0 Select * from table_name where col1=1 OR (col2=1 and col3=0) They make a big difference, also helps to indentify what you're selecting when you come back to the sql later. Adam
[PHP-DB] Re: adding a space in mysql
I think the other replies to this are missing the point. You want to search a text field for the word Wash, and want to put the space in so you can search with the space, eliminating words which begin with wash. But then, if you think about it, that means you'd have to search for commas, and full stops. I don't think this is such a good way to do it. Try using regular expressions. I have never used regex on a db before, but I have seen a few people mention it. Have a go and if you find a solution, post it. Adam --- Original Message --- How can I add a space to the end of a varchar string in mysql? I can't seem to do it directly, and I tried str_pad and other things, but no luck so far. The db doesnt hold the value of the space...its getting trimmed somewhere(?) The reason I want to do this is so I can search for exact matches on one word strings without stemming: ...WHERE name LIKE '$var %'. If the user types 'Wash' I don't want any matches for 'Washington', 'Washing', etc. Thank You All
[PHP-DB] Benefits of assigning query to variable
Yes, I see a few benefits. 1. It makes the code easier to read. 2. It makes the code easier to debug. Imagine the following: $sql = "SELECT * FROM tblName"; $result = mysql_query($sql); Now if you want to print the sql and not do the select, you would simply add a line $sql = "SELECT * FROM tblName"; test($sql); $result = mysql_query($sql); where the function "test" is: function test($var){ echo $var; exit(); } The benefits are more evident when you have bigger sql queries, such as: $sql = "INSERT INTO tblName SET field1 = 'something1', field2 = 'something2', field3 = 'something3', field4 = 'something4'"; $result = mysql_query($sql); Hope that answers your question. Adam
[PHP-DB] Re: Auto Increment Problems....
Firstly, don't cross post unless the question *really* has to do with both (in this case, it should be just db). Secondly, your id field should only be used as a reference to a row (not showing order of record). Auto increments are exactly that, the rdbms will take care of creating the increment. eg. you have this table tblName ID | field1 | field2 Your insert sql should be something like this: INSERT INTO tblName VALUES ('','value1', 'value2') OR INSERT INTO tblName SET field1 = 'value1', field2 = 'value2' The reason why the 'hole' is there, is to maintain data integrity. Say you have two tables and they relate to each other (through the id). If you delete a record from one and it relates to something in the other table, if you add a new record using the old id, it will join with the second table, when it shouldn't. Confusing? yeah its just cause i can't explain it right. If you want to use numbering for your records, create it dynamically when you display the data. Adam --- Original Message --- rite, my primary key column ("id") is set to auto_increment as usual which is very handy. But when I delete a row, the auto_increment just keeps incrementing and there's this 'hole' left where I deleted the row! Apart from this looking ugly, it poses another problem. In my PHP script where I can add new rows, I query the table, checking how many rows in the table altogether and set the new id as the next number, but this doesnt work if theres 'holes' in the id field, as the new record tries to overwrite another id. So I've 2 questions 1) Can the next auto_increment value be 'set' by a SQL query 2) Can I get a SQL query to INSERT INTO the first 'hole' it finds in the ID column?? TIA
[PHP-DB] Re: Pulling a data from array of checkboxes
This is friendlier, cleaner and faster way to return the results. $chk = implode(", ", $chk); $sql = "SELECT field1, field2 FROM tblName WHERE ID IN ($chk) ORDER BY ID"; this should bring back all the records within one resultset, which is easier to manage Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: php and javascript?
Just reiterating over what the others have said (plus expanding), and just a bit cleaner. HTH, Adam. > Hi, > > Here is what I wanted to achieve, I want to get a confirmation box pop > up > when user click on the delete link of the webpage(displays the contents > got > from mysql database). I know we can do it in javascript easily, but my > question is: > 1st, > a common javascript confirmation will be like this: > > > > New Page > > my question is how to integrate the javascript with php, the sample > delete > link will be something like: http://localhost/index.php?id=1 ,and the id > number(in this case:1) is from database: ( href=delete.php?".$row["id"].">) > > 2nd is there a better way to write pure php code to get a confirm > window pop > up once i clicked on delete link? > > Thanks and Good day. > > Bo
[PHP-DB] To Bo
Study these two parts in the manual, and you will know how to do everything you've mentioned (and more). http://www.php.net/manual/en/ref.strings.php http://www.php.net/manual/en/ref.array.php Adam
[PHP-DB] Re: Construct, Q+E, QBE
This sounds very interesting. As far as I know, there are no automatic functions to do this, although i don't think it would be too hard to write the php function to do this. If end up finding a solution, please email it to me (and the list), or if you need a hand in writing it, I'd be happy to help. Adam
[PHP-DB] Re: HELP NEEDED
First of all, you are not using the variable when you are passing it to the sql string. Second, you are doing a pointless var check, and thirdly, your condition statement is flawed. 1. SQL should be (if you have register globals turned on, otherwise you must use $_GET['_Name1'] ): $_query = " select userName from users where userName='$_Name1' "; 2. mysql_query returns a result identifier - not the actual results. You should use mysql_num_rows() to find out if any rows were returned (or use the other mySQL functions to retrieve the actual data): $numRows = mysql_num_rows($_result); 3. Print the value of $numRows, without doing a check: echo $numRows; 4. In your IF statement, the equal comparison operator should be '==' (otherwise you are assigning the value to the variable). What you also could choose to do, is to leave out the comparison like so: if ( $_result ) // 0 = false, 1 = true; { echo "Name was found in the database"; } else { echo "Name was NOT found in the database"; } Hope that helps.. Adam > Hi there > I am having a problem querrying to my database. > I wish to check to see if a username is listed in the database so that > I can > authenticate that individual. However, when I try to echo my $_result > i'm > always getting 0 can someone please help. I think it should be either 1 > or > 0. > > These are my scripts. > > This is my login pagepage > echo ""; >echo ""; > echo ""; >echo ""; > echo ""; > echo ""; > echo ""; > echo ""; >echo ""; > echo ""; >echo ""; > echo "" > ?> > > This is my script processor > file://Script processor > mysql_connect("localhost", "nik", "playas") or > die("Could not connect to the server"); > > mysql_select_db("chronicleOnline") or > die("Could not connect to the database"); > > $_query = " select userName from users where userName='_Name1' "; > > $_result = mysql_query($_query) or > die(mysql_error()); > > if ( $_result = 0 ) > { > echo "$_result"; > } > else > { >echo "$_result"; > } > ?> > > P.S. I have no problem putting the data into the database, just this > query. > > Thx > Nik
RE: [PHP-DB] A Simple Question
Just a correction you can use arrays with querystrings page.php?var1[]=first&var1[]=second&var1[]=third $var1 Array ( [0] => first [1] => second [2] => third ) OR page.php?var1[]=first&var2[2]=second&var2[]=third $var 1 Array ( [0] => first ) $var2 Array ( [2] => second [3] => third ) You can also have multidimensional arrays, but not associative arrays. But you do have the 255 character limitation (can be a bummer). Adam > Also, as far as limitations go, the following are considerations; > > 1. You can't pass an array using the querystring > 2. Multiline variables (ie. contents) are bad > 3. There is a limit of 255 or something characters to a URI (someone?) > 4. Be careful with the $_GET[] array that Tony mentions, it is only > available on more recent versions of PHP, before that it was > $HTTP_GET_VARS > and a lot of people had been using just plain $var1 or whatever, > assuming > that "register_globals" would always be ON in the php.ini file (which > also > changed in recent versions). > > HTH > > Beau
[PHP-DB] Re: Urent please
Simply open the javascript window with a querystring.. so you have some like this in your javascript code: window.open("somepage.php?var1=value1&var2=value2","theWindow","width=200, height=300"); and if the variables are inside php... use something like this: window.open("somepage.php?var1=&var2=","theWindow","width=200,height=300"); adam > maybe this is more a javescripy problem...but its related to my php > code: > how can i open a new window with javacript and pass to it php > variables?? > thanks guys alot. > > > Rehab M.Shouman -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Refresh after DB Query
Sorry if you are a newbie.. but if might help if you delete the records before you select them to display in html ie: put the delete query at the top of the page, just after this line: require ("templates/db_connect.php"); adam
[PHP-DB] Re: delete multiple records with one query
another way to do this is (quicker, using only one query): $delete_IDs = implode(",",$name_array); $sql = "DELETE FROM $mysql_table WHERE id IN ($delete_IDs)"; mysql_query($sql); or you could delete the first line (implode) and take the square brackets out of the name of the form field. this will make a comma-delimited string of all your selected ID numbers, and will be available in $name_array your choice adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: remove from db renumbering
You should not rely on the autonumber as a sorting method. You should use it as a reference. I see you have two easy options (there may be more, but this seems suitable). 1. Get the SQL to pull a random record (requires mySQL 3.23.x or higher) SELECT * FROM tblName ORDER BY RAND() LIMIT 1 2. Get all of the ID numbers into an array and pick a random value, then retrieve the rest of the details using the row ID you picked from the array. Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Form not working...
What you said (Mike) is mostly correct, although the GetSQLValueString() function in Scott's code automatically puts the quotes around the values if the datatype definition of "text" is passed to the function. Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: getting the value of a javascript variable
Hi Hermann, This has been covered many times on this list, but the basics are this: PHP retrieves all information and outputs it into a javascript array - this way all combinations are available to javascript. Then when the user selects a list from the menu, javascript determines the contents of the second drop-down box. There are a few examples around on the net - Google is your friend. Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Populating multi-select list from mysql
Hi Bob, I have written some functions which make select lists much easier. I have two functions: - BuildQuickSelect() - you pass a couple of parameters (tablename, etc) - BuildSelectMenu() - you pass $sql and some more parameters Unfortunately, they require a few things (such as other functions I have written). Fortunately, I have them all in one lib.php file, and you are welcome to use it. I think you will find it very handy and time-saving. I COULDN'T do without them. Look through the whole file, and you might see some other handy ones in there too. There are four variables at the top of the lib.php file, which you must set according to your server setup (server, username, password, etc). To use the stuff, simply include() it at the top of each page. And to solve your problem (using the lib.php file), all you have to do is this: BuildQuickSelect("category_list_array[]","categories","","multiple size=10"); And voila... all is done... Need any help... ask Oh yeah, btw everyone else, I have emailed the lib.php file to Bob - if you want a copy, email me. Adam lib.php.zip Description: Zip archive -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Converting values from text to numerical
Hi Matt, I think this might be the answer to your problem. It basically checks if the string is an integer. I generally love the PHP automatic type conversion, but sometimes it can trick ya :) if (intval($val) == $val){ // integer stuff } else { // string stuff } Adam > Hi Russ, > > thanks for the reply ... if that will evaluate whether a (in this > case) a > text string is an integer or not, then its exactly what I need! :) > > if it doesnt work, I will post a more detailed example to the list and > see > what we can come up with! :) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Having trouble understanding how to manage arrays
Hi Bill, Looks like you're making it hard for yourself, by querying the database for each record found. Here is some code which should make your life easier. Of course, I have developed functions which would turn the following code into 10 or so lines, but this should work for your situation. Adam ">
[PHP-DB] Re: SQL Troubles with JOIN, GROUP BY and MAX???
I think this is something like you would want... Adam SELECT users.id, username, MAX(stamp) as stamp, filename FROM users, files WHERE users.id = userid GROUP BY username -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] sql and week starting ending numbers (dates)
Hello all, I am creating a finance manager in php and mysql for my own accounting purposes (and to broaden my skills in php and sql) and I have a couple of pages where I view statistics on how much I spend, etc, and what patterns are formed from my spending. I have made a couple of pages with different statistics, and on one specific page, I show how much I spend total each week... The following query does that, but I want to display the start date and end date of the week. $sql = "SELECT YEARWEEK(purchaseDate,1) AS week, CONCAT_WS(' ',MONTHNAME(purchaseDate), YEAR(purchaseDate),'- Wk', WEEK(purchaseDate,1)) AS month, SUM(itemPrice) AS total FROM tblCashflow WHERE userID_FK = ${user['userID']} AND Type = 'Expenditure' GROUP BY week"; OK, so the sql works, and the output on the page looks like something below... February 2002 - Wk 5$49.70 February 2002 - Wk 7$12.95 February 2002 - Wk 8$53.29 February 2002 - Wk 9$275.99 March 2002 - Wk 10 $78.95 March 2002 - Wk 11 $171.15 March 2002 - Wk 12 $82.85 March 2002 - Wk 13 $20.50 April 2002 - Wk 14 $55.15 April 2002 - Wk 15 $30.55 April 2002 - Wk 16 $104.20 April 2002 - Wk 17 $461.95 May 2002 - Wk 18$152.75 May 2002 - Wk 19$219.80 May 2002 - Wk 20$133.55 May 2002 - Wk 21$98.65 Now thats all well and good, but I want to make it display something like the following: February 1 - 7 2002 $49.70 February 8 - 15 2002$12.95 February 16 - 23 2002 $53.29 etc etc etc Does anyone have any idea on how this could be achieved? I looked at the mySQL time and Date functions, but I couldn't find out how to do it with that, and I think doing the work in PHP might be the answer Also, currently the SQL statement only shows the weeks where I have spent money, so if I don't spend anything in that week, it won't show up at all, although I would like it to say "January 12 - 19 2002 $0" or something like that. Below is my table schema for the above query Adam CREATE TABLE tblCashflow ( ID bigint(20) NOT NULL auto_increment, purchaseDate date default NULL, categoryID_FK tinyint(4) default NULL, itemName text, itemPrice float default '0', isEssential tinyint(4) default '0', paymentTypeID_FK tinyint(4) default '1', receiverID_FK tinyint(4) default NULL, itemDesc text, Type text, userID_FK int(11) default NULL, PRIMARY KEY (ID) ); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] new pair of eyes
Hey there, I was just looking at your code, and I also look at other's code, and I think people are making life difficult for themselves. Sure a lot of people on this list are beginners, but thats more te reason to simplify code... One thing you should always do, is write functions... I have written a few functions to connect to a database, execute queries and return results, and insert and update queries. Using functions like these make it a lot easier to write working code, and because it's less typing, its a lesser chance of an error occurring... for example... here is a portion of my lib.php which I include() on each page I create (some comments are removed to save space) putting the below code into an external file and including it on every page makes everything a lot cleaner, and if you need to connect to a database, just call dbConnect(); in your php script... you must make sure that in the external file, the constants are set with your server details... or you can do it in the actual page with the function, like so: dbConnect("dbname","localhost","username","password"); and if you need the connection ID, it is in the variable $DB_CONN. If you want some more functions like this (i have a few more called getData(), dbInsert(), dbUpdate() which all make it a LOT easier to transport data to and from a mysql database), email me and I will send them to you directly. If you don't run mySQL, then you can just modify the functions to suit your DB, or you can add and delete things inside the functions for your own setup. Adam / DEFINE CONSTANTS / // Connecting to a database define( "DB_SERVER" , "localhost" ); // used for dbConnect() define( "DB_USERNAME" , "username" ); // used for dbConnect() define( "DB_PASSWORD" , "password" ); // used for dbConnect() define( "DB_DATABASE" , "dbname" ); // used for dbConnect() / DATABASE FUNCTIONS / function dbConnect($dbDatabase=DB_DATABASE, $dbServer=DB_SERVER, $dbUsername=DB_USERNAME, $dbPassword=DB_PASSWORD){ global $DB_CONN; $DB_CONN = @mysql_connect($dbServer, $dbUsername, $dbPassword) or die("Couldn't connect to database server."); $db = @mysql_select_db($dbDatabase) or die("Couldn't select database."); return $DB_CONN; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: db sql issue from var
Hi Dave, Load the data from the text file into a variable (eg, $fileContents) Then split the file into an array and run every sql statement. The following code should work... Adam $arrSQL = explode(";",$fileContents); for ($i=0;$i
[PHP-DB] Re: Adding totals
This should be it (if I am understanding you correctly). Adam $strSQL = "SELECT SUM(columnName) as sum FROM tblName"; $result = mysql_query($strSQL); while ($row = mysql_fetch_array($result)){ $total = $row["sum"]; } Hi all, Is there a way for me in PHP4 to add all the contens (floating numbers) = of a cartain column whithin a row and show up the result? I have several = time inputs and need to show the total. Thanx. Cesar Aracena [EMAIL PROTECTED] Neuquen, Argentina
[PHP-DB] Re: query
Not sure if you received this previously. Try this query below. Adam. $query = mysql_query("SELECT * from 150bk where Signature like '%1' and 150bk.ID ='$rec_id' limit 1");
[PHP-DB] Re: Upcoming event script
Should be something like so... "SELECT text FROM events WHERE date < now() SORT BY date DESC LIMIT 1" That should work. Adam
[PHP-DB] PHP tips to make your life easier
Hello everybody, There are some techniques which I use that come in REALLY handy when writing PHP (or even ASP). I will just go through them here briefly. Any questions? Email me. 1. Keep a php file (lib.php) inside a 'code' folder in a directory for every site you work on (depending on security needs, you might want to keep it out oft he web directory). In this file, keep your functions that you are likely to use again and again. In mine, I keep my database connection and query functions, and all the other string/array functions I create. Your pages become cleaner and to start a new page, all you have to type is the following: 2. Try to use functions (and classes) to your advantage. Write them. I have written a few to make my life easier. // Open a database connection dbConnect(); // select and put into 2d associative array $sql = "SELECT * FROM tblTable"; $data = getData($sql, ASSOC); If you want to use these functions, send me an email and I will send them to you. They are very flexible (although they are only mySQL compatible). Here are some functions that I wrote when I first started using PHP: // if you want to quickly test a variable (such as an sql statement) chuck this in... saves time. test($sql); function test($str){ echo $str; exit(); } // Useful for: printing arrays and seeing their structure preformatted from php // Example: /* plainText(); print_r($array); */ function plainText(){ header ("Content-Type: text/plain"); } // Useful for: sending someone back to the last page they were on // Usage: goBack(); function goBack(){ header ("Location: $HTTP_REFERER"); exit; } // Useful for: quick redirection to another page // Usage: go("url.php"); function go($URL){ header ("Location: $URL"); exit(); } So you see, these functions aren't big, and they don't have to be, but it cleans things up a bit and makes your code more readable... And as a huge bonus, a lot of your syntax errors/spelling errors are fixed because you don't have to type as much. Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Regular Expressions
Don't complicate your code if you don't need it. IF you need to find out the length of the string, use PHP's built-in functions. They're faster and they are easier to write, debug and for others to understand. If I missed your point completely, forgive me. And here's the code for you do figure out your problem. if (strlen($string) > 20){ print "error"; } else { print "OK"; } Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Pop up are you sure...
Dave, Javascript is client side. PHP is server side. Obviously the limitations imposed by each of the languages is evident. PHP can't do anything once the output is sent to the browser. JavaScript can't do anything before it gets sent to the browser. But, each is important as the other. Learn to use both (its not that hard) and it will make life a lot easier (and more interesting). Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Advice to PHP beginners
Just some advice... You should use a consistent programming style, especially with PHP. You can read some guys advice here. http://www.phpbuilder.com/columns/tim20010101.php3?page=1 Some of the advantages of having a consistent style, is when you are looking for bugs. If you look over your code and see something unusual, then you can target that area to see if it is the culprit. If you don't have a consistent style, then sometimes that can cause serious heartache, as everything will look unusual. A few issues that trip up most people when beginning to use PHP, is the syntax errors. Usually these arise from quote issues, to semi-colon and brace issues. A lot of this trouble can be avoided (or easily debugged) by simply using tabs to your advantage. Consider the following: Technically I *think* this would be syntactically correct, but if I was looking for a bug, I would be shot in the foot. A better way to write this would be the following: So its a couple more lines, but if I came back to that script a month or two months later trying to fix something, or add a new feature, it would be easy. Couple that style with comments and you're on fire!!! Hope this helps for someone out there... Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Checking for 2 unique row contents
Simple do these checks and you'll be sweet as a nut Adam // you might have this at the top of your form to show the error messages \n"; for($i=0;$i\n"; } echo "\n"; } ?> > Hi all > > > > I am trying to create a registration area that uses a nickname and email > pair. > > > > I need both to be unique. > > > > So how do I that either do not already exist then if unique insert into > db. > > > > So > > if nickname exist then error = "sorry..." > > if email exist then error = "sorry..." > > else must be unique > > insert. > > > > I have been trying for hours know but cant get the twin check to work. > > > > Can get single check to work though. > > > > I thank you in advance for any thoughts or code examples > > > > Dave Carrera > > Php Developer > > http://davecarrera.freelancers.net > > http://www.davecarrera.com
[PHP-DB] Re: PHP/Access problem
SELECT * FROM 'Documents'WHERE (CourseRef='4712' AND Valid_From<=#26/03/2002# AND Valid_Until>=#26/03/2002#) Order by Author,Title should be SELECT * FROM Documents WHERE (CourseRef='4712' AND Valid_From<=#26/03/2002# AND Valid_Until>=#26/03/2002#) Order by Author,Title your table name should not hae single quotes around it... adam
[PHP-DB] Re: If else Question
Maybe I am missing something but it seems you are doing things in a potentially unreliable way. Firstly... your sql statement in create.php $query_update = "INSERT INTO pets (uid) SELECT uid FROM users WHERE uid={$session["uid"]}"; could simply be mysql_query("INSERT INTO pets SET uid = " . $session["uid"]); if you are using php4 session variables, why don't you use $uid as the session, so you would only need --> mysql_query("INSERT INTO pets SET uid = $ID"); Moving on... I don't know why you would create an empty record, and insert data later if it is allowed. Do this: Show Form --> Submit Form --> Check Data Integrity --> Check If Allowed to Insert Record --> Insert Record If anything stuffs up then you don't do the bit following. So it doesn't check data integrity if you haven't submitted the form (obvious) and it doesn't insert the record until it checks the data integrity and if they are allowed to insert the record. Adam. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Again Select then update
In your UPDATE query, should you have a WHERE clause? eg. UPDATE my_items SET name = '$update' WHERE ID = $ID OR do this $update = $name; instead of $update = "$name"; Try running the query on the command line (on *nix) or through phpmyAdmin or something to see if the query is actually working. Adam
[PHP-DB] Re: urgent guys
You cannot use javascript variables in php, nor php variables in javascript, unless you write the variable to the page (for php -> javascript) or post to a new page with querystring or form (javascript -> php). php -> javascript: var jsVariable = "= $phpVariable ?>"; javascript -> php: // this is probably wrong javascript syntax, but you get the idea location.href = "thing.php?q=first+one&p=second+one"; Adam > i know it has nothing to do with php but i'm stuck:) > > i have this url: > http://localhost/auction/seller/additems.php?category=Books&subcategory=Fiction > > and in javascript when i say for example alert(category) it gives me > undefineddoesn't javascript see variables passed with the url??? > > > Rehab M.Shouman
Re: [PHP-DB] "marking" DB entries...
I have done an address book in php, although I kept the username/password in with the rest of their details. If you wanted to keep it all in two tables, then go ahead. You really should have an ID field in every table, whether you use it or not, and most of the times, you'll find you will use it. So if you're using two tables, you'll have a column in each of them 'linking' up the columns (ie, the same number). If you don't know how to do this, there are tons of tutorials on the net which gloss over this... (have a look at the mysql documentation/examples). Then on your actual page, what you should do is have a login page, which checks a username/password from a form against the database. At the same time, retrieve the ID number where it matches the user/name password and put the username and id number in separate session variables. Once you have the ID number of the person logged in, you can allow/disallow what they can edit depending on the ID. If you need further help, contact me directly. Adam. > Im making an address book using PHP and mySQL. > I want each user to have access only to his/hers adressinputs. Now Im > wondering how I gonna solve this, ofcourse its very easy just to > create a > table for each user but then the hole idea of "database" loose its > purpose > =). How can I "mark" each input so that only the specific user who > entered > the information can access it? If two users enters the exact same > information I want them both to have access to it... > > I was thinking about a table looking like this: > name CHAR(30), > adress CHAR(30), > email CHAR(30), > phonenumber INT(20), > authority ENUM()//here is my thought-- > > I was thinking I could save the users name in "authority" and thereby > marking that this entry was made bye the specific person. Is it possible > to > use this? Please give me a few pointers or better, give me a website > where > I > can read about it... > thanks! > /Ljungan
[PHP-DB] Re: insert into javascript php
PHP cannot recognise javascript variables because javascript is interpreted via the browser, and not the server (which php is). for php to use javascript variables, you must post the variable to another page using either a form or querystring. Adam > > > c=document.forms[0].category.options[document.forms[0].category.selectedIndex] > .text > $x=c; > ?> > > > > but the php doesn't understand this c variable -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Output of curl to an array.
Hi Keith, I read your post and decided to write a function for you. Basically what it does is does, is take in a string, and optional newline and value separators, and outputs an associative array. It actually works, and has a few comments... so yeah, enjoy.. and thanks for the challenge : ) Adam You can use it like so... PHP Script (of course, you must either have the function on the same page or include() it like so): Output: Array ( [Name1] => Value1 [Name2] => Value 2 [Name 3] => Value 3 ) //=> extractPairs.php ""); } // gets rid of newlines/spaces etc so we don't get a crap array $strText = trim($strText); // separate each line in an element in an array $arrLines = explode($strNewlineSeparator,$strText); // loop through $arrLines, separating the names/values and placing them in $arrOutput for ($i=0;$i > Ok, lets say I have some code here: > > $result = array(); > > $ch = curl_init ("https://www.myverificationplace.com/verify.asp";); > > curl_setopt ($ch, CURLOPT_POST, 1); > curl_setopt ($ch, CURLOPT_POSTFIELDS, $args); > curl_setopt ($ch, CURLOPT_TIMEOUT, 120); // Set the timeout, in seconds. > curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); > $result = curl_exec ($ch); > > curl_close ($ch); > > Now that we see that, how can I make it so that the output from curl, > which > is in the variable $result, will be an array, for each line of output? > > Some of the line of output looks like this: > > ssl_result_message=APPROVED > ssl_txn_id=---- > ssl_approval_code=00 > > I need each of the lines to be turned into a variable. Any ideas as to > how I > might go about this? > > Thanks, > > Keith Posehn
[PHP-DB] RE: login
If the variable $SCRIPT_NAME does not suit your needs, try the other environment variables here: http://www.php.net/manual/en/language.variables.predefined.php Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: login
I have not tested this but it should work... Adam this goes in the form area on login.php -Original Message- From: its me [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 4:27 PM To: [EMAIL PROTECTED] Subject: login there is a page that when user go to need to be looged in,so it automaticaly go back with him to loggin page but after login i want him to go back to the page he was in.how? using history()? and how. thanks guys Rehab M.Shouman - Express yourself with a super cool email address from BigMailBox.com. Hundreds of choices. It's free! http://www.bigmailbox.com - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Question about advanced SQL
Hi. I need some guidance for writing an effective query (instead of processing through PHP). I lets says I have two tables, tblCDs and tblOrders. tblCD cdID| cdTitle | cdArtist -- 1 | Great Hits | Bon Jovi 2 | Forever Young| The Youngsters 3 | Now and Then | Beach Boys 4 | Cheesy Name | Two Tones tblOrders orderID | cdID_FK | ordererID -- 1 | 1| 442 2 | 3| 233 3 | 1| 233 Now, I want to select all the records from tblCD where the cdID does not appear in any row of tblOrders.cdID_FK This means that it selects all the CDs that have not been ordered. The results of the query should be cdID| cdTitle | cdArtist -- 2 | Forever Young| The Youngsters 4 | Cheesy Name | Two Tones I know how I can do this in PHP (two queries - put all cdID_FK in an array, and on displaying the other query, check if it is in the array, and display if not) but there HAS to be an easier way. Adam. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] "The" Debacle
To make sure that other names are not interfered with, I would refine what you're doing. ie. "Theater Nuts" would become "ater Nuts, The" obviously this is not acceptable... so you would do something like this... //does it begin with 'The '? $name_start = substr($band_name, 0, 3) if ($name_start=="The ") { //remove the word 'The' and following space from the beginning of the string $band_name = str_replace('The ', '', $band_name) ; // add ', The ' to the end of the name $band_name .= ", The"; } > When you add the data > > //does it begin with 'The '? > $name_start = substr($band_name, 0, 2) > > if ($name_start=="The") > { > //remove the word 'The' and following space from the beginning of the > string > str_replace('The ', '', $band_name) ; > > //add ', The 'to the end of the name > $band_name=$band_name.', The'; > } > > You might want something more sophisticated if The with a capital is > found > in the middle of names, but hope this is a start > > > Peter
[PHP-DB] Re: Special Insertion Into MySQL - at a loss!
The following code is how you should retrieve the data from mySQL... if you wanted to update all of the information through one button, though, I would do it in a slightly different way... Cancel This Domain? as long as all these are from the same table... the update is easy... I recently did the same thing with ASP (and I wish we had PHP at work), but I don't have it here at home. It was slightly more complicated, in the way that each value relating to each row presented to the user had to be put into different tables according to the values. with the HTML form, you would put the fields like this (formatted without HTML for ease of viewing) this method is for updating only one table // start row "> "> "> // end row so basically you get the idea... what happens here is all the values are put into their respective arrays (when submitting the form) and you loop through the arrays on the next page on an insert query... like so... all the above could should work, although its untested things to watch out for is making sure you have single quotes around the text fields but none around the ID (which should be a number) if you have multiple tables to update, mail me and I'll tell you how to do that... its late and I don't want to explain unless u need it... also, I would probably also have a good look at how you are presenting the form to the user. my example might not be how you want it to look, but i think its the data transfer that you were worried about... any questions about the code?? just ask... Adam >I have a special set of information retrieved from a while loop that I would >like a person to be able to edit and send back into a MySQL table. > >I know all of the basic MySQL commands for doing such, but the PHP side to >get the input from the form to go in is really stumping me. > >This is what I have: > >- > >$or = 0; > >while($or < $orderidrows) { > > $orderinfo = mysql_fetch_row($orderidinfo); > $domain[$or] = $orderinfo[2]; > $cancel[$or] = $orderinfo[3]; > > print "face=Arial>$domain[$or]size=2 face=Arial>Cancel This Domain?face=Arial>size=3>"; > > $or++; > } > >-- > >The values I would normally insert into the MySQL from the form would be >$confirm - however, in this case, I have a number of rows with the same >name. How do I distinguish one from another? The [$or] doesn't work to do >it (didn't think it would). > >Thanks for any help! > >-Mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Session confusion :-(
I presume that the session is not updating because PHP does not automatically overwrite session variables. You should use something like this: $category = $HTTP_GET_VARS["category"]; session_register("category"); Session register can be called more than once, and has no effect on current session variables with the same name. See if that works, and if it doesn't have a look at this... http://www.php.net/manual/en/language.variables.predefined.php Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Getting days after last login. Date problem
Hey there... Sometimes it is easier to store the date as a unix timestamp (seconds since midnight 1/1/1970) cause it allows you to format the date any way you want, and php has cool date and time functions which rely on a timestamp. A time stamp example is like this: Formatted date: " . date("j/m/Y",$time); ?> would produce something like: Timestamp: 1013605509 Formatted date: 13/02/2002 and then you can store the value of $timestamp in a database and calculate the formatted string later... Adam > Hi there, > > I would like to find out the changes on content after a members last > login. > > The format of the date stored in the member db is e.g.: Feb 13, 2002 > The format of e.g pictures uploaded is: > 2000-02-13 > > How can I search for pictures which are uploaded since the members last > login. Is ist possible to convert the memberdate format to the other > one and > just search for something like picturedate > logindate? > > Thanx for any help > > Andy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: Outputing Distinct rows
What you *should* do is have a lastUpdated field in your posts table, and the value inserted into their is the date when you update it. Then your query would be like $sql = "SELECT posts.topic_id, posts.forum_id, topics.topic_title, topics.topic_replies WHERE topics.topic_id = posts.topic_id ORDER BY posts.lastUpdated DESC LIMIT 10"; Also, this would allow for extra things in the future, such as a page showing all updates in a certain day, or within last 3 days, or something like that. Hope this helps. Adam -Original Message- From: KingZeus [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 10, 2002 1:36 PM To: [EMAIL PROTECTED] Subject: Outputing Distinct rows I'll give you all the short version of what I need and if it is enough for you to help that would be great. I need to pull the last 10 updated topics from a table and output them. However, the posts table lists each post and then has a topic id. There is also a table of topics with topic id, title, etc. I cannot just pull the last 10 posts in the post table because those posts could all be for the same topic and I'm trying to output the last 10 updated topics (not posts). How can I do this? I can't find anything on the subject. This is what I tried as a random guess: $sql = "SELECT DISTINCT posts.topic_id, posts.forum_id, topics.topic_title, topics.topic_replies WHERE topics.topic_id = posts.topic_id DESC LIMIT 10"; Any ideas about what I need to do? I'm sure it is pretty simple. Regards, Steve "KingZeus" Downs Co-Webmaster: http://www.cncrenegade.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: option in forms
I think this is what you're getting at: "> or something like that so it would look like (in HTML) Artist's Name First in list Artist's Name second in list Artist's Name third in list if you select the first item in the list, the next page will produce: $artistID = "23" so yah... thats it ---____-_--_-_-_-_-___-___--_-_-_-_-- I know how to do the option call e.g. This is the list of artists already in our database : But I want to do a form where they select the option then fill out rest of form. The option above returns the artist name, but I want to insert the artistid. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Counting db generate links
You use a link management system. You can find examples of these all around the web, but I know you can get some at http://www.hotscripts.com They are also probably more complex and flexible than what i describe below. Basically what it does (you could even write it yourself) is this: 1. All links point to a redirect.php script with a URL like the following. - eg.1.http://www.domain.com/redirect.php?URL=http://www.otherdomain.com/place. htm OR - eg.2 http://www.domain.com/redirect.php?link=432 Depending on which way you choose, the link=432 will search a database with link 432 and send the user to that appropriate page. 2. To redirect the user (for eg.1) all is needed is redirect.php to contain the following code - eg. - before this line is called however you need to insert the url (and maybe date/time/referring page etc aswell) into the database. 3. When you want to display the data, all you need to do is filter the results and sum up the totals as necessary. If you store the code the following way it seems much more flexible. 3/12/02 5:36PM http://www.domain.com/ http://www.referringdomain.com/page.htm 3/12/02 8:44PM http://www.domain2.co.uk/place.htm http://www.referringdomain. com/page2.htm 3/13/02 7:26AM http://www.domain.com/ http://www.referringdomain.com/page.htm Cause you only have to do one sql statement (a quick insert, rather than a select and update, etc) and then you can collate all data on a different page, and provide comprehensive results. Another link system (like eg.2 up above) would involve the database a lot more, by connecting to the database and selecting certain links, then updating, etc. this is would be good if you were storing addresses (like downloadable things, eg PDFs or scripts, etc) cause then it really is a link MANAGEMENT system, and not just a link stat counter Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: FIle Uploading to database
You missed the SET parameter in your query... example is below... $query = "INSERT INTO Canidate SET (FirstName, LastName, Indus... Adam -Original Message- From: Todd Williamsen [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 11:06 AM To: [EMAIL PROTECTED] Subject: Re: FIle Uploading to database Well... thanks to Dan Burner for the script... BUT I cannot get this friggin INSERT statement to execute.. which craps out.. I cannot figure it out. I have been staring at it for about an hour and I still cannot figure it out here it is: $db = @mysql_select_db($db_name, $connection) or die("Could not select database"); $query = "INSERT INTO Canidate(FirstName, LastName, Industry, Address1, Address2, City, State, Zip, LocationPref, Phone, Email, ResumeUp) VALUES ('$FirstName', '$LastName', '$Industry' '$Address1', 'Address2', '$City', '$State', '$Zip', '$LocationPref', '$Phone', '$Email', '$ResumeUp2')"; $result = @mysql_query($query, $connection) or die("could not execute query"); $pat = array("#", "@", "*", "&", "%", "@","$","'","`"); $w= '_'; $ResumeUp2 = str_replace ($pat, $w, stripslashes($ResumeUp)); exec("cp '$ResumeUp' '/resumes/$ResumeUp2'"); ?> it errors out on the $result "could not execute query" Let me know if you need more info! Thank you! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: ensuring unique field value in MySQL using PHP
Checking a small database for username/password combination would happen so quick, it would be nearly impossible for two usernames to be entered in. Your script should work properly, but to make sure no duplicates are entered, you can change the column definition using the "ALTER columnName" command to make sure there are no duplicates. Look in the mySQL documentation (www.mysql.com) to find the correct command. Adam -Original Message- From: Janet Valade [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 1:24 PM To: [EMAIL PROTECTED] Subject: ensuring unique field value in MySQL using PHP I have a form in which users create their own login name. The code for storing the login name they created does something like the following: $userlogin is the name the user typed in the form $sql = "select loginname from login where loginname='$userlogin'"; $result=mysql_query($sql); $num=mysql_num_rows($result); if ($num > 0) { echo "Sorry, that login name is already taken, Try another"; shows form again; } else insert new record into database; echo "okay, your new account is added"; I am wondering if it is possible that two people could hit the submit button at the exact same time with the same login name so that the same login name could get entered twice? Seems unlikely that this would happen by accident, but is this something a hacker could do on purpose? Thanks, Janet -- 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]
[PHP-DB] RE: MySQL Update help needed
A few things to check: 1. You have a connection to the database (I'm assuming you do). 2. mysql_query() is a php function so you should not put a dollar sign before it (indicating it is a variable. If you want mysql_query() to return a variable, do something like this: $result = mysql_query("UPDATE etc"); 3. Check that you field names are the same, they are case sensitive (I'm pretty sure). 4. If all that doesn't work, try setting the query out in a logical pattern. This way it is easy to find mistakes. ie. $sql = UPDATE search6 SET email = $email, description = $comments, etc region = $region WHERE id = $id); -Original Message- From: Chris Payne [mailto:[EMAIL PROTECTED]] Sent: Monday, January 21, 2002 3:18 PM To: [EMAIL PROTECTED] Subject: MySQL Update help needed Hi there, Can anyone see what is wrong with this query? I am trying to update some fields, if I do an echo everything looks good but it doesn't update the fields in the DB - am I missing something obvious here? Thanks for your help Chris www.planetoxygene.com $mysql_query ("UPDATE search6 SET email = '$email',description = '$comments',category = '$category',url = '$url',type = '$type',country = '$country',rating = '$rating',fname = '$fname',state = '$state',region = '$region',city = '$city' WHERE id = '$id'"); -- 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]
[PHP-DB] RE: Recalculation ?
You shouldn't need to unset session variables if you're going to use them again, just write over them. And to check if a session variable has been used or not, you can use: if (session_is_registered($qty)){ calcluation in here } If the calculation part is the same in your 'if' statement, then you should need to do the session_unset() and session_register() stuff. If $qty is already registered as a session variable, you can safely run session_register($qty) again and cause no harm to the already registered variable, so this will register a session variable, but not change an existing session variable. Also, in logic (I haven't tested though), your condition for your 'if' statement ($qty == $qty) will always evaluate to true. Adam -Original Message- From: Dave Carrera [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 19, 2002 3:17 AM To: php List Subject: Recalculation ? Hi All, I have create a page to calculate qtys and show totals. This works fine, except that I change a qty the change is not registered and calculate from the old value. I am using sessions and have try a loop of if($qty == $qty){ than calc stuff here} else{ session_unset($qty); session_register($qty); calc stuff here } And have tried other ways but to no avail. Can someone throw any light on this. As always any help is appreciated. Dave C -- 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]
[PHP-DB] Authentication
> I have a successful website with authenticatin and logons. There are > sections that I allow anyone to get to, but the others have to be > authenticated. This site is not using frames at all. its a page by > page, > with the unit that does the authentication and sessions being included > in > each page. > > I've taken these same units to another site. I altered the pieces > neccesary > to hit the new sites database and users. This site is using frames. > the > outer frames are not using the authentication or sessions. However, > internal pages do. As I enter a section that needs a logon, it prompts > me. > Then it goes to the correct page. But the next page it goes too, it > wants > to get a logon again. These pages are in a row, and they all use the > same > sessions stuff that the other site uses. I know that they all have to > include the same units, so once it needs to logon, it'll prompt that, > but it > should pass this session info from here to there, and not have to logon > again. Its driving me nuts. > > The only thing I can think of thats different is the frames. I even > took > the same code from the other site ( the one that does work without > frames), > and plugged it in. So the session logon was for the other site and > other > db. It'd prompt me each time too. I am not sure what to do now... > > help please. When I first set up PHP my sessions did not work. What I eventually found was something to do with my php.ini file on how it deals with sessions (ie. where they save them, etc) This is some stuff from my php.ini file which i found useful (and made it work, I think) register_globals = true session.save_path = /tmp session.use_trans_sid = 1 session.auto_start = 1 Some of it might not be the solution but I think the session.save_path directive is what makes it work. For better definition of what these things do, look in the php manual (Chapter 3. Configuration). Hope this helps, Adam. -- 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] Automatic Listboxes
Javascript is your way to do this, but there are obviously a few ways you can do that aswell. You don't want to have to submit a form and reload images/pages etc, so javascript is the only way to go (or dhtml or other stuff) One way to do this is either with layers (hide/unhide depending on what need) and all the information is already printed to the page, but shows only the needed information. Another way is to create javascript arrays and let javascript do the selections and stuff... I've seen a few tutorials around that do that... Here are some links that might help you: This is for dreamweaver and ASP but same principal (and explains how it works aswell) http://www.macromedia.com/support/ultradev/ts/documents/client_dynamic_listb ox.htm This is something similar, and also cool... http://javascript.internet.com/forms/auto-drop-down.html This is a basically what you want... but you might have to modify it a little bit... http://javascript.internet.com/forms/category-selection.html So you get PHP to fill the javascript array by something like this, knowing that I am no genius in javascript (as long as you have values in $array):
[PHP-DB] mail() on Mac OS X
I have been trying for months now (on and off) to get mail() working in OS X. I have trid various things, but this is my current setup. If you have any suggestions or if you could put me in the right direction, then I would be glad. - I am using PHP v4.0.6 on Mac OS X 10.1 (pre-compiled with cool options from entropy.ch) - I installed Communigate Pro (a mail server -- and this works when I use it in Mail.app) - I don't want to use sendmail, I want to use the mail server I have already installed. - I have these two lines in my php.ini SMTP = ifunk.dyndns.org sendmail_from = [EMAIL PROTECTED] my sendmail_path is still the same as default... but I was just thinking that PHP would use my smtp server(ifunk.dyndns.org) Can someone slap me in the face if I'm misunderstanding something, or help me if you can. Thanks, Adam. -- 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]
[PHP-DB] 2D array into mySQL DB
Hi there... I wrote a PHP script which extracts the title and content from all the HTML files in a directory and puts the filename, title and content into a 2 dimensional array. I know the array is fine because when I print it to the page it dislays properly. When I try to input it into the DB I think mySQL chokes. Is there a better way to put contents of an array in a db, or some way to slow down the process? I have tried using insert delayed, and also doing a complex calculation after each insert to keep the php engine thiking but allowing mysql to fix itself, but this does not work. The results I get in the db is muffled and only contains three rows (instead of about 15) and the information is all jumbled aswell. I tried a test line (commented out) and it worked as expected. This is my code. for ($i=0;$ihttp://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]