Re: [PHP] htmlentities()
Chris Shiflett wrote: > View source, and I think you'll understand. Or, remove the call to > htmlentities(). > > Chris .. Thank you all for your assistance. Best... TR ... "...when a browser sees <, it prints out a < character instead of thinking "OK here comes an HTML tag." This is the same idea (but with a differnt syntax) as escaping a " or $ charcater inside a double quoted string..." ~[from Learning PHP5 [O'Reilly] page 102] love sweet tea and rice. & tea\n"; echo $str; echo ""; echo htmlentities($str); ?> // Output in view source code: I love sweet tea and rice. & tea I love sweet tea andrice.& tea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] htmlentities()
Copied and pasted the following sample script from the php manual and this outputs: ... bold"; echo htmlentities($str); ?> .. // outputs: A 'quote' is bold Not sure why the I am still getting the tags and spaces after the call to htmlentities(). Thank you for any help. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] foreach()
Greetings, The following code is from "Learning PHP5 [O'Reilly] on page 90. Example - 6.5: I get a: Warning: Invalid argument supplied for foreach() in c:\apache\htdocs\or_6.4.php on line 15 after submitting the form. I'm not sure why since the example uses the call to foreach() in which the array $lunch is passes through the call to retireve the values of the array Thank you for your help. TR BBQ Pork Bun Chicken Bun Lotus Seed Bun Bean Paste Bun Bird-Nest Bun Selected buns: "; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Does this beginner's book exist?
Chris Lott" <[EMAIL PROTECTED]> wrote in message: > I am looking for a new text for my beginning PHP and MySQL programming > class. This class is for COMPLETE beginners who have never programmed > before. I have used, in the past, PHP4: A Beginner's Guide and PHP for > the World Wide Web (Visual Quicktart). (I will be using PHP4, at > least until the Redhat Enterprise Server upgrades :) > > However, both of these books, while being well pitched towards > beginners, also assume that register_globals is enabled, and while the > former is more like a textbook (it has exercises and mini-quizzes) it > doesn't do as good a job with the examples as the latter (which has > no exercises). My students are distance education students, so little > things like variable scopes can be very time consuming to help them > with-- it would be nice if the text got it right :) > > Does a book for complete beginners exist that also demonstrates basic > good programming practices, has decent examples, and perhaps > exercises/quizzes (not as important as the first two)? > > c > -- > Chris Lott ... Besides Larry's book - which is excellent - try David Sklar's book called "Learning PHP 5" (O'Reilly). Not too much on mySQL with PHP except for chapter 7 _however_ the whole book is grounded in the understanding of PHP syntax and constructs - if/else, loops, arrays, functions - then moves on to databases, cookies/sessions, forms and files. Plus, there are questions at the end of each chapter. Clear, concise and with humor and - if you like Chinese food - mouth watering entrees for the array examples. Both books are very good. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Does this beginner's book exist?
Chris Lott wrote in message: > I am looking for a new text for my beginning PHP...[snipped] ... Besides Larry's book - which is excellent - try David Sklar's book called "Learning PHP 5" (O'Reilly). Not too much on mySQL with PHP except for chapter 7 _however_ the whole book is grounded in the understanding of PHP syntax and constructs - if/else, loops, arrays, functions - then moves on to databases, cookies/sessions, forms and files. Clear, concise and with humor and if you like Chinese food great entrees for the array examples. Both books are very good. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strcasecmp()
.. In strcasecmp() - this comparison will return 0 - interpreted by PHP as FALSE - eventhough words are _equal_ so what will execute is "words are not equal". whereas if the negation symbol of ! is inserted as in: ... ... to read if the comparsion which is returned is not _FALSE_ excecute: "words are equal." . Am I on the right track with this logic? Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_fetch_array()
Thank you Chris. My question was the call to mysql_fetch_array() will also return a result set without the additional argument constant as in: while ($row = mysql_fetch_array($sql)) {... // no constant is being used There are many times that I see that used in textbooks - without the constant - just the variable from the sql query as the argument. TR --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql_fetch_array()
When using mysql_fetch_array() is it necsessary to specify the second argument - meaning the constant of MYSQL_NUM or MYSQL_ASSOC? I have seen many examples where it is left out and it is coded: $row = mysql_fetch_array($sql); as opposed to $row = mysql_fetch_array($sql, MYSQL_BOTH); Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS / eregi_replace()
Justin Patrin <[EMAIL PROTECTED]> wrote in message: > Thanks, lots of good info here. It's nice to have all of the info at once. > > I don't know about eregs myself, but I'll try a preg solution: > > $new_text = preg_replace('!(.*?)!', ' target="_blank">\1', $text); Thank you. I tried the following: http://www.nytimes.com/2004/08/03/national/03tape.html? ex=1249272000&en=484f82ff258ab8c7&ei=5088&partner=rssnyt"; $new_text = preg_replace('!(.*?)!', '\1', $text); echo $new_text; ?> The output in my browser is the URL with no link - and no target="_blank". http://www.nytimes.com/2004/08/03/national/03tape.html? ex=1249272000&en=484f82ff258ab8c7&ei=5088&partner=rssnyt If you get a chance run the script through your server and see. I'm on apache. Any throughts? Many thanks for your time. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RSS / eregi_replace()
Greetings, I'm using an RSS feed from the New York Times and right now the a href link takes the user to the same window. I'd like the link to open in it's own window by using the target .html attribute. I was hoping that I could use the eregi_replace() call by inserting: http://\\0";>target="_blank">\\0 where it matches any character between the string in the URL. However it is not working for me. Viewing the xhtml of thr NY Times feed below, there are many areas of so I'm not sure whether this is the correct way to go. Any leads or assistance will be greatly appreciated. TR .. http://www.nytimes.com/2004/08/03/national/03tape.html? ex=1249272000&en=484f82ff258ab8c7&ei=5088&partner=rssnyt"; // the string URL $pattern = "^(.+)$"; //match any character between the and $replace_pattern= 'http://\\0";>target="_blank">\\0'; $new_string=eregi_replace($pattern,$replace_pattern,$string); echo $new_string; ?> // snippet of NYTimes RSS feed http://www.nytimes.com/2004/08/03/politics/03intel.html?ex=1249272000&; en=e061516bea792668&ei=5088&partner=rssnyt Much of the information that led to the new terror alert was three or four years old, but even the dated evidence was troubling. By DOUGLAS JEHL and DAVID JOHNSTON Tue, 03 Aug 2004 00:00:00 EDT - Tape of Kennedy's Killing Is Getting Digital Analysis http://www.nytimes.com/2004/08/03/national/03tape.html?ex=1249272000&e n=484f82ff258ab8c7&ei=5088&partner=rssnyt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php textbook
Reading "Creating Interactive Websites with PHP and Web Services" (Sybex) by Eric Rosebrock. I've found it a good textbook and wanted to get some feedback from the group about two things I noticed in most of the code throughout the book which has helped me. 1. The author separtares .html form from .php script by using many include() functions for the .html files. I have found that that helps from getting parse errors from the many escaped strings throughout the .html within a .php file if the coder can separate the .html markup from the backend script as much as possible. Kind of like CSS which can separate form from content. 2. The author makes use of many switch() constructs throughout the book as opposed to if / else. He brings in variables from query strings when the user submits the .html form to match the switch() contructs which then decides what action will follow. Anyway, I found the textbook a nice change in the way he presented his scripts and thought others would like to share any feedback if they have read or are reading the book. TIA TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] form textbox with search
Greets, The following code snippet receives data from a textbox named searchtext if the user types in a word. It then tries to match that word from the mysql database using: $searchtext = $_POST['searchtext']; if ($searchtext != '') { // Some search text was specified $where .= " AND blurb LIKE '%$searchtext%'"; } and adding on to the WHERE sql statement. If the user clicks the submit _without_ inserting a word, the whole database is output due to the basic select sql statement of: $select = 'SELECT DISTINCT merch.ID, merch.blurb, merch.price'; $from = ' FROM merch'; $where = ' WHERE 1=1 '; I am trying to work out a way to display a page that might say - "Please enter a word" if the user fails to insert a word in the textbox. Any help greatly appreciated. TR . Click for detailsDescriptionPriceEditDeletePhoto //etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] example from meloni not working
Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] example from meloni not working
Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] example from meloni not working
A basic ht counter script from Meloni's book on mysql (page 318). Not working for me. Every time I load the page the counter stays at zero. Thanks for help. TR .. You have been counted. The current number is . // mysql SCHEMA CREATE TABLE test_track( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, page_name VARCHAR(50), hits INT ); INSERT INTO test_track VALUES(1,'test1',0); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] binary data in php
Marek Kilimajer <[EMAIL PROTECTED]> wrote in message: > You said register globals are off, didn't you? Where is the above > variable set then? > > :) ... That was it. Many thanks Marek and others. Checking through the command line the file was uploaded to mysql database. However when clicking the getdata.php link - the file does not appear on the screen. The code is below. Thank you for your time. TR . //getdata.php "; echo $description.""; } else { @mysql_connect("localhost","root","mypass"); @mysql_select_db("sitename"); $query = "SELECT bin_data,description,filetype FROM binary_data WHERE id=$id"; $result = @mysql_query($query); $data = @mysql_result($result,0,"bin_data"); $description = @mysql_result($result,0,"description"); $type = @mysql_result($result,0,"filetype"); Header( "Content-type: $type"); echo $data.""; echo $description.""; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] binary data in php
"John W. Holmes" <[EMAIL PROTECTED]> wrote in message: > So what's the output? How do you know it's not working? If you're not > getting an error, then your query is running and something is going in > the database. Are you sure the problem isn't in how you're displaying > the data? .. John, I know that there is no binary file upload to the table called binary_data in mysql database since I checked if there was a new entry through the command line after I submit. After I hit submit, the field that I inserted are blank. Any other thoughts? Thank you for your time. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] binary data in php
Lowell Allen <[EMAIL PROTECTED]> wrote in message: > You might try using "$HTTP_POST_FILES" rather than "$_FILES" -- was > necessary in my code recently. > > -- > Lowell Allen ... Lowell, Thank you. I tried that in code below. Still - no dice. Any other thoughts? Best... TR ... This file has the following Database ID: $id"; echo ""; echo "Click to view file"; MYSQL_CLOSE(); } else { // else show the form to submit new data: ?> File Description: File to upload/store in database: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] binary data in php
John W. Holmes <[EMAIL PROTECTED]> wrote in message: > Remember... we're laughing with you, not at you. You forgot to call > mysql_query() in your code. :) . Hmmm... I wish it was as simple as that. I inserted the mysql_query() below but it still doesn't upload the file nor does it throw an error. If you get a chance please take a look and advise. Again, my thanks for your help, TR This file has the following Database ID: $id"; echo ""; echo "Click to view file"; MYSQL_CLOSE(); } else { // else show the form to submit new data: ?> File Description: File to upload/store in database: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] binary data in php
Greets, Register globals are to off - however the files will not upload. At wit's end - help please! Thank all in advance. TR This file has the following Database ID: $id"; echo ""; echo "Click to view file"; MYSQL_CLOSE(); } else { // else show the form to submit new data: ?> File Description: File to upload/store in database: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file upload
In the following snippet, which uploads binary files to a mySQL database it works fine when Register Globals are set to ON. . mysql_connect("localhost","root","pass"); mysql_select_db("adatabase"); $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data))); $result=mysql_query("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) ". "VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data _type')"); $id= mysql_insert_id(); print "This file has the following Database ID: $id"; echo ""; echo "Click to view file"; mysql_close(); ... However, when I turn the Register Globals to OFF and insert a $_FILES[ ][ ] array for the form variables such as: - $data = addslashes(fread(fopen($_FILES[form_data], "r"), filesize($_FILES[form_data]))); and "VALUES ('$_FILES[form_data][form_description]','$_FILES[form_data][data]','$_FILES[ form_data][form_data_name]','$_FILES[form_data][form_data_size]','$_FILES[fo rm_data][form_data_type]')"); - The file does not get uploaded. Any assiatnce will be greatly appreciated. Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: .doc file
Jason Barnett" <[EMAIL PROTECTED]> wrote in message: > Actually, why don't you just use plain text like this. Sheesh, > sometimes I forget the easy answer :) .. Jason, Thanks for the reply. Since those figures change _daily_ on their site, I was hoping for a way to open the file, read it, adjust the format by lopping off the last line into an array and writing those values into a table - _without manually copying and pasting the data each day into a .txt file_. I have been able to do that with other remote URL's dynamically which were designed as .txt files using a tab separator. The php script opens and reads the file every time it is changed on their server and formats the data. However, this file is a .doc file and I'm trying to find a way to achieve the same result. Best... TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] .doc file
Greets, I've been able to open a remote URL, read it and then lop off everything except the last line and break it into an array with its' tabs - /t . The data will then be inserted into a table. However, the following URL shows reservoir storage and is a .doc file. I am unable to run the same script with this URL since it is a .doc file - not a .txt file. The client has said that this is the only file that their office has and does not offer any csv or tsv .txt files. Is there anyway to acheive formatting this data using the following file? http://water.usgs.gov/orh/nrwww/odrm/storage2004.doc Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] htmlspecialchars()
php / mysql/ apache I tried the following using the call to htmlspecialchars() not sure why it is insn't working. I get the output: Test Thank you. TR .. //script Test", ENT_QUOTES); echo $new; ?> // this is what is output:Test // instead of this... // Test -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] isset() question
- Original Message - From: "Richard Davey" <[EMAIL PROTECTED]> > Hello Anthony, > I feel the book you're learning from might not be the best out there! > Especially as it uses the horrible if : else : endif notation, > includes code on the same line as the PHP tags themselves and is > teaching you to code with register globals on. Is the book still on > sale? (i.e. did you buy it recently) or was it something you've had > for a while/got 2nd hand? > Best regards, > Richard Davey > http://www.phpcommunity.org/wiki/296.html Thank you for the reply Richard. Yes. The book is on sale at: www.sitepoint.com also, at amazon, b and n, etc. In fact, it's now in it's second edition by Kevin Yank. It's not a bad book - quite readable to a newbie like myself - but when I ran that code it didn't jive with that function call. To make sure, I downloaded it from their site and ran it again - and the same thing happened. Thank you for your help. TR --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] isset() question
The following script is from Kevin Yank's book (Sitepoint). When I test it _without_ entering a name in the text box and hit submit, the _next_ page loads - however the same page should load beacuse of the conditional if (!isset($name) ): . If I replace !isset() with empty() like if (empty($name)): and do not enter a name then the _same_ page loads which is what is supposed to happen. Why doesn't the call to !isset() with the negation mark loads the next page when a name is not entered? The script predates globals being turned off and it is below. Thank you. TR . Sample Page Please enter your name: Your name: This paragraph contains a link that passes the name variable on to the next document. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php_hostconnect()
I currently have websites with two ISP's. I am getting a lot of warnings throughout a .php script on one server - such as: php_hostconnect() I have used the _same_ .php script exactly on my other ISP's server and I don't get any warnings. In addition, I have tested this script locally on Apache server without any errors. The site where I do not get warnnings has php 4.1.1 installed - wheras the other site where I get php_hostcoonect() warnings is php 4.2.3 Any help will be greatly appreciated. Thank you. Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] localhost mail
Using php/apache/mysql on win 98 I am testing an mail script. The script has a .html form which receives the text input and then a .php script to execute the variables in a mail() function. When I publish both files - the .html and .php - to my ISP's server and enter the data and hit submit I receive an e-mail. In my php.ini file I have configured the SMTP to the name of the ISP's email server. However, when testing the same script out locally on Apache Server: I get the form box, enter the data but I do not receive an email. I only use one ISP. Is it possble they have two name servers and that is why I am not receiving an e-mail when testing on Apache Server? Thank you for any help. Best... Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mail()
Using php/apache/mysql I am testing an mail script. The script has a .html form which receives the text input and then a .php script to execute the variables in a mail() function. When I publish both files - the .html and .php - to my ISP's server and enter the data and hit submit I receive an e-mail. In my php.ini file I have configured the SMTP to the name of the ISP's email server. However, when testing the same script out locally on Apache Server: I get the form box, enter the data but I do not receive an email. I only use one ISP. Is it possble they have two name servers and that is why I am not receiving an e-mail when testing on Apache Server? Thank you for any help. Best... Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] count()
Marek Kilimajer <[EMAIL PROTECTED]> wrote in message: > There are 10 '[PAGEBREAK]' substrings in the string. If the string is > split apart at these substrings, it will give you total 11 parts. Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] count()
Greetings- I'm have the follwing string called $text and throughout this string I'd like to split this into an array by calling spliti() at the tag called PAGEBREAK. So, I count the array elements starting at 0 and get to 9. When I call count(), I get 11. Could somebody please explain why this is? Thank you. TR . "; echo "If I subtract 1 since elements begin at 0, there are ".$another_num_array."."; //This is the output using count(): //... //There are 11 elements using the count() function. //If I subtract 1 since elements begin at 0, there are 10 ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] download from mysql script
I'm trying to receive data from a mysql database through php. Using the command line at mysql listed below gives me a result set. I am able to connect to the database through php, however, when using the following script, I receive no data when the data is in the table called pictures in the db called sitename. // In browser window it reads: // http://localhost/download.php?filename=7 //...and on the Command Line using the following query: // SELECT filetype FROM pictures where ID=$ID // gives me a image/pjpeg as the result set. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file paths and binaries
Greetings all, I'm looking for a tutorial or some assistance in explaning how store and then open and read a binary file using php/mysql. I've got a few tutorials about storing the binary data _within_ a mysql table from Kevin Yank, phpbuilder, etc. but I've heard that it's sometime better to keep your binaries on the server and not in the database. Thus, if the developer just keeps the file path in a VARCHAR column like: C:\apache\images\house.jpg C:\apache\images\tree.jpg etc... and then directs that file be fopen() fread(), etc. it will work without the added overhead. I'm a bit lost in what happens after the filepaths are inserted into the database and what steps follow in the script so that they can be opened and read. Any help, URL's or tutorials will be of assistance. Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] =sessions / J. Meloni Textbook=
Additinally, upon looking at the session files in: C:/apache/tmp: I get from session file from script session_1a.php: products|s:23:"a:1:{i:0;s:6:"Tardis";}"; ... However, looking at session file from script session_1.php: I get: products|s:2:"N;"; -- "Anthony Ritter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Sure. > > Here it is. > > There are three scripts. > > session_1.php: the original form script. > session_1a.php: a revised script with a conditional else. > session_2.php: the receiving script for the session array variable. > > Running script 1a and 2 works fine. > > However the original script 1 and 2 gives me a error when returning to the > contents page the first time - it then fills the contents starting with the > number 2 on subsequent page loads. > > as in: > 1. > 2. Hal 2000 > 3. Sonic Screwdriver > > Try it and see and let me know. > Thank you. > TR > . > > > // this is the original script > // script session_1.php > > session_start(); > ?> > > > Storing an array with a session > > > Product Choice Page > if (isset($_POST[form_products])) { > if (!empty($_SESSION[products])) { > $products = array_unique( > array_merge(unserialize($_SESSION[products]), > $_POST[form_products])); >} > $_SESSION[products] = serialize($products); > print "Your products have been registered!"; > } > ?> > > Select some products: > > Sonic Screwdriver > Hal 2000 > Tardis > ORAC > Transporter bracelet > > > > > > content page > > > > ... > //this is a revised script with a conditional else > //script session_1a.php > session_start(); > ?> > > > Storing an array with a session > > > Product Choice Page > > if (isset($_POST['form_products'])) { > if (!empty($_SESSION['products'])) { > $products = array_unique( > array_merge(unserialize($_SESSION['products']), > $_POST['form_products'])); > }else{ //this conditional has been added > $products = $_POST['form_products'] ; > } > $_SESSION['products'] = serialize($products); > print "Your products have been registered!"; > } > ?> > > > Select some products: > > Sonic Screwdriver > Hal 2000 > Tardis > ORAC > Transporter bracelet > > > > > > content page > > > .. > //this is session_2.php > > session_start(); > ?> > > > Listing 16.5 Accessing session variables > > > Content Page > if (isset($_SESSION[products])) { >print "Your cart:\n"; >foreach (unserialize($_SESSION[products]) as $p) { >print "$p"; >} >print ""; > } > ?> > Back to product choice page > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] =sessions / J. Meloni Textbook=
Sure. Here it is. There are three scripts. session_1.php: the original form script. session_1a.php: a revised script with a conditional else. session_2.php: the receiving script for the session array variable. Running script 1a and 2 works fine. However the original script 1 and 2 gives me a error when returning to the contents page the first time - it then fills the contents starting with the number 2 on subsequent page loads. as in: 1. 2. Hal 2000 3. Sonic Screwdriver Try it and see and let me know. Thank you. TR . // this is the original script // script session_1.php Storing an array with a session Product Choice Page Your products have been registered!"; } ?> Select some products: Sonic Screwdriver Hal 2000 Tardis ORAC Transporter bracelet content page ... //this is a revised script with a conditional else //script session_1a.php Storing an array with a session Product Choice Page Your products have been registered!"; } ?> Select some products: Sonic Screwdriver Hal 2000 Tardis ORAC Transporter bracelet content page .. //this is session_2.php Listing 16.5 Accessing session variables Content Page Your cart:\n"; foreach (unserialize($_SESSION[products]) as $p) { print "$p"; } print ""; } ?> Back to product choice page -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] =sessions / J. Meloni Textbook=
Thanks again but here's what happens when I run that. The form box appears. I select an option. I hit submit. The page that loads says: Warning: Invalid argument supplied for foreach() in c:\apache\htdocs\session_yyy.php on line 13 I then hit the link: Back to content page. The form box appears. I select _another_ option. I hit submit. The page that loads now has the _second_ value I have submitted but not the first. Like: 1. 2. Hal 2000 Is there a way to get the first option into the array? If you get a chance please try the code. Thanking you for your time. TR .. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] =sessions / J. Meloni Textbook=
Thanks John and others. I'm using the script and no values show up in the page: session_bb.php after I submit the values in the form. If somebody would like to test both scripts (session_aa.php and session_bb.php) and get back to me I would be grateful. As I said, these were from her book/CD. Thank you. TR . // this is session_aa.php script Listing 16.4 Storing an array with a session Product Choice Page Your products have been registered!"; } ?> Select some products: Sonic Screwdriver Hal 2000 Tardis ORAC Transporter bracelet content page .. // ...and this is session_bb.php script Listing 16.5 Accessing session variables Content Page Your cart:\n"; foreach (unserialize($_SESSION[products]) as $p) { print "$p"; } print ""; } ?> Back to product choice page -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] =sessions / J. Meloni Textbook=
Using mysql, apache and win98 The following code is from "PHP, mySQL and Apache" (SAMS) by Julie Meloni. Page 338-339 (hour 16). After choosing my selections in the form box and hitting submit I get: ... Warning: Invalid argument supplied for foreach() in c:\apache\htdocs\listing16.5.php on line 13 .. I checked her errata at thickbooks.com but there was nothing for this chapter. Any help will be greatly appreciated. Thank you. TR --- // script 16.4.php Listing 16.4 Storing an array with a session Product Choice Page Your products have been registered!"; } ?> Select some products: Sonic Screwdriver Hal 2000 Tardis ORAC Transporter bracelet content page .. // script 16.5.php Listing 16.5 Accessing session variables Content Page Your cart:\n"; foreach (unserialize($_SESSION[products]) as $p) { print "$p"; } print ""; } ?> Back to product choice page ... Warning: Invalid argument supplied for foreach() in c:\apache\htdocs\listing16.5.php on line 13 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: naughty words / filter
Was able to get this to filter: . TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] naughty words / filter
Hi, I'm trying to filter a word - in this case - called badword1 - to be replaced with asterisks. Listed below is my .html form and .php receiving script. I've also added the same script which gets a hardcoded string. In the first example, the output still shows the original message _without_ replacing the badword whereas in the second example with the hardcoded string - it is getting replaced with *. Any assistance would be greatly appreciated. Thank you. Tony Ritter Your message: // example #1: in the script the text in the variable $guestbook does not get replaced. . // example #2: in this snippet, the hardcoded string $guestbook gets replaced with -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql output
Thanks very much John. I found the following and inserted it into my snippet for alternating backgoriund colors. However, I'm not sure I understand the logic. This part: ... $alternate = "2"; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); if ($alternate == "1") { $color = "#eaf3da"; $alternate = "2"; } else { $color = "#d5eae9"; $alternate = "1"; } Best... Tony . $display_block = " Showing posts for the $topic_title topic: AUTHOR POST "; $alternate = "2"; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); if ($alternate == "1") { $color = "#eaf3da"; $alternate = "2"; } else { $color = "#d5eae9"; $alternate = "1"; } //add to display $display_block .= " mailto:$post_owner>$post_owner[$post_create_time] $post_text "; } //close up the table $display_block .= ""; - Original Message - From: "John W. Holmes" <[EMAIL PROTECTED]> To: "Anthony Ritter" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, August 19, 2003 9:59 PM Subject: Re: [PHP] mysql output > Anthony Ritter wrote: > > >>You also asked a very, very common question, i.e. how to alternate colors > > > > in > > > >>table rows... there are a ton of websites/tutorials out there that explain > >>ways to do this. > >> > >>---John Holmes... > > > > > > > > Apologies for the lengthy code. > > > > I've tried using a few tutorials and am still adrift. > > > > Here's a snippet: > > > > Thank you for any assistance. > > Tony Ritter > > .. > > > > > > > > > > >AUTHOR > > > >POST > >"; > > > >while ($posts_info = mysql_fetch_array($get_posts_res)) { > >$post_id = $posts_info['post_id']; > >$post_text = nl2br(stripslashes($posts_info['post_text'])); > >$post_create_time = $posts_info['fmt_post_create_time']; > >$post_owner = stripslashes($posts_info['post_owner']); > > > >$color1 = "#CCFFCC"; > >$color2 = "#BFD8BC"; > >$posts_info = 0; > > Move the above line outside of your while loop > > >$row_color = ($posts_info % 2) ? $color1 : $color2; > > $row_color = ($posts_info++ % 2) ? $color1 : $color2; > > You were setting $posts_info to zero in each loop, so it's never going > to change. You must set it to zero outside of the loop, then increment > it within. > > You could make this real easy and just do: > > $row_color = ($row_color == $color1) ? $color2 : $color1; > > -- > ---John Holmes... > > Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ > > PHP|Architect: A magazine for PHP Professionals – www.phparch.com > > > > > --- > [This E-mail scanned for viruses by gonefishingguideservice.com] > > --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql output
> You also asked a very, very common question, i.e. how to alternate colors in > table rows... there are a ton of websites/tutorials out there that explain > ways to do this. > > ---John Holmes... Apologies for the lengthy code. I've tried using a few tutorials and am still adrift. Here's a snippet: Thank you for any assistance. Tony Ritter .. AUTHOR POST "; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); $color1 = "#CCFFCC"; $color2 = "#BFD8BC"; $posts_info = 0; $row_color = ($posts_info % 2) ? $color1 : $color2; //add to display $display_block .= " $post_owner[$post_create_time] $post_text REPLY TO POST "; } //close up the table $display_block .= ""; ?> . -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql output
The following code snippet outputs a table from a mySQL database. In version 1, I am able to get alternating background cell colors. However, the output gives me the same post five times. In version 2, I am able to receive five separate posts - which is what I'm looking for - but I'd like to get alternating cell backgrounds. Somewhere my syntax is failing me. Any advice would be greatly appreciated. Thank you. Tony Ritter // version 1: You have selected an invalid topic. Please try again."; } else { //get the topic title $topic_title = stripslashes(mysql_result($verify_topic_res,0, 'topic_title')); //gather the posts $get_posts = "select post_id, post_text, date_format(post_create_time, '%b %e %Y at %r') as fmt_post_create_time, post_owner from forum_posts where topic_id = $_GET[topic_id] order by post_create_time asc"; $get_posts_res = mysql_query($get_posts,$conn) or die(mysql_error()); //create the display string $display_block = " Showing posts for the $topic_title topic: AUTHOR POST "; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); $i = 0; while ($posts_info = @mysql_fetch_array($get_posts_res)) {// begin light-dark loop $row_class = (($i % 2) == 0) ? 'light' : 'dark'; $display_block .= " $post_owner[$post_create_time] $post_text "; $i++; } } //close up the table $display_block .= ""; } ?> p {font-family:sans arial; font-size: 1.25em; } th { font-family:arial; font-size: .75em;\ font-color:#ff; } td {border:1px solid #ff; font-family:arial; font-size:.5em; color: #2d73b9} .light { color:#000; background-color:#eee; } .dark { color:#000; background-color:#aaa; } Posts in Topic Posts in Topic . // version 2: You have selected an invalid topic. Please try again."; } else { //get the topic title $topic_title = stripslashes(mysql_result($verify_topic_res,0, 'topic_title')); //gather the posts $get_posts = "select post_id, post_text, date_format(post_create_time, '%b %e %Y at %r') as fmt_post_create_time, post_owner from forum_posts where topic_id = $_GET[topic_id] order by post_create_time asc"; $get_posts_res = mysql_query($get_posts,$conn) or die(mysql_error()); //create the display string $display_block = " Showing posts for the $topic_title topic: AUTHOR POST "; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); //add to display $display_block .= " $post_owner[$post_create_time] $post_text REPLY TO POST "; } //close up the table $display_block .= ""; } ?> p {font-family:sans arial; font-size: 1.25em; } th { font-family:arial; font-size: .75em;\ font-color:#ff; } td {border:1px solid #ff; font-family:arial; font-size:.5em; color: #2d73b9} .light { color:#000; background-color:#eee; } .dark { color:#000; background-color:#aaa; } Posts in Topic Posts in Topic -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] email confirmation script
This is what I receive via e-mail after I click submit using the following code. As you can see - the html attribute To: <[EMAIL PROTECTED]> Sent: Thursday, August 14, 2003 2:04 PM Subject: Thank you for registering > Thank you for registering tony > > http://www.gonefishingguideservice.com/[EMAIL PROTECTED] efishingguideservice.com&confirmation_ID=">Click - /*the .html form which takes a name and an e-mail address */ Your name: Your e-mail address: ... /*process_a.php: which receives the name and email variables. The script then tries to then send the note back to the user with a link - called CLICK. When the user hits the link to email_verify.php the email address is inserted into the database*/ http://www.gonefishingguideservice.com/email_verify.php?email=$email&; confirmation_ID=$confirmation_ID>CLICK"; $secret_variable = "something_only_you_know"; $confirmation_ID = md5($email.$secret_variable); $to="[EMAIL PROTECTED]"; $subject="Thank you for registering"; $mailheaders="From: Us"; mail($to,$subject,$msg,$mailheaders); ?> . // email_verify.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] email confirmation script
Hi, I'm trying to find a script that does the following: 1. A user is presented with a form with a textbox for their e-mail address. 2. The user types in their e-mail addrees and submits the form. 3. A note is then sent from that server if their e-mail address , in fact, exists. 3. If the e-mail address does exist - the user receives a note. The user is then presented with a link which they click to confirm and their e-mail address in then inserted into the database. I've searched through google for: e-mail, confirmation, php, etc. and have not come up with anything. If anyone has code that I could look at, I would greatly appreciate it. Many thanks, Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] discussion forum from j. meloni's book
Jennifer Goodie" <[EMAIL PROTECTED]> writes: > You didn't switch the aliases around, you just switched the join order. > This will provide unexpected results. In order to understand it, you should > read up on left joins. > http://www.mysql.com/doc/en/JOIN.html Thank you. But... // the query $verify = "select ft.topic_id, ft.topic_title from forum_posts as fp left join forum_topics as ft on fp.topic_id = ft.topic_id where fp.post_id = $_GET[post_id]"; ... My question: why - or how can - the columns ft.topic_id and ft.topic_title come from the table forum_posts? In the original schema, there is no column called topic_title in the table called forum_posts. When I change the following to read: $verify = "select ft.topic_id, ft.topic_title from forum_topics as ft left join forum_posts as fp on fp.topic_id = ft.topic_id where fp.post_id = $_GET[post_id]"; It works fine. /*Roughly translated: Select the column ft.topic_id along with the column ft.topic_title from the table called forum_topics which we'll call ft. Then join the table called forum_topics onto the table called forum_posts and match the records where topic_id corresponds in both tables along with post_id corresponds in both tables.*/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] discussion forum from j. meloni's book
Ford, Mike [LSS]" <[EMAIL PROTECTED]> writes: > You have a conceptual misconception. In effect, you need to read that query > as: > > "select ft.topic_id, ft.topic_title > from ( forum_posts as fp > left join forum_topics as ft > on fp.topic_id = ft.topic_id > ) > where fp.post_id = $_GET[post_id]" > > In other words, the left join of the two tables is treated as a single > virtual table, from which you could select any column of either original > table. .. Thanks Mike for the clear explanation. TR --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help Please in using fopen in PHP
[EMAIL PROTECTED] wrote in message: > Hi Folks, > > I am currently learning php and Mysql a scripting language and DB i just feel > in love with. I am currently having problem in opening file to put data > collected from clients when the purchase from an online shop. The scripts is as > follows. > > where i am having problem is this // open file for appending > $fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt ", 'a'); [snipped] . Looks like that script was pulled from Welling and Thomson's textbook on PHP and mySQL. I've got the first edition - SAMS. You need to create a file called: orders.txt which which would reside in the path of your argument to fopen(). Best... Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] discussion forum from j. meloni's book
The following code is From Julie Meloni's textbook - PHP, mySQL and Apache (SAMS) on page 305-307 / Listing 14.5: It's the last script of a discussion forum which is comprised of four php files and one html file. The script can be seen at: http://www.thickbook.com Chapter 14 off the zipfile. Anyway, in the textbook and the zip her mySQL query reads: ... $verify = "select ft.topic_id, ft.topic_title from forum_posts as fp left join forum_topics as ft on fp.topic_id = ft.topic_id where fp.post_id = $_GET[post_id]"; . The part that I'm confused about is: ... select ft.topic_id, ft.topic_title from forum_posts It seem that the alias of ft refers to forum_title - not forum_posts. In fact, I switched the query to read as follows: $verify = "select ft.topic_id, ft.topic_title from forum_topics as ft left join forum_posts as fp on fp.topic_id = ft.topic_id where fp.post_id = $_GET[post_id]"; .. And that seems to run fine. Any explanations will be appreciated. Her original code is below. Thank you. Tony Ritter .. Post Your Reply in $topic_title Post Your Reply in $topic_title Your E-Mail Address: Post Text: "; } } else if ($_POST[op] == "addpost") { //check for required items from form if ((!$_POST[topic_id]) || (!$_POST[post_text]) || (!$_POST[post_owner])) { header("Location: topiclist.php"); exit; } //add the post $add_post = "insert into forum_posts values ('', '$_POST[topic_id]', '$_POST[post_text]', now(), '$_POST[post_owner]')"; mysql_query($add_post,$conn) or die(mysql_error()); //redirect user to topic header("Location: showtopic.php?topic_id=$topic_id"); exit; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] email confirmation script
Thanks Jackson. I appreciate the assistance. Am I on the right track? Best... TR .. // this is the form Your e-mail address: ... //process.php mailto:[EMAIL PROTECTED]/email_verify.php?email=$email&c onfirmation_ID=$confirmation_ID>link" mail($_POST['email'],'Thank you',$body,'From: Us Fish'); } ... //email_verify.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] discussion forum from j. meloni's book
Jennifer Goodie" <[EMAIL PROTECTED]> writes: They don't. ft is aliased to forum_topics. That's right. ft is aliased to the forum_topics table. The query reads: ... $verify = "select ft.topic_id, ft.topic_title from forum_posts as fp left join forum_topics as ft on fp.topic_id = ft.topic_id where fp.post_id = $_GET[post_id]"; . The question: How can the column that is called: ft.topic_title in the select statement above be taken from the table called forum_posts when it was not there in the schema? "SELECT ft.topic_id, ft.topic_title FROM forum_posts...[snipped] Thank you. TR --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] discussion forum from j. meloni's book
Ford, Mike [LSS]" <[EMAIL PROTECTED]> writes: > You have a conceptual misconception. In effect, you need to read that query > as: > > "select ft.topic_id, ft.topic_title > from ( forum_posts as fp > left join forum_topics as ft > on fp.topic_id = ft.topic_id > ) > where fp.post_id = $_GET[post_id]" > > In other words, the left join of the two tables is treated as a single > virtual table, from which you could select any column of either original > table. .. Thanks Mike for the clear explanation. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_real_escape_string
Larry E . Ullman" <[EMAIL PROTECTED]> wrote in message: > The mysql_real_escape_string() requires a connection to the database. > The connection identifier is defined in another script so it's brought > in using the global statement. > > Hope that helps, > Larry . Thank you Larry. Now I see the variable $dbc as the connection to the database in other file which uses require_once(). Best... TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql_real_escape_string
The following function is from Larry Ullman's PHP and mySQL on page 217 - script 6.8 - in which there is a connection to a mySQL database using PHP. My question is that I'm not sure of the global variable $dbc. If I am to understand...this made up function escape_data() will receive a piece of data - say $_POST['first_name'] - and then check if magic_quotes_gpc is turned on in the ini file. If it returned true, then stripslashes will be applied to the data - if it is not turned on, then slashes will be applied to the data variable. What is the reason that the global variable $dbc is declared in the function - I cannot find another instance of $dbc outside of the function in script 6.8. Thank you, Tony Ritter . function escape_data($data) { global $dbc; if (ini_get('magic_quotes_gpc')) { $data=stripslashes($data); } return mysql_real_escape_string($data,$dbc); } . //check for a first name if(empty($_POST['first_name'])) { $fn=FALSE; $message='You forgot to enter you first name'; } else { $fn= escape_data($_POST['first_name']); // calling the function } .. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strings
Curt Zirzow writes: > I did some testing you can see the code and results here: > http://zirzow.dyndns.org/html/php/tests/preg/parse_doc.php .. Thanks Curt. I checked it out and I still pick up the following lines which I was looking to delete on the pattern match. They are: . Expires:No;;725283 //line 1 AWUS41 KALY 012014 //line 2 RWSALB // line 3 . It could be that when the URL file is being opened and read that these characters are on _three_ different_ lines as opposed to one line/string and the match is not being met. I was looking to delete those lines and to start the match at REGIONAL. Best... TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strings
Curt Zirzow wrote in message: > This exact thing was talked about earlier today, with the subject > 'Using eregi_replace()'. Right. However, I've tried using the following code in which the text from the URL is printed out completely and then I change the variable from $contents to $text and using the line with preg_replace(), it still outputs the complete text without the pattern match. Any advice will be helpful. Thank you. TR http://weather.noaa.gov/pub/data/summaries/regional/ny/albany.txt";; if (!($fp=fopen($theurl, "r"))) { echo "Could not open the URL."; exit; } $contents=fread($fp, 100); fclose($fp); echo $contents; echo ""; $text=$contents; $newtext= preg_replace("!.*?(REGIONAL.*YORK).*!","$1",$text); echo $newtext; // outputs the same text as above ?> .. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strings
In the following snippet, I'm trying to open and read a URL into the variable $contents. I'd like to use preg_replace() to return only part of that string beginning with say - regional and ending with new - but I get the complete URL string returned. Thank you for any assistance. Tony Ritter ... http://weather.noaa.gov/pub/data/summaries/regional/ny/albany.txt";; if (!($fp=fopen($theurl, "r"))) { echo "Could not open the URL."; exit; } $contents=fread($fp, 100); $newtext= preg_replace("/.*?(regional.*new).*/","1",$contents); fclose($fp); echo $newtext; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using eregi_replace()
However, this works using: preg_replace() . Thank you all. Is there a way I can be sure of the syntax? "!.*?(hello.*going).*!", // the pattern which - I think - reads as follows: !.*? // do not use any character or characters before the grouping of hello (hello.*going) // get the grouping of hello and any character after that word to going .*! // do not use any character or characters after the grouping of going - not sure why the exclamation is at the end if it is a negation symbol. Please advise. Thank you. TR "$1", // the grouping $text // the original string -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using eregi_replace()
Messju Mohr" <[EMAIL PROTECTED] writes: > you mean > $newtext= ereg_replace(".*?(hello.*going).*","\\1",$text); > ?? .. Thank you but I get: Warning: REG_BADRPT: in c:\apache\htdocs\string.php on line 3 Using: . Regards, TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using eregi_replace()
Using eregi_replace(), is there a way to take out a piece of a sentence - which has spaces - and then return the new sentence? For example, to return the new sentence: hello I must be going from the original sentence: blah blah blah hello I must be going blah blah. I tried: ... ... Thank you. Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: anchor in php page
Ivo: > Why not use : > www.thesite.com/thepage.asp#here . Thank you Ivo. I don't usually use asp but was wondering if the word "go" in asp like: www.thesite.com/thepage.asp?go=here is a _reserved_ word in .asp which acts like the symbol "#" - serving as the anchor. And if one can achieve this using php. Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] anchor in php page
I am trying to access a page published on a server - and then using an anchor - to jump to a specific paragraph on that page. For instance, if using asp, I could write: www.thesite.com/thepage.asp?go=here where "here" -the value - in the string query would be marked up as: ... // thepage.asp blah,blah,blah, etc... ... Can this be done using php? Thank you. Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] isp configuratuion error
Burhan Khalid" wrote in message: > You need to edit the php.ini file (or if this is hosted, have your host > change the php.ini file). > > The setting you want is : force-cgi-redirect > > You need to change this to false (0) for it to work on IIS. > > IIRC, it says something along those lines in the default > php.ini-recommended that comes with the package. > > I'm not on my php box or else would give you the exact line to change, > but I know its the force-cgi-redirect (might be cgi_force_redirect) > setting that's causing this problem (had similar issue with local IIS > install) . Thank you BK. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] isp configuratuion error
When calling up a page on my web with the extension of .php, I presently get the following notice. (please see below) Before yesterday, I had been able to load any .php page on my web. The ISP which hosts this web is on NT. Please advise. Thank you. Tony Ritter . Security Alert! The PHP CGI cannot be accessed directly. This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive. For more information as to why this behaviour exists, see the manual page for CGI security. For more information about changing this behaviour or re-enabling this webserver, consult the installation file that came with this distribution, or visit the manual page. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] upload question
Greetings all, Using PHP 4.1.1 / Apache Server / MS Win 98 / IE 5.5 The following script is from Julie Meloni's book PHP Fast and Easy on page 170-174. The first part is an html form in which the user browses and chooses a file to be upoloaded to the server. The script works fine in that when I chose a file and hit submit it, the file ends up in: C:\apache\htdocs However, in the book, in the last illustration, she explains: "Just to be sure, use the File/Open Page menu item in your _browser_ to navigate through your filesystem and find the file that you just uploaded." The illustration shows the .jpg file _within_ the browser screen on the upper left hand side. When I follow those steps and hit file / open, my paint program takes over and opens the uploaded .jpg file and the browser interface of MS IE 5.5 is gone. Any advice would be appreciated. Thank you. Tony Ritter ... // html form File to upload: // .php script called upload.php You sent: , a byte file with a mime type of . -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ISP Blues
Marek, For testing purposes, on my home computer with php 4.1.1 and Apache Server, the script works fine. Now, I'd like the script to work on my ISP's server which hosts my site. They use MS IIS. What are the correct steps for them to install the php_gd.dll file on their server since that same script is causing an error when published to the web. Many thanks, Tony Ritter 1. 2. 3. etc... --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ISP Blues
The following script works fine when I test it at home using localhost on: MS Win 98 Apache Server PHP 4.1.1 php_gd.dll I then publish the script to my web at my ISP's MS IIS server which is the host and get an undefined function call of: ImageCreate() The ISP has said that they have installed php_gd.dll on their server but I get that error. I have run php scripts on this site _without_ the gd libraries. Could somebody please advise how they should be installing the .dll file so I can utlize the gd_libraries with php? Many thanks, Tony Ritter .. The script... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: using strcmp()
Justin Garrett wrote: > You were missing a semicolon: > $result=strcmp($firstword, $secondword); ... Thank you Justin and all other. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] using strcmp()
The following test script for the function strcmp() is from page 114 -115 of PHP (Hungry Minds). I'm getting a parse error on line 6. Using PHP 4.1.1 / MS Win 98 / Apache Server. Many thanks... Tony Ritter .. =1) { $statement="comes after"; } else if ($result<=-1) { $statement="comes before"; } else { $statement="is the same as"; } echo "The word $firstword $statement"; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] cropping an image script
I'm getting a fatal error on the following script using MS Win 98 / Apache Server / PHP 4.1.1. / php_gd.dll Fatal error: imagecreatetruecolor(): requires GD 2.0 or later in c:\apache\htdocs\testphoto.php on line 6 Is there a workaround to this function so that I can crop part of the source .jpeg? Thank you. Tony Ritter ... Fatal error: imagecreatetruecolor(): requires GD 2.0 or later in c:\apache\htdocs\testphoto.php on line 6 --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] cropping an image script
In the following php script, the function takes the original file and crops to the destination file. I've ran the script using a .png file and a .jpg file. The .png works fine whereas the .jpeg file returns only part of the image along with a blue rectangle. For instance - where the original image is a 200 x 300 jpeg called: 1_data.jpeg and the destination iamge is 75x75 called: 2_data.jpeg and starting at the x,y coordinates of 0,0 - the script returns a 75x 75 file but only a sliver of the .jpg image is within the 75x75 blue square. Any help will be of assistance. Thank you. Tony Ritter The following is the php cropping script (with author credit): http://obala.net/en // // Yes the proses could be executed with imagecopyresized build-in function // but with this function you get the idea of how an image color set is constructed // // $cropX = source starting X // $cropY = source starting Y // $cropW = crop weigth // $cropH = crop heigh // $source = source filename // $destination = destination filename // $type = image type function im_crop($cropX,$cropY,$cropH,$cropW,$source,$destination,$type='jpeg') { // switch known types and open source image switch ($type) { case 'wbmp': $sim = ImageCreateFromWBMP($source); break; case 'gif': $sim = ImageCreateFromGIF($source); break; case 'png': $sim = ImageCreateFromPNG($source); break; default: $sim = ImageCreateFromJPEG($source); break; } // create the destination image $dim = imagecreate($cropW, $cropH); // pass trought pixles of source image for ( $i=$cropY; $i<($cropY+$cropH); $i++ ) { for ( $j=$cropX; $j<($cropX+$cropW); $j++ ) { // get RGB color info about a pixel in the source image $color = imagecolorsforindex($sim, imagecolorat($sim, $j, $i)); // insert the color in the color index of the new image $index = ImageColorAllocate($dim, $color['red'], $color['green'], $color['blue']); // plots a pixel in the new image with that color imagesetpixel($dim, $j-$cropX, $i-$cropY, $index); } } // whe dont need the sorce image anymore imagedestroy($sim); // switch known types and save switch ($type) { case 'wbmp': ImageWBMP($dim, $destination); break; case 'gif': ImageGIF($dim, $destination); break; case 'png': ImagePNG($dim, $destination); break; default: ImageJPEG($dim, $destination); break; } // free the used space of the source image imagedestroy($dim); } // example im_crop(0,0,75,75,'1_data.jpeg','2_data.jpeg','jpeg'); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] image and text from remote URL
There is a photograph named bar.jpg in a remote URL called http://www.foo.com The photograph is about 640 x 480 in size. The following script allows me to open and read the file. In addition, I have a file named data.jpg in my web folder. I want to write the bar.jpg into the data.jpg file and at the same time reduce that image to 256 x 192. After testing the following script on Apache server / MS Win 98 and PHP with php_gd libraries it seems that I can accomplish that. However, I cannot add a line of copy below the photo like: Only the photo shows up and not the text. How can I add a line of text along with the photo? Thank you. The script follows... Tony Ritter . http://www.foo.com/bar.jpg', 'r'); if ($fh) { $imgbuffer = null; while ($chunk = fread($fh, 100)) $imgbuffer .= $chunk; fclose($fh); } // o.k. to here... $filename="C:\apache\htdocs\data.jpg"; $thephoto=$imgbuffer; $myfile=fopen($filename,"w+")or die("Could not open the file."); fwrite($myfile,$thephoto)or die ("Could not write to the file"); fclose($myfile); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie: contents will not output
Hugh, That script works fine. Thank you. What I am trying to achieve is to pull a .jpeg from a remote URL and then resize and/or crop it after it is placed in a variable. Your script is able to open and read the original file for output. In the following script, I have the variable $contents holding the file - bar.jpg - which is - say 1000x1000 - and I am trying to reduce the size of that file to 300x300. I have php_gd libraries installed. Many thanks, Tony Ritter ... http://www.foo.com/bar.jpg";; $fp=fopen($file_to_open,"r"); $contents=fread($fp,100); //reads to eof or ~10K whichever comes first $new_w=300; $new_h=300; $dst_img=ImageCreate($new_w,$new_h); $src_img=ImageCreateFromJpeg($contents); ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),I mageSY($src_img)); ImageJpeg($dst_img); fclose($fp); ?> --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] newbie: contents will not output
I'm trying to test the following script to display the contents of the following URL but it will not output. Any advice will be greatly appreciated. Thank you. Tony Ritter ... http://www.weather.com";, "r"); $contents = fread($file_handler, filesize($file)); fclose($file_handler); echo $contents; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] image question
I'm looking for a php tutorial or script which can open and read an existing .jpg or .png from another URL. Next, the script then modifies that image by - say - cropping off the bottom by 20px or resizing it by 50%. Lastly, could this modified file then be renamed on ones server? Many thanks, Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] transferring another .jpg to your own
Using PHP 4.1.1. / Apache / Win 98 I'd like to use a .jpg from another URL - say: http://www.blah.com/foo.jpg and turn it into a variable using PHP and then once it is a variable to try to manipulate that image using GD Libraries which are installed. Is this possible? I tried placing the string of the URL into a variable like: $theoldimage="http://www.blah.com/foo.jpg";; and then calling this function of: $thenewimage=imagecreatefromjpeg ($theoldimage); but it did not return a value when I echo'ed $thenewimage Many thanks for any advice. Tony Ritter .. function LoadJpeg ($imgname) { $im = @imagecreatefromjpeg ($imgname); /* Attempt to open */ if (!$im) { /* See if it failed */ $im = imagecreate (150, 150); /* Create a blank image */ $bgc = imagecolorallocate ($im, 255, 255, 255); $tc = imagecolorallocate ($im, 0, 0, 0); imagefilledrectangle ($im, 0, 0, 150, 30, $bgc); /* Output an errmsg */ imagestring ($im, 1, 5, 5, "Error loading $imgname", $tc); } return $im; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Thank you! [GD Libraries]
Thank you to all that came to my aid while I was muddleing through my attempts to install GD Libraries. Since I had various versions of PHP from textbook CD's - I downloaded PHP Triad which happened to be PHP version 4.1.1 I changed two lines in the php.ini file and ran the phpinfo() function call and GD showed up without the page hanging up. In that version, there is no php_gd2.dll - just php_gd.dll. Again...my sincerest thanks to all. Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
Rich, I've got five screenshots at this URL: www.gonefishingguideservice.com/php1.htm If you get a chance please take a look. I got php_gd2.dll from the zipfile (see photo) and the "extensions" sub-directory was not there when I installed. Many thanks, TR . Rich Gray: > You said in your earlier post that in your php.ini your extension_dir is set > to "C:\PHP\" - this is wrong it should be c:/php/extensions > If the extensions directory was not there and you had to create it manually > then where did you get the php_gd2.dll from? > The extensions sub-directory should be there for a normal installation - did > you install from zip? > > Rich --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
P.S. If you get a moment, maybe you could send me a .txt file of your php.ini file along with you php_gd2.dll setup. That way I could check line for line. Many thanks, TR --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
Rich, I've checked my php.ini files on my drive and all I've got is one. The php_gd2.dll file is in: C:/PHP/extensions There was no default folder called extensions when I installed PHP so I made a directory called extensions under PHP. Everytime I take out the semicolon in the .ini file, the page won't load and I've got to shut down Apache server manually. If I put the semicolon back in, the page loads fine. I don't have a clue. Somewhere between the .ini file and Apache something is very screwed up. TR --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php.ini
I run the following script: // the page loads o.k. when the semi-colon remains as in: ;extension=php_gd2.dll but if I remove the semicolon as in: extension=php_gd2.dll the page won't load and the server hangs up. .. \\ this is my php.ini file on MS Win 98/ PHP/ Apache ; Directory in which the loadable extensions (modules) reside. extension_dir = "C:\PHP\" ; Whether or not to enable the dl() function. The dl() function does NOT work ; properly in multithreaded servers, such as IIS or Zeus, and is automatically ; disabled on them. enable_dl = On extension=php_gd2.dll ... Any advice on how I can install GD libraries greatly appreciated. Thank you. Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] =at wit's end with GD Libraries=
I want to thank those who tried to help with my questions about using the GD libraries. I still have not gotten them to function using PHP. I've put two screenhots of the phpinfo() page at: www.gonefishingguideservice.com/php_page.htm If you care to take a look at those images, you'll see that I've got php and Apache working with MS Win 98. It also says that directories are enabled. I've searced for the following files that I believe I need for GD Libraries and PHP in Explorer and found: php_gd.dll -> C:\PHP\extensions php.ini -> C:\WINDOWS php4ts.dll -> C:\WINDOWS\System msvcrt.dll -> C:\WINDOWS\System When I load the phpinfo() page, it comes up like you see in the screenshots. However, when I _take out_ the semi-colon as in the line: ... extension=php_gd.dll //semi-colon taken out .. the page - or any page with a file extension.php will _not_load at all using Apache. However, when I _reinsert_ the semi-colon in the php.ini file, the .php page then loads. Any advice on how I can get the GD libaries to work will be greatly appreciated. At wit's end... Thank you. Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] imagecreate()
Chris, The function I'm trying to get...it's: imagecreate() I am using MS Win 98 / PHP 4 and Apache. I tried running the following script but got an undefined call to imagecreate() The following copy is located in my php.ini file...one of which is: .. ;extension=php_gd.dll .. I tried uncommenting this line to no avail. What is the best way to install php_gd.dll so that I can make use of the image library. Many...many thanks. Tony Ritter --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] imagecreate()
Fine Chris. Maybe you'd be kind enough to explain how I can get that function to work. I've uncommented the line in the php.ini file. In "Mastering PHP" (Sybex) on page 559 - Chapter 18, the authors of the textbook - Allen and Hornberger - say when using Win to: ... "uncomment it; that's it. Restart your webserver. That's all it takes." ... Please advise on the steps if you get a chance. Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] imagecreate()
Yes Adam. Any ideas? TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] imagecreate()
On MS Win 98 / Apache / PHP 4 If somebody out there using Win can check my php.ini file and advise me what I'm doing wrong. I have uncommented: .. extension=php_gd.dll .. and have included: .. extension_dir = C:\php4\extensions I run the php script: I receive: X-Powered-By: PHP/4.0.0 Content-type:image/png Fatal error: Call to undefined function: imagecreate() in c:\program files\apache group\apache\htdocs\image.php on line 3 Thank you. TR ... // this is in my php.ini file: ; ; Paths and Directories ; ; include_path = ; UNIX: "/path1:/path2" Windows: "\path1;\path2" doc_root = ; the root of the php pages, used only if nonempty user_dir = ; the directory under which php opens the script using /~username, used only if nonempty ;upload_tmp_dir = ; temporary directory for HTTP uploaded files (will use system default if not specified) upload_max_filesize = 2097152 ; 2 Meg default limit on file uploads extension_dir = C:\php4\extensions; directory in which the loadable extensions (modules) reside ;; ; Dynamic Extensions ; ;; ; if you wish to have an extension loaded automaticly, use the ; following syntax: extension=modulename.extension ; for example, on windows, ; extension=msql.dll ; or under UNIX, ; extension=msql.so ; Note that it should be the name of the module only, no directory information ; needs to go here. Specify the location of the extension with the extension_dir directive above. ;Windows Extensions ;extension=php_mysql.dll ;extension=php_nsmail.dll ;extension=php_calendar.dll ;extension=php_dbase.dll ;extension=php_filepro.dll extension=php_gd.dll ;extension=php_dbm.dll ;extension=php_mssql.dll ;extension=php_zlib.dll ;extension=php_filepro.dll ;extension=php_imap4r2.dll ;extension=php_ldap.dll ;extension=php_crypt.dll ;extension=php_msql2.dll ;extension=php_odbc.dll //this is the php script: ... //this is what I get: X-Powered-By: PHP/4.0.0 Content-type:image/png Fatal error: Call to undefined function: imagecreate() in c:\program files\apache group\apache\htdocs\image.php on line 3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie: installing gd in php4
In my php.ini file, this is what it looks like: ... extension_dir = C:\php4\extensions\; directory in which the loadable extensions (modules) reside extension=php_gd.dll Many thanks, TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: resizing .jpg file in php
-- Steve Magruder wrote in message : > To reduce its display size in an img tag, specify 640 * .75 for the width > (assuming 640 is for width) and 480 * .75 for the height. If you actually > want to reduce the size of the image, then look at PHP's image-related > functions (and the GD library). > > Steve .. Thanks Steve. Using MS Win 98 / PHP 4 and Apache. I tried running the following script but got an undefined call to: ImageCreate() The following copy is located in my php.ini file...one of which is: .. ;extension=php_gd.dll .. I tried uncommenting this line to no avail. What is the best way to install php_gd.dll so that I can make use of the image library. Many thanks. Tony Ritter ;; ; Dynamic Extensions ; ;; ; if you wish to have an extension loaded automaticly, use the ; following syntax: extension=modulename.extension ; for example, on windows, ; extension=msql.dll ; or under UNIX, ; extension=msql.so ; Note that it should be the name of the module only, no directory information ; needs to go here. Specify the location of the extension with the extension_dir directive above. ;Windows Extensions ;extension=php_mysql.dll ;extension=php_nsmail.dll ;extension=php_calendar.dll ;extension=php_dbase.dll ;extension=php_filepro.dll ;extension=php_gd.dll ;extension=php_dbm.dll ;extension=php_mssql.dll ;extension=php_zlib.dll ;extension=php_filepro.dll ;extension=php_imap4r2.dll ;extension=php_ldap.dll ;extension=php_crypt.dll ;extension=php_msql2.dll ;extension=php_odbc.dll > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] newbie: installing gd in php4
Using MS Win 98 / PHP 4 and Apache. I tried running the following script but got an undefined call to: ImageCreate() The following copy is located in my php.ini file...one of which is: .. ;extension=php_gd.dll .. I tried uncommenting this line to no avail. What is the best way to install php_gd.dll so that I can make use of the image library. Many thanks. Tony Ritter ;; ; Dynamic Extensions ; ;; ; if you wish to have an extension loaded automaticly, use the ; following syntax: extension=modulename.extension ; for example, on windows, ; extension=msql.dll ; or under UNIX, ; extension=msql.so ; Note that it should be the name of the module only, no directory information ; needs to go here. Specify the location of the extension with the extension_dir directive above. ;Windows Extensions ;extension=php_mysql.dll ;extension=php_nsmail.dll ;extension=php_calendar.dll ;extension=php_dbase.dll ;extension=php_filepro.dll ;extension=php_gd.dll ;extension=php_dbm.dll ;extension=php_mssql.dll ;extension=php_zlib.dll ;extension=php_filepro.dll ;extension=php_imap4r2.dll ;extension=php_ldap.dll ;extension=php_crypt.dll ;extension=php_msql2.dll ;extension=php_odbc.dll -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] resizing .jpg file in php
I'd like to use (with permission) .jpg files from a webcam from another URL. Once that URL is opened and read via PHP as a file into my site is it possible to resize that image? It measures 640 x 480 pixels and I would like to reduce the image size by 25%. Thank you. Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax question
Many thanks Jason. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax question
This is what I was getting at. The following is correct mysql syntax in which a comma must be added after each field - except for the last field - in this case price: i.e., . CREATE TABLE chairs( id int(5), item varchar(50), desc text, price float ); . However, within the loop in her script it says to add the comma after _each_ field since there is no way of knowing when the loop will end. Thus, why is she directing the script - after the loop has ended - to lop off the last comma by using the substr() function call as in: if ($field_length[$i] != "") { $sql .= "($field_length[$i]) , "; } else { $sql .= ", "; } loop is finished. and then... $sql=substr($sql,0,-1); //which basically says to take the existing sql statement string from the beginning to the next to last character and return it to the variable $sql thus taking off the comma. Am I on the right track? Thank you. Tony Ritter ... Ernest E Vogelsinger" <[EMAIL PROTECTED] > No. The reason for the comma is that SQL dictates that column names in a > create table statement are separated by a comma. > > This is valid SQL: > create table chairs( > id int(5), > item varchar(50), > desc text, > price float > ); > > This is invalid and generates an SQL error when passed to the server: > create table chairs( > id int(5) > item varchar(50) > desc text > price float > ); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] syntax question
Greetings... The following is the _third_ part of a script found in Julie Meloni's book "PHP Essentials" on page 118. The script dynmically generates a form box of field names, field types and field sizes for a mysql table depending on what the user chooses. My question is about syntax or logic in the following snippet: The variables: $field_name $field_type $field_length are carried over from the previous script. . $sql = "CREATE TABLE $table_name ("; for ($i = 0; $i < count($field_name); $i++) { $sql .= "$field_name[$i] $field_type[$i]"; if ($field_length[$i] != "") { $sql .= " ($field_length[$i]),"; } else { $sql .= ","; } } $sql = substr($sql, 0, -1); $sql .= ")"; ... My question is about the snippet: . if ($field_length[$i] != "") { $sql .= " ($field_length[$i]),"; } else { $sql .= ","; } .. In that it would say that if the field_length variable is not empty then add the (number) and comma to the sql statement If it is empty, then just add a comma. The question: Is the reasoning that a comma *must* be added since this is _within_ a loop? As in: CREATE TABLE chairs ( id INT(5), item VARCHAR(50), desc TEXT , price FLOAT , // common should be deleted but there is no way of knowing this within the loop. // that's why after the loop closes there is a substr() function to delete the comma. ); And that after the loop ends, the comma is then deleted using the substr() function to complete the sql statement. TIA, Tony Ritter .. The complete script: Create a Database Table: Step 3 p {font-family:arial; font-size: .75em;} input {border: 1px solid black;} th {font-family:arial; font-size: .75em; color:red;} h2 {font-family:arial; font-size: 1em;} Adding Table Couldn't create table!"; } else { echo "$table_name [table] has been created!"; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] geek fishing stuff
Jason Wong wrote in message: > Try the mysql website or the mysql list? . Yep. I went to the mysql site and they didn't have any promo material like t-shirts, visors, etc. My news server doesn't have any mysql newsgroups. SQL - yes - but not mysql. There was a shop online that had geek stuff...I forget the name. And that dolphin _is_ a nice looking logo. If you know it - please post. Thanks. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] geek fishing stuff
My guiding season begins in April. Anybody out there know where I can purchase a nice mysql dolphin t-shirt? Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: undefined function - crypt()
Greg wrote in message: > I believe you need to have mcrypt installed. > -Greg . Not sure what mcrypt is. Please advise. In Ullman's textbook, it says that decrypt() and encrypt(0 fuctions will not work if PHP is not installed as a module. However, in his example in the book, it was with crypt(). It does seem to work by calling the md5() function. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] undefined function - crypt()
Using MS Win98 / PHP /Apache I'm getting a undefined function error - crypt() The following scripts were taken from Larry Ullman's book on PHP on page 60-61. Any advice would be helpful. Thank you. Tony Ritter .. //ullmanform.html HTML Form First Name Last Name E-mail Address Comments // ullmanpassword2.php Form Results/Using Strings \n"); print ("Your E-mail address is $Email.\n"); print ("This is what you had to say:\n $Comments\n"); $CryptName = crypt($Name); print ("This is the crypt() version of your name: $CryptName\n"); ?> .. Fatal error: Call to undefined function: crypt() in c:\program files\apache group\apache\htdocs\ullmanpassword2.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql/php query - wrox
Chris Shiflett" wrote in message: > Your query returns two rows because you have two rows in > the database that match the condition: > > host='localhost' > > -- > Chris .. Chris, I was under the impression that the mysql database had as default user when installed: .. anonymous root And that the _anonymous_ user could only create a database that began with the word - test. Using the following commands: ... C:\WINDOWS\cd c:\mysql\bin C:\mysql-shareware --standalone C:\mysql\bin>mysqladmin CREATE houses Database houses created C:\mysql\bin>mysql Welcome to the mysql monitor... mysql>USE houses Database changed As it is, I'm reading Meloni's tutorial on mysql/PHP so the question might also apply to others in this PHP ng. Anyway, the database "houses" was created _without_ the word "test" as the anonymous user. Why is this? Thanking you, Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php/mysql connection
John W. Holmes wrote in message : > Because a default install of MySQL includes an anonymous user, one with > no username or password. There is also a root user with no password. > Read the MySQL manual on Installation and the GRANT command on how to > fix this. > > ---John W. Holmes... ... John, I was under the impression that the mysql database had as default user when installed: .. anonymous root And that the _anonymous_ user could only create a database that began with the word - test. Using the following commands: ... C:\WINDOWS\cd c:\mysql\bin C:\mysql-shareware --standalone C:\mysql\bin>mysqladmin CREATE houses Database houses created C:\mysql\bin>mysql Welcome to the mysql monitor... mysql>USE houses Database changed And the database "houses" was created _without_ the word "test". Why is this? Thanking you, Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql/php query - wrox
Working on: Win 98 / mysql 3.23.55 / php 4 I installed mysql 3.23.55 and wanted to check the user table in the mysql db. The query was: SELECT User FROM user WHERE host='localhost'; The output was: xx user | xx || || root | xx 2 rows in set . In the Wrox book on PHP (page 396) by running that query it is: x--x user | x--x root | x-x 1 row in set I'm not sure why I'm getting two rows. Many thanks for your assistance. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php