RE: [PHP-DB] Can't Insert more than 1 record
Hello All, I am having a problem inserting records into my Database. I am passing fields from a FORM to my php program that adds 1 record to my DB. It will create the first attempt just fine, however any attempt after the 1st fails. I have to delete the existing row in order to add a new record. Anyone know what I am doing incorrectl? KJ Do you have unique indexes on your table? On each insert are you sure that the unique index columns are actually unique? What errors do you get on the second++ inserts? Rich -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] DB CODEING HELP!!!!!
this is bugging me. I have tried everything and I cant develop the code without an error. Can someone plese write me simple code that will go through a table and print 3 collums of that table? I cant figure it out I don't know which database you're using but say for example it was MySQL here's a very quick and dirty example ? $link = mysql_connect('localhost','user','password') or die(mysql_error()); if (mysql_select_db('mydatabase',$link)) { $rs = mysql_query('select col1, col2, col3 from mytable') or die (mysql_error()); $num = mysql_num_rows($rs); for ($i=0;$i$num;$i++) { $row = mysql_fetch_assoc($rs); echo 'Col 1: '.$row['col1'].' Col 2: '.$row['col2'].' Col 3: '.$row['col3'].'br /'; } } mysql_close($link); ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] PHP script execution - display issue
Hello, I have a display problem with one of my sites. Because there is an big amount of information in the pages, which is extracted from database, using IE browser I see only the background of the site, and then, after a time, the whole page. My client has recently requested to make something to improve the site speed and display time. So because all the site is done using the classes, and the information is extracted through them, I reduced the instruction numbers, and I compacted as much as I could the classes. But I still have the display problem using IE browser : I see the background, and just after that I see the whole site. I mention that the classes are included, and the class function is called through $this_class-function($parameters); Not all the classes used in the page are called In the beginning; and another mention is that the site pages contains 4 sections. Top, left, middle, right. My question is: Is there a way to display sequentially the site. After the background, to display the first section (top), then left part, middle part and right part after that ? Again, the site loads like this : the background, then the whole page. This doesn't matter if I use dial-up or T1. My client saw, for example, that cnn or yahoo site loads sequentially. Knowing that yahoo is done in php, I'm wondering how they did it. Thanks Petre Nicoara Try flush() http://www.php.net/manual/en/function.flush.php HTH Rich -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Real Killer App!
I'm having a heck of a time trying to write a little web crawler for my intranet. I've got everything functionally working it seems like, but there is a very strange problem I can't nail down. If I put in an entry and start the crawler it goes great through the first loop. It gets the url, gets the page info, puts it in the database, and then parses all of the links out and puts them raw into the database. On the second loop it picks up all the new stuff and does the same thing. By the time the second loop is completed I'll have just over 300 items in the database. On the third loop is where the problem starts. Once it gets into the third loop, it starts to slow down a lot. Then, after a while, if I'm running from the command line, it'll just go to a command prompt. If I'm running in a browser, it returns a document contains no data error. This is with php 4.3.1 on a win2000 server. Haven't tried it on a linux box yet, but I'd rather run it on the windows server since it's bigger and has plenty of cpu, memory, and raid space. It's almost like the thing is getting confused when it starts to get more than 300 entries in the database. Any ideas out there as to what would cause this kind of problem? Nick Can you post some code? Are your script timeouts set appropriately? Does memory/CPU useage increase dramatically or are there any other symptoms of where it is choking...? What DB is it updating? What does the database tell you is happening when it starts choking? What do debug messages tell you wrt finding the bottleneck? Does it happen always no matter what start point is used? Are you using recursive functions? Sorry lots of questions but no answers... :) Cheers Rich -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Output a few tupels of 493033 tupels
Hello, I have got a little problem with my datas. In one table I have got 493033 tupels. A simple Output of all datas is to much for the Browsers (and the intranet-connection) and to ask for all and then only give out a few is also a big problem for the server. Is there any way only to ask for some tupels in a postgres-database with PHP? H. Etzel IIRC Postgres supports the limit and offset options on a select statements so how about - for 100 rows starting at the first row... select * from mytable limit 100, 0 Rich -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] I'm almost there! Just a little more help
Below is all of my code. The first is my html page that calls my php page. I do not know php well enough to edit the code to make this work. I need the image to go to a folder called logos on my C drive. The actual path is: C:\Program Files\Apache Group\Apache2\htdocs\logos Could someone please make the changes to my code so that it will work! Thank you Thank you!!! HTML Page*** html form action=fileupload2.php method=post enctype=multipart/form-data submit this file: input type=file name=userfilebr rename to: input type=text name=newnamebr input type=submitbr /form /html **PHP Page * How about... this ? if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { move_uploaded_file($_FILES['userfile']['tmp_name'],$_SERVER['DOCUMENT_ROOT'] .'/logos'); } ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Populate Array During Loop With in_array
Can somebody please tell me why the $displayThese variable in the code snippet below only gets populated with the last value in the $newsList array even when $newsList has more than one row of data? while($newsList = mysql_fetch_array($result_getNews)){ if($convReadList != ){ for($i = 0; $i $countNewsItems; $i++){ if (!in_array($newsList[$i], $convReadList)){ //echo $newsList[$i]. was found\n; $displayThese[$i] = $newsList[$i]; } } } else{ echo preadList is empty/p; } } print_r($displayThese); You're resetting $i back to 0 for each row returned from the database. So if there are multiple rows (which you say there are) then the array entries will get overwritten each time... HTH Rich -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: [PHP] Random not working?
Hi All, I'm trying to get a random record each time this script runs; Only it's giving me everytime the first record back.. No random at all.. // generate and execute query $query = SELECT stedenid, naamstad, stadomschrijvk FROM steden ORDER BY RAND() LIMIT 1; $result = mysql_query($query) or die (Error in query: $query. . mysql_error()); $row = mysql_fetch_object($result); echo $row-naamstad; Version info; PHP 4.3.1 Mysql 3.23.54 When i'm trying to excute the SELECT statement in phpmyadmin; i'm only getting the first record back and when i'm taking off the LIMIT 1 it will display all the records in ascending order so also not in random.. Regards, Frank Frank This really belongs on the MySQL list but there was a known issue with RAND() on 3.23.54 - can you upgrade? If your table has an auto_increment ID column then a workaround would be to use rand() in PHP to generate a random ID then use that with a 'where id = '.$id in your query... HTH Rich -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Storing images in MySQL table
Pedro Er ... probably - I've not tested it personally. However, if you output the image directly from a database then your script is sending the http headers for content type etc and the browser has no choice but to render what you send. With HTML based img src=blah stuff it'll try to pull the image from cache in most cases - you can fool it with a dummy query string however to force a local cache bypass... HTH Cheers Rich And i've heard the server or client does not cache db stored images, while it caches them in as separate files. True ? -- Regards, Pedro MG www.tquadrado.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Session variables when global variables switched off [Sorry, first message accidentally fired off to quickly ]
Hi Jeff Don't use session_register() just use the $_SESSION superglobal as you would use any other array. So does this work? ? //index.php session_start(); // Login stuff done OK $_SESSION['verified'] = true; ? ? // Other pages needing a valid login session_start(); if (!isset($_SESSION['verified'])) { // push user back to login page header('Location: http://mysite/index.php'); exit(); } ? HTH Rich -Original Message- From: Baumgartner Jeffrey [mailto:[EMAIL PROTECTED]] Sent: 18 February 2003 11:20 To: '[EMAIL PROTECTED]' Subject: [PHP-DB] Session variables when global variables switched off [Sorry, first message accidentally fired off to quickly ] [sorry for the incomplete posting of a couple moments ago. I hit ctl something or other and outlook fired off the e-mail against my wishes!] I am making a section on a web site which requires that visitors log-in. Log-in, password, etc are in an MySQL table. I am using (via a web host) PHP 4.2.2 with global variables turned off. Until now, I have worked with a different host in which global variables were switched on. The way it works The user logs in at index.php. When she does so successfully, index.php returns a menu of links. However, if she clicks on any of those links, which are different pages, she gets a please log-in first message because each page includes... if ($_SESSION['verified'] yes){ echo Pa href='index.php'Please log in first/a/P; exit(); } Returning to index.php requires a log-in again. So, it seems the session variable is not being sent being sent between pages, although it works within the same page. I expect I am missing something obvious. I've made this kind of thing work with global variables on - so I assume I am misunderstanding something related to lack of global variables. I use session_start(); at the top of all pages and session_register($_SESSION['okbabe']); on index.php. Your enlightenment will be highly appreciated. Jeffrey Baumgartner -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Sorting Arrays
Mark Not exactly sure what you're after but will array_multisort() help? http://www.php.net/array_multisort Rich -Original Message- From: Mark @ Webbiz NZ [mailto:[EMAIL PROTECTED]] Sent: 28 January 2003 05:10 To: [EMAIL PROTECTED] Subject: [PHP-DB] Sorting Arrays Hello, I don't understand arrays that well. If someone can help me sort the contents it would be appreciated. I have data being retrieved from a text file and the fields as an array inserted into another array. orderby is numeric is 1-99 and requires sorting ASC content is just formatted html for instance : While Loop $a++ Get Data content orderby $marray[$a] = Array(content=$msort , orderby=$orderby[1]); End After this data is retrieved I would like to sort the information by the orderby field. Then the information is printed from the content field as per the sorted order foreach ($marray as $val) { echo $val['content']; } If someone can help me out, this would be appreciated. Regards Mark NZ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Error
Hi Jordan Made any recent changes to your network configuration? Can you access other IP ports OK e.g. http port 80? Do you have any firewall protection on your PC? Can you access MySQL from the command line OK? Rich -Original Message- From: JordanW [mailto:[EMAIL PROTECTED]] Sent: 28 January 2003 04:37 To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL Error I'm getting this error message when I try the following code: $link = mysql_connect(localhost) or die(Could not connect); print (Connected successfully); mysql_close($link); The scripts outputs: Warning: Can't create TCP/IP socket (10106) in C:\Projects\WebServer\admin.php on line 3 Warning: MySQL Connection Failed: Can't create TCP/IP socket (10106) in C:\Projects\WebServer\admin.php on line 3 Could not connect Any ideas? Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Filling Fields
have you tried str_repeat()? Rich -Original Message- From: Chezney [mailto:[EMAIL PROTECTED]] Sent: 19 January 2003 08:47 To: [EMAIL PROTECTED] Subject: [PHP-DB] Filling Fields Hi Can some one please tell how I can fill and entire field with the same value. Maybe in a loop or is there a command. Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Secure variable transport (newbie)
Karina Use the superglobal $_SESSION[] array together with session_start(). $HTTP_SESSION_VARS[] is not a super global. Rich -Original Message- From: Karina S [mailto:[EMAIL PROTECTED]] Sent: 22 January 2003 23:30 To: [EMAIL PROTECTED] Subject: [PHP-DB] Secure variable transport (newbie) Hi, I have read, that use global variables on php site is not a good idea. I'm newbie in PHP and maybe a stupid question: If I make an array and register it in a session and after I use it all of my pages as $HTTP_SESSION_VARS['variable'] and register_globals is off. In this case is $HTTP_SESSION_VARS['variable'] a global variable? What is the best method (most secure method) to use the same array on all php site? (I want to read the user data, but don't want to read it always from database. I want to read once and use it on more pages. ) Thanks for your help! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Data won't insert
Jeffrey Most probably site 2 has register_globals set to Off whilst site 1 has them set to On... Try using $_POST['name'] for $name, $_POST['age'] for $age and $_SERVER['PHP_SELF'] for $PHP_SELF Cheers Rich -Original Message- From: Baumgartner Jeffrey [mailto:[EMAIL PROTECTED]] Sent: 23 January 2003 10:42 To: [EMAIL PROTECTED] Subject: [PHP-DB] Data won't insert I've learned the basics of PHP and MySQL by using a web hosting service over the past few weeks. Call this site 1. And I am finally feeling that I am getting the hang of things. Now, another web host that I have been using is letting me try out PHP and MySQL on their server. Call this site 2. The problem I am having is that if I take pages with php scripts from site 1; change the user, password and database names; and upload them to site 2 - data does not insert into tables. However, the scripts are connecting to the database (no die messages or other error messages are appearing) and the tables have been prepared via phpmyadmin without problem. Likewise, I can insert data via phpmyadmin without problem. Below is a sample script that is causing such a problem. I appreciate that it is sloppy (it was one of my first). But it works on site 1 and not site 2. Could this be a matter of the permissions the site 2 web host has granted me? And if so, why can I do things with phpmyadmin but not via my own scripts? Many thanks, Jeffrey Baumgartner ?php $dbcnx = mysql_connect(localhost, USER, PASSWORD); $db = mysql_select_db(TABLENAME, $dbcnx) or die(Couldn't get DB); If (isset($name)) { echo P . $name . /p P . $age . /p; } ? FORM ACTION=?php echo($PHP_SELF); ? METHOD=POST P Name: INPUT TYPE=TEXT NAME=name SIZE=62/p P Age: INPUT TYPE=TEXT NAME=age SIZE=8/p INPUT TYPE=SUBMIT NAME=submitInfo VALUE=Submit ?php if (isset($name)) { $query = INSERT INTO formtest (name,age) VALUES ('$name' , '$age') ; if (mysql_query($query)){ echo P . $name . /p P . $age . /p; } else { echo (pTough cookies, sunshine/p); exit(); } } ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Fatal error message
Jon Based on your include path does the script exist in any of these locations on your server? = /var/www/html/addrbk/Connections/addrbk.php or = /php/includes/Connections/addrbk.php = /usr/share/pear/Connections/addrbk.php If not then that's your problem, else you need to start looking at file/directory permissions... Your include_path setting in php.ini tells php where to look for scripts if a non absolute path is specified on a include/require statement. In your case it will first look in the including script's directory, then the directory /php/includes then the directory /usr/share/pear... Rich -Original Message- From: Jon Miller [mailto:[EMAIL PROTECTED]] Sent: 16 January 2003 10:03 To: [EMAIL PROTECTED] Subject: [PHP-DB] Fatal error message I get the following when loading a php file created by Dreamweaver MX using MySQL database and php. Fatal error: Failed opening required 'Connections/addrbk.php' (include_path='.:/php/includes:/usr/share/pear') in /var/www/html/addrbk/frmAddr.php on line 1 For the include_path I've used include_path = .:/php/includes and still get the same error. I'm not too sure what this path is supposed to be pointing to. Can someone enlighten me on this? setup info: MySQL is on a Linux 7.3 server PHP is on the same server Dreamweaver MX is on Windows 2000. Everything work fine as for as creating the form, just when try to run it I get the message. I should mentioned I just copied the file created to the linux location where the files are supposed to be. Thanks Jon L. Miller, MCNE, CNS Director/Sr Systems Consultant MMT Networks Pty Ltd http://www.mmtnetworks.com.au I don't know the key to success, but the key to failure is trying to please everybody. -Bill Cosby -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Dynamic Table Front End
You didn't mention it so did you check http://www.phpclasses.org - there's a lot of good stuff there - you will need to register however. HTH Rich -Original Message- From: Hutchins, Richard [mailto:[EMAIL PROTECTED]] Sent: 10 December 2002 14:52 To: [EMAIL PROTECTED] Subject: [PHP-DB] Dynamic Table Front End List, I've been looking on and off for now for a class or plug-in or something that will allow an application user to define table specifications (#rows, #columns, spanning, etc) then allow them to enter table data (headers, body data, title, footer, etc.) in a graphical representation of the table they specify. I'd then use PHP to handle data formatting/grouping/ordering prior to sending it to a MySQL db. I could probably build it myself, but I'd like to save some time and maybe get more functionality than I could come up with by using en existing widget. This should not be something like phpmyadmin or whatever as the application users will not be maintaining the actual MySQL db, just constructing their own tables for presenting data. I've checked sourceforge, phpbuilder, javascriptsource, etc and found a couple, but none that are what I'm looking for. Anybody here use anything like what I'm trying to describe? I'm not looking for anybody to do my work for me, just make some recommendations on what they have used and liked/disliked. Thanks in advance for any feedback. Rich Hutchins Sr. Technical Writing Administrator Getinge/Castle, Inc. 1777 E. Henrietta Rd. Rochester NY 14623 585-272-5072 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MSSQL Text Length Restriction
Adam IIRC this is a known problem with the native php SQL Server APIs which were built using the original TDS drivers based on v6.x of SQL Server which did not support NVARCHAR data types... if you can't change the datatype to TEXT then try a cast. Failing that does it work if you use ODBC instead? Rich -Original Message- From: Adam Voigt [mailto:[EMAIL PROTECTED]] Sent: 10 December 2002 15:18 To: [EMAIL PROTECTED] Subject: [PHP-DB] MSSQL Text Length Restriction I can't seem to get more then 255 characters to be sent back from a field in our MSSQL database, unless the fields is a TEXT type, which is very inefficient. Anyone know a fix? (I've already tried modifying the max size variables in the php.ini under the MSSQL section.) -- Adam Voigt ([EMAIL PROTECTED]) The Cryptocomm Group My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MSSQL Text Length Restriction
Adam IIRC this is a known problem with the native php SQL Server APIs which were built using the original TDS drivers based on v6.x of SQL Server which did not support NVARCHAR data types... if you can't change the datatype to TEXT then try a cast. Failing that does it work if you use ODBC instead? Rich -Original Message- From: Adam Voigt [mailto:[EMAIL PROTECTED]] Sent: 10 December 2002 16:01 To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: [PHP-DB] MSSQL Text Length Restriction Uncommented, and set to the max value (2147483647). No effect. On Tue, 2002-12-10 at 10:57, [EMAIL PROTECTED] wrote: Adam. are these lines uncommented in your php.ini? They are under [MSSQL] ; Valid range 0 - 2147483647. Default = 4096. ;mssql.textlimit = 4096 ; Valid range 0 - 2147483647. Default = 4096. ;mssql.textsize = 4096 sorry, i'm not replying to the other email. i deleted it accidentally -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Still having problems...?!
Is PHP running as a module in Apache/IIS? If yes then you will need to bounce your web server to pick up the new ini settings... Rich -Original Message- From: Hartleigh Burton [mailto:[EMAIL PROTECTED]] Sent: 10 December 2002 14:01 To: [EMAIL PROTECTED] Subject: [PHP-DB] Still having problems...?! Thanks John and Cornelia for a fast response :). I have edited my ini file as you suggested, and I changed the code around a bit and experimented a bit more with it, but I still have some problems. This is exactly how the file looks; ? // page1.php session_start(); $_SESSION[real_name] = Hartleigh Burton; print a href='page2.php'Go to this page/a; ? Nothing more, nothing less. But the problem I am receiving does not seem to be based on the PHP, here is the error. Warning: open(/tmp\sess_1df563d6d8c8b4b16534c438251e7107, O_RDWR) failed: No such file or directory (2) in E:\Webroot\tutorial\page1.php on line 3 Warning: open(/tmp\sess_1df563d6d8c8b4b16534c438251e7107, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct ***(/tmp)*** in Unknown on line 0 This is the php.ini line; session.save_path = e:\webroot\tmp, and i have created the directory tmp in that location. i tried both \'s and /'s for that line, not sure as to whether they do any difference or not, and restarted the server service both times. Hartleigh Burton www.channel-x.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Select Last row
Does 'select * from table order by id desc limit 1' do what you want? HTH Rich -Original Message- From: Afif [mailto:[EMAIL PROTECTED]] Sent: 21 November 2002 01:49 To: PHP DB Subject: [PHP-DB] Select Last row dear All, I have data and I want to get the last row of my table. how to select the last row, with the id is timestamp? and the the result will display in the prompt? sorry if my question is sound stupid, but I really confuse how to start this code -- Warm regards, Afif mailto:[EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] HTML Forms question...
If you name the checkbox as name=system[] then PHP will automatically create an array of the checkbox values which can be subsequently accessed via $_POST['system'][n] - be warned however that the '[]' can screw up any JavaScript code that refers to the checkbox object... HTH Rich -Original Message- From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]] Sent: 19 November 2002 08:53 To: 'Ryan Jameson (USA)'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] HTML Forms question... OK. If I am using the POST method and the checkbox 'name' for all of the checkboxes is 'system', how do I access the results? I am researching on the PHP site trying to figure out what this array is, and how I access this if the index name is the same for all elements. I am hoping that this data will be in an array and I can simply loop through the contents of the array. If this data is stored in a hash (Perl word for this type of array, not sure if it's the same in PHP), how do I access this data since the index for every element would be the same? I am SURE that I am probably missing some important conceptual issues here, but still learning as I go. Unfortunately, this probably means that I will be completely rewriting this application at least once in the future. Oh well, live and learn. Thanks again for the help. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php