[PHP-DB] Re: Off the point here!
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Scott Fletcher) wrote: P.S. the php.general php.version4 newsgroup is now closed! No they're not. I just accessed both lists (via news server) without difficulty. Maybe something's funky with your newsreader config? -- CC -- 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: ranking database searches
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Michael Hall) wrote: This may be more trouble than I'm interested in, but I'm working on search functionality for a number of our MySQL database projects. I'm looking for ways (or just ideas about ways) to set up a ranking system such that I could have exact matches at the top of the list, then multiple partial matches listed below that, and single partial matches below that, etc. See the MySQL manual's section on FULLTEXT indexes. It won't necessarily return results in exactly the order you describe, but will go you one better by ordering based on relevancy. -- CC -- 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: function ??
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: are INSERT INTO statements forbiden inside a function?? Assuming that you're referring to a PHP function and not a function of the RDBMS, no it's not forbidden. Show the relevant snip of code and any error messages being reported. Most likely, you've got a typo or syntactical problem that's causing the insert to fail (ex. forgetting to bring a global var into the function's local scope, an extra curly brace, missing quote, etc.). -- CC -- 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: (preg_match ?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: $search = TheName $data = TheName,TheAddress,ThePhone if (preg_match('/\b'.$search.'\b/i', $data)) { echo Truebr; } else { echo Falsebr; } I am trying to see if the search name matches exactly a name in the $data. In that case, may I suggest an alternative method? $arr=explode(,,lower($data)); if(in_array(lower($search),$arr))) ... (If you want to use the preg_*: take out the double quotes in your regex, which do not appear to be delimiting the substrings within variable $data.) -- CC -- 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: the body of the response
In article 008101c10e0f$379207e0$c844500c@zeospantera, [EMAIL PROTECTED] (Ken Sommers) wrote: PHP manual says: fopen fopen -- Opens file or URL Description int fopen (string filename, string mode [, int use_include_path]) If filename begins with http://; (not case sensitive), an HTTP 1.0 connection is opened to the specified server, the page is requested using the HTTP GET method, and a file pointer is returned to the beginning of the body of the response. can someone explain the clause: and a file pointer is returned to the beginning of the body of the response. can someone explain and describe what this body is? Presumably that's what RFC 2616 refers to as the message body, the part of the response that follows the headers. Translated: what you get with fopen() is what you'd get by fetching the same URL with a browser and then viewing source. BTW, fsockopen() can be used to get both headers (Content-type, Content-length, Expires, Location, etc.) and body (HTML/HTML or whatever). -- CC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Re: the body of the response
In article 00c801c10e3f$758ba8a0$b943500c@zeospantera, [EMAIL PROTECTED] (Ken Sommers) wrote: Suppose I had a MUSIC database that you wanted your site visitors to be able to query,and it was OK with me because you had a MOVIE database that i wanted MY site visitors to be able to query, would we set it up this way? (Sorry, forgot to respond to this part before...) Well, technically, you could...but generally-speaking, I wouldn't. Not unless the database was very small, the queries were very simple, and there was good reason to avoid using a DBMS (ex. MySQL, PostgreSQL, Access, Oracle, etc.). Also, if either of you considers the contents of your respective databases to be valuable (or sensitive), then you should consider that what you propose to do is put the entire contents of both databases up on the WWW for anyone to view/copy/download in toto. -- CC -- 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: remote database exchange
In article 00d201c10e41$9fa2e340$b943500c@zeospantera, [EMAIL PROTECTED] (Ken Sommers) wrote: Is it possible to exchange data on remote databases in PHP mysql? PHP is a scripting language. MySQL is a database management system (DBMS). Two different things. Suppose I had a MUSIC database that you wanted your site visitors to be able to query,and it was OK with me because you had a MOVIE database that I wanted MY site visitors to be able to query, Could we swing this? (Already answered in the previous thread.) IF it exists,,where are all the tutorials and docs on it? Any tutorial/book that explains how to make a search engine using PHP and MySQL can give you the overview. The difference betweeen implementing that fuctionality via a remote connection vs. a local connection is trivial (a minor difference in the host setting for the database connection parameters). http://www.google.com/search?q=php+mysql+tutorial -- CC -- 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] remote database exchange
In article 001b01c10e52$0c08e060$3c41500c@zeospantera, [EMAIL PROTECTED] (Ken Sommers) wrote: I ran mysql show variables; to see if my host server has Oracle support,, sighMySQL is a DBMS. Oracle is a DBMS. Different products from different vendors. MySQL doesn't tell you if you have Oracle support. You can use the PHP function phpinfo() to see what options are compiled into your PHP install. But the information show there can look pretty cryptic until you compare it against the manual to find out what each option means. Simpler way: talk to your ISP. Ask them all these questions. I don't see anything about Oracle or any other DBMS,, any way to tell without asking them? Without asking who? And why would you want to avoid asking them? Your ISP should be a resource for you, not something to avoid. And if it's the database owner you don't want to talk to, let me repeat: you need to be granted access to an account on the database. -- CC -- 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] cites/states data
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Jaskirat) wrote: I am creating a database driven php page for which I need to have a database of US and Canadian states and cities in the back end. Is there some place on the web where I can get such data in the reusable form and You might try looking at census data. It's public info, so free, and should have extensive lists of city info somewhere (you may have to cobble together a complete list from various regional sub-lists, but then again maybe not...). Another possible source: public GIS (geographic information system) databanks. See http://directory.google.com/Top/Science/Social_Sciences/Geography/Geographi c_Information_Systems/Data/, for instance. There are also plenty of people willing to sell you such info... ;-) -- CC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] mysql errors .... or php errors ????
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Steve Brett) wrote: 'invalid index test assumed 'test' in test.php at line 13' can't remember the exact syntax but that's the general idea. if i quote the var when i reference it the error goes away. like $arow['test'] as opposed to $arow[test]. so in general i quote them always BUT i tried to set up a php members board on my server yesterday using someones elses code (blazeboard) and got hundreds of these errors whihc leads me to believe it's either my php or mysql setup ... Strictly speaking, these are not supposed to be the same thing: $myarray[index] //key uses the value of a constant named index $myarray['index'] //key is the literal string index It's a PHP warning that you're getting. Because it's an informational error rather than fatal, the parser continues on as long as it can find an element with that same name (even though it's looking first for the constant). If there's any danger of there being confusion between a constant and array element with the same name, then you need to correct the quoting. If you set your error_reporting level lower (you probably have it at E_ALL now) the warning will no longer appear; but understand that it'll still be *occuring*--it's just that you just won't be reminded of that fact anymore. So you still need to watch what you name those constants and keys! (And in the future, get in the habit of quoting keys correctly so there's no room for confusion.) -- CC -- 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] do table alias's work in PHP?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (cameron walker) wrote: It's hard to comprehend how this is a MySQL problem as my SQL commands work perfectly when entered at the command line. This fact is a pretty strong pointer to PHP being the culprit. Why empirical test would suggest otherwise? A good empirical test is to echo/print the sql to the browser at the point where it is submitted to mysql_query(). Then copy/paste that back to the command line. As long as the quoting isn't scewed up, PHP should not care what is in a query submitted to MySQL. And since apparently PHP isn't throwing an error (you *are* checking the value of $php_errormsg, right?) it sounds like the only thing balking at this query is MySQL. -- CC -- 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] Newbie question
In article 034101c0d3f3$0dd747e0$41041dd8@winbox, [EMAIL PROTECTED] (~BD~) wrote: at the end of my script, I run a set of closing and clean-up procedures.. what I would like to be able to do is that when a user bails out of the script by closing the browser or leaving the site/page, detect that they've gone, and then go ahead and run my closing procedures.. is this possible? http://php.net/manual/en/features.connection-handling.php http://php.net/register-shutdown-function -- CC -- 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] Mystery variable query?
In article 9crr9l$4c4$[EMAIL PROTECTED], [EMAIL PROTECTED] (martin helie) wrote: assuming: $var=1234;(type does not seem to matter) this query returns no error, but no result either: mysql(database,SELECT * FROM table WHERE id='$var'); When you call mysql_query is it perhaps from inside a function, where variable $var has not been passed or made global? (BTW, whenever you experience problems with a query, it's a good idea to echo the query string to the browser. Often, this simple step makes it very clear where the problem lies. Using mysql_error() and $php_errormsg on a query failure also can give you very useful information.) -- CC -- 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] Mystery variable query?
In article 9cs791$mn3$[EMAIL PROTECTED], [EMAIL PROTECTED] (martin helie) wrote: The problem, evidently, is that echoing the variable didn't show the html formatting (it was something like font color=black in an obvious way! Look at it via source view next time. Echoing the content wrapped in a pre tag can also be handy. I wish there were a php debugger. http://php.net/manual/en/debugger.php There's a built-in for PHP3. For PHP4, scroll down toward the bottom of the user annotations for a couple of options. -- CC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] database synchronizing
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Benny K. Putera) wrote: I have 2 systems, local and internet. I want my Internet database is updated from local database. How can I make this through php script? See the manual for your DBMS for info on terms like replication, backup, mirroring, etc. -- CC -- 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] Error Msg: Wrong data type when performing extract()
In article [EMAIL PROTECTED], [EMAIL PROTECTED] ("Shahmat Dahlan") wrote: $result=mysql_query($sqlstmt); # print $result; $row=mysql_fetch_array($result) extract($row); If I do the above, I get the results below: Warning: Wrong datatype in call to extract() in E:\winnt\temp\stock_in.php on line 39 I've went through the query, and it seems alright. It worked previously, now all of a sudden it doesn't work anymore.. Can anyone help me out. Since apparently $row is not an array, I'd guess that mysql_fetch_array has nothing to fetch (i.e. no row was returned by the query). Two things to get into the habit of doing: 1) check that the query was valid. For example: $result=mysql_query($sqlstmt) or die("Query error: " . mysql_error()); 2) check that the query returned 1 or more rows. For example: if(mysql_num_rows()) { $row=mysql_fetch_array($result) or die("Row fetching error: " . mysql_error()); //BTW, you were missing a semi-colon on this line ... } -- CC -- 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] Really Dumb Question...
In article 00c701c0c2af$be478f40$[EMAIL PROTECTED], [EMAIL PROTECTED] ("Darryl Friesen") wrote: How do I create a table within my PHP? Heres what I currently have, but I keep getting parse error on the "create" line... Because create is not a valid PHP command. You have to assign the create statement to a string, _then_ pass the string to mysql_query: $sql = "create table $propTable ( ID int not null auto_increment primary key, TourName tinytext, TourTitle tinytext, ViewTitle tinytext, TourNum tinyint not null, Applet tinyint not null, Desc text, TourPath text, SmFile text, LgFile text ); "; $result = mysql_query($sql); And take out the semicolon immediately after the closing parenthesis in "LgFile text )". :-) -- CC -- 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] Delete all Data and keep the Table
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Naga Sean) wrote: How to delete all the data in database, without delete the table. Do you want to delete every *table* in the *database*, or delete every *row* in the *table*? Assuming the latter, "delete from database_name". -- CC -- 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] Search results
In article 001301c0bafa$34d15be0$[EMAIL PROTECTED], [EMAIL PROTECTED] ("David Drummond") wrote: Can anyone tell me what is the best way to implement displaying multiple search results using next and previous buttons to cycle through all the results. I see this method done on a lot of sites but don't know how to do it in PHP. "Limit" is how it's commonly done (though what's "best" really depends on what you're doing). In mysql, it would be something like: mysql_query("select foo from bar limit 5,10",$connect) //show ten records from result set, starting with the sixth I believe phpbuilder.com has a tutorial on this. If not them, then you shouldn't have much trouble finding examples on one of the other PHP tutorial sites. -- CC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] MySQL max_connections
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Lee Stretton) wrote: Got a bit of a problem with the number of users accessing a website driven by a MySQL database. I want to increase the number of allowed connections to the database, I have found the variable to change (max_connections) but have not been able to find out how, or where to change it. So if anyone can let me know it would be very helpful. http://www.mysql.com/doc/O/p/Option_files.html See in particular the section on "set-variable". -- CC -- 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] Copy data from one mysql table to another?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Bob Stone) wrote: I cannot find any documentation on how to copy the data from one mysql table to another, i.e. table1, columnx to table2, columnx. See the mysql documentation of the "insert into" syntax for how to use a trailing "select" statement to get the values to be inserted. In a single statement you can select the data from one table and insert it into another. Example: "insert into table2 (p_key,data) select p_key,data from table1 where p_key 100 and data !='garbage'" (This also works for "replace into" and "create table" statements, BTW. Nifty, eh? g) -- CC -- 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] How do you define table row indexes?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] ("Anyangwe, Tanwani") wrote: $result = mysql_query("SELECT * FROM motor_vehicle",$db); $strSep = 'nbsp;|nbsp;'; while ($myrow = mysql_fetch_array($result)) { echo $myrow['id'].$strSep; } Gives me the following error: Warning: Undefined index: id in C:\PHP\Test_Scripts\testdb2.php on line 16 1) It's not considered a good habit to use "select *" in scripts. When you later modify the table defs, your scripts will be blown. Even if you never add/drop/change a column, it's still messy since whenever you're working on the code you have to remember--accurately--all of the columns and exactly (case_sensitive_ what they are named. Yuck. Much cleaner to include the column names in your query now. "Select id from motor_vehicle"--then you know for sure you're working with a column of that name. 2) mysql_fetch_array doesn't fetch NULLs. If the value of column 'id' in a given row is NULL, then $myrow['id'] will be undefined for that row. See http://php.net/manual/en/function.mysql-fetch-array.php. -- CC -- 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] Checking for empty string - long
In article 99qq47$jvn$[EMAIL PROTECTED], [EMAIL PROTECTED] (Martin Skjoldebrand) wrote: How do I check for an empty string in PHP/MySQL. http://www.php.net/empty/ http://www.php.net/is_null/ -- CC -- 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] Error Control
In article [EMAIL PROTECTED], [EMAIL PROTECTED] ("Jason Bell") wrote: Hello! I'm writing a script that validates a form It creates users in a mysql table, where there are 2 unique columns 'username' and 'email'. I'm putting mysql_error() into a variable, but I don't want the end user to see that particular message... is there a way to look at just the key that has been duplicated, and create a custom error message for user display? for example, when I duplicate a username, 'jbell', I get this from mysql_error() : "Duplicate entry 'jbell' for key 2" I want to be able to see that the error is from key 2, and react accordingly From a MySQL perspective, you could adjust the query so no error is generated. See the syntax for "INSERT IGNORE" or "REPLACE" for instance. From a PHP perspective, there are functions such as set_error_handler() or register_shutdown_function() to deal with such issues. http://www.php.net/manual/en/features.error-handling.php http://www.php.net/manual/en/ref.errorfunc.php http://www.php.net/manual/en/function.register-shutdown-function.php -- CC -- 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] What's wrong with this code?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Emir Musabasic) wrote: I have user/password/host variables inside a config file but for some reason when I include this into a php page when I test it, I get: Fatal error: Cannot redeclare db_connect() in /www/affiliate/include/functions.inc on line 7. Am I missing something because everything looks good to me. Try using include_once() instead of include(). You're probably inadvertantly re-including the file. In general, except where you're deliberately making multiple includes of the same file, it's a good idea to get in the habit of using include_once() or require_once() to save yourself from surprises like this. -- CC -- 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] error and general problems
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Liz Bander) wrote: I am getting a parse error for the return line every time I try and view the page. Can anyone tell me why? The code is below. $results = "select req, source, number from orders where req=" . $GLOBALS["req"] . ", source=" . $GLOBALS["source"] . ", number=" .$GLOBALS["req"] . ""; if (mysql_fetch_row($results) != 0) { return "This has already been added."; Is this inside a function? 'Cuz AFAIK a "return" would only make sense inside a function. FWIW, the comparison of the fetched row to zero strikes me as a bit unusual. Are you just checking whether there was no rows were returned by the query? If so, I suspect that checking mysql_num_rows() would be more efficient. Also (since this is part of the problem, I'm sure) how do I take the $GLOBALS values and set them equal to the req and source values in the select statement? Is this syntax correct? Depends. MySQL needs string values quoted too, so if for example all of those variables are strings you'd do something like: $results = "select req, source, number from orders where req='" . $GLOBALS["req"] . "', source='" . $GLOBALS["source"] . ", number='" . $GLOBALS["req"] . "'"; -- CC -- 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] reading a URL...
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: Is it Possible, in PHP to read a URL? What I am trying to do is this... I have many news stories in a database, and a single static news page, that calls the story, and the corresponding headline. I have looked about on-line, and seen a common URL,... http://www.arandomsite.com/news_story.php?id=123 I have adopted this method, and it only displays the top most story in my database, no matter what news ID I use. Can I get the ID number from the URL?, and then pass that to the SQL statement? Yes to both, and quite easily. All the variables passed in a GET request (which is what the url is) will automatically be made available in the $HTTP_GET_VARS associative array. So variable "id" is at $HTTP_GET_VARS['id']. In addition, if the configuration setting "register_globals" is turned on, the variable will also be accessible simply as $id. So in the script news_story.php, you could write a query string like, for example: "SELECT article_text from story_table where id=$id" or "SELECT article_text from story_table where id=" . $HTTP_GET_VARS['id'] See http://www.php.net/manual/en/language.variables.external.php -- CC -- 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] Getting info from remote host
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: My idea was to make the http request and load it into an array, to be output in a PHP page. http://www.php.net/manual/en/function.file.php -- CC -- 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] Date
In article 002f01c0b52b$d4778e00$[EMAIL PROTECTED], [EMAIL PROTECTED] ("[EMAIL PROTECTED]") wrote: I save the date in my MySQL db as 2001-03-25. But in my PHP script i want do see it like 25-03-2001. Do it in the MySQL select. Assuming date_field is of field type 'date': select date_format(date_field,"%d-%m-%y") as date_formatted from mytable; (See the MySQL manual's section on date/time functions for more ideas) -- CC -- 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] newbie help
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Matt Coyne) wrote: I have been trying to detect if the variable holds any value and then building a query by concatenating like this: if(!empty($foo)) { ... } $result=@mysql_query($concatsql, $connection) or die ("bugger...!"); This just dies on mysql_query. $result=@mysql_query($concatsql, $connection) or die (mysql_error() . " from query br\n$concatsql"); //show as much relevant info as possible When building complex queries like this, it's really easy to miss a missing quote or extra comma, etc. Displaying the query string usually makes it quite obvious where the problem lies (especially when coupled with a MySQL error message, since MySQL is pretty good about pointing out the spot where the syntax fails). -- CC -- 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] read fils
In article 004101c0b44b$b8e90640$[EMAIL PROTECTED], [EMAIL PROTECTED] ("[EMAIL PROTECTED]") wrote: I just want to read a txt file and let the output in php file. Can someone help me? ?php readfile("myfile.txt"); ? For more sophisticated alternatives, see http://php.net/manual/en/ref.filesystem.php. -- CC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] SQL Select?
In article 99jh2n$gr1$[EMAIL PROTECTED], [EMAIL PROTECTED] ("Grant") wrote: Is there any way of using a string in an SQL query instead of using the table name. Something along the lines of $result=mysql_query("SELECT * FROM $tablename",$db); this doesnt work it come up with a parse error "SELECT * FROM $tablename" should be sufficient to permit PHP variable expansion. MySQL will also require a string value to be quoted, so if $tablename is a string, change the query to "SELECT * FROM '$tablename'". AFAIK, the missing inner quotes would not cause a PHP parse error, only a MySQL error. So you may want to look for something else in your code that could be causing the parse error. -- CC -- 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] Procedure to Include
In article 011201c0b29b$7b6d9cb0$0101a8c0@server, [EMAIL PROTECTED] ("Pankaj Ahuja") wrote: Can anybody tell me the procedure and/or code necessary to include another document into a .php document http://www.php.net/include http://www.php.net/manual -- CC -- 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] Strings
In article 003801c0afa2$2d5853e0$890083ca@oemcomputer, [EMAIL PROTECTED] ("Mick Lloyd") wrote: Can anyone advise on how to surround a string variable in a query. I select a string code from a column using: $result = mysql_query("SELECT * FROM $TA WHERE Profileid = '$profileid'"); $row = mysql_fetch_array($result); I then want to extract from a second table an id that relates to the code from the first query. I've tried various combinations of: $result = mysql_query("select Primaryid from primarycodes where Code = '$row[Primaryexpertise]'") Associate array indexes should be quoted: $row[Primaryexpertise] //not like this $row['Primaryexpertise'] //like this $row["Primaryexpertise"] //or like this Also, even though simple variable references are expanded within double-quotes (ex. "where Profileid = '$profileid'"), the PHP parser seems to be less certain about how to deal with array indexes: is the square bracket intedned as plain text, as a special character (such as in a regular expression) or is it actually an array index? I find that dropping out of quotes whenever referencing array indexes eliminates a lot of parse errors. For example: "select Primaryid from primarycodes where Code = '" . $row['Primaryexpertise'] . "'" Another option is to use extract() so that the array element can be treated as a simple string variable: extract($row); $result = mysql_query("select Primaryid from primarycodes where Code = '$Primaryexpertise'") String manipulation has me baffled most of the time! Re-read the manual's chapters on strings and arrays. Also check out the Zend site. There are some interesting articles and tutorials over there that address issues not yet adequately covered in the manual. -- CC -- 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] If`s in MySQL.... Having some trouble here...
In article [EMAIL PROTECTED], [EMAIL PROTECTED] ("Trond Erling Hundal") wrote: I want to query two tables in my db. One containing a list of numbers ranging from 1 - 10200, the other table is storing information that is relative to some of the numbers: Eks: Table1.record1: number=1 Table2.record1: number=1 name=John Now I want to query these to tables to show a table that has one column with the numbers, and if there is a name stored in the other table for this number, I want to display this. Try: select table1.number as num, name FROM table1 left join table2 using (number) -- CC -- 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] If expressions in selects....
In article [EMAIL PROTECTED], [EMAIL PROTECTED] ("Trond E. Hundal") wrote: Is it possible to run sql expressions in an if expression??? Eks: IF(table1.id 12, table1.id, 'Not') Do you mean something like "select if(table1.id 12, table1.id, 'Not') from foo where somefield='bar'"? Yes, it's possible. See the mysql.com manual for details. -- CC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] upperCase
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Hoo Kok Mun) wrote: This is what I did and it did not work. $userfield = upper('$userfield'); echo "User Field - $userfield"; Errors (tried both ucase and upper) Call to undefined function: upper() Call to undefined function: ucase() Yep, because you're using the wrong name(s) for the function known as "strtoupper" (confusing PHP functions with those of some other language, perhaps?). BTW, a quick search of the manual or skim through the list of string functions would have revealed the problem--and solution--immediately. -- CC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] php-mySQL and an SQL query
And even without the subquery, the "like" keyword expects a wildcard character or two, for example: LIKE '$month%' " mysql doesn't support sub-queries unfortunately =( At 10:22 PM 3/8/01 -0500, Michael Gerholdt wrote: Hi, folks, Can someone insight me regarding this? I have a datetime field in mySQL (-mm-dd hh:mm:ss) called event_time I want to pull records hitting against this field with the idea: where the abbreviated month from this field LIKE '$month' and here's the SQL string I've been playing with. It works when I comment out the line that tries to do the above with a subquery. $strSQL = "SELECT DATE_FORMAT(event_time, '%M %e %Y, %l:%i %p'), bandname, image "; $strSQL .= "FROM doings, styles "; $strSQL .= "WHERE style = musicstyle "; $strSQL .= "AND bandname LIKE '$artist' "; $strSQL .= "AND style LIKE '$style' "; $strSQL .= "AND (SELECT DATE_FORMAT(event_time, '%b') FROM doings) LIKE ; $strSQL .= "ORDER BY event_time"; echo "$strSQLBR"; $month will be carrying the three-character short version of the alpha month name. -- CC -- 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] array awry
In article 061201c0a063$08eab5a0$[EMAIL PROTECTED], [EMAIL PROTECTED] ("Keith Spiller") wrote: This associative array embedded within a function and declared as a global at the start of the function, is meant to be a multidimensional array, but with every loop of the while ($myrow = mysql fetch row($result)) statement, it's previous values are replaced by the new ones. Any ideas on how I can fix this? If ($Selection == "3") { $tabledata[catid]= $myrow[0]; $tabledata[category] = "$myrow[1]"; $tabledata[under]= $myrow[2]; $tabledata[corder] = $myrow[3]; $tabledata[active] = $myrow[4]; } So what you're saying is that want indexes 'catid', 'category', etc. to have a distinct value for each row pulled from the database? Then you need to add another dimension to that array. -- CC -- 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] Data input
In article [EMAIL PROTECTED], [EMAIL PROTECTED] ("Matthew Cothier") wrote: How can they input the data into the database as they typ eit in without them having to add html .br. tags? nl2br() -- CC -- 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] assoc arrays
In article [EMAIL PROTECTED], [EMAIL PROTECTED] ("Free Beachler") wrote: the form variables from an http post are stored in: http_post_vars[] - associative array containing form variables.. what about url parameters, such as:: http://www.mysite.com?param1=12 is there a corresponding array for them, or do they go in the post_vars array? $HTTP_GET_VARS[] -- CC -- 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] Hide Files
In article 000c01c09ac2$7ed27ab0$0100a8c0@fusion, [EMAIL PROTECTED] ("Fusion") wrote: while ($file name = readdir($dir)) { if (($file name != ".") ($file name != "..") ($file name !="*.php") ($file name !="main.gif") ) { how come that still displays all the *.php files? Are you trying to use '*' as a wildcard character? Because right now, it's only looking to exclude a file with the exact, literal name '*.php'--not files like 'anything.php'. Check out the regular expression functions, either the ereg_* family or preg_*, to do pattern matching. -- CC -- 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] Using include() to specify mysql_connection??
In article 96klap$c8p$[EMAIL PROTECTED], [EMAIL PROTECTED] ("Boclair") wrote: Is it possible to place the mysql connect and mysql select db functions in an include file and to open the connection and use the database in a PHP file using include(); ? All that happens when I attempt it is that the text of the include file is dumped, the connection to the mysql server is not opened and the variables are not created. To be parsed as PHP code, the contents of the included file also need to be in PHP mode ?php ... ?. -- CC -- 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]