Re: [PHP] Re: REsource Identifier( PHP_MYSQL)
Gimic wrote: The entire script looks like this: } function GetVals() { $db = mysql_connect("localhost", "root"); mysql_select_db("books",$db); $result = mysql_query($sqlQry,$db); echo mysql_errno($db); echo mysql_error($db); echo $result; } ?> GetVals() has no ide what is $sqlQry because it is out of its scope. Try this instead GetVals($sqlQry); function GetVals($query) { //Trimmed rest $result = mysql_query($query,$db); //Trimmed } Please cc: your replies to [EMAIL PROTECTED] so others may also contribute. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5RC1 Windows problem
Hi, Trying to run PHP5RC1 on Apache1.3 I get the following error in my syslog: Faulting application Apache.exe, version 0.0.0.0, faulting module php5ts.dll, version 5.0.0.0, fault address 0x0003c773. ... and Apache terminates. Anyone have a solution? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multi-dim array from text file
Larry Pisani wrote: Hi, I need to do some text file manipulation of a text file from an html interface. I have a file with multiple lines where each line has 2 fields each (a mac address and an associated vlan). Here's an example of rht text file: /tmp/TEST: a1b2.c3d4.e5cc VLAN3 a1b2.c3d4.e5dd VLAN4 a1b2.c3d4.e5ee IS a1b2.c3d4.e5ff VLAN6 a1b2.c3d4.e5a1 VLAN7 a1b2.c3d4.e5b2 VLAN8 a1b2.c3d4.e5c3 Printer a1b2.c3d4.e5d4 Guest a1b2.c3d4.e5e5 IS a1b2.c3d4.e5f6 VLAN6 a1b2.c3d4.e5a2 VLAN2 a1b2.c3d4.e5a3 VLAN4 Being an admin and not a developer of any kind, I'm having trouble reading in the file and being able to output specific lines and fields of a php array. [ snip ] Try this $infile = "/tmp/TEST"; $contents = file($infile); if (!$contents) { die("Could not read ".$infile); } $tmp= array(); $lookup = array(); while(list($num,$line) = each($contents)) { $tmp = explode(" ",$line); $lookup[$tmp[0]] = $tmp[1]; } ?> Now you have an array with the "key" being the mac address, and the value being your vlan, something like this (actual output of the snippet above): Array ( [a1b2.c3d4.e5cc] => VLAN3 [a1b2.c3d4.e5dd] => VLAN4 ) You can search this array for the mac address, and then output the associated lan, or you be a bit more on-topic, create a form with the associated data, like so : echo ''; echo 'VLAN Editor'; while(list($mac,$vlan) = each($lookup)) { echo ''; echo $mac; echo ''; echo ''; echo ''; } echo ''; ?> You can add the form bits however you like :) What I want to eventually do is read in the "records" and fields of this file, present it as a form, allow admins to modify the second field and write that back to the text file (while backing up the original file). In order to preserve your original data, I would suggest you make a backup of it first (copy the file if you have to). If you will be doing a lot of read/writes and updates, consider using a database to store the information. [ trimmed rest ] Hope this helps, Burhan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 4.3.5 compiler error
Hi... I'd always use following settings to compile every PHP on my machine (SuSE 8.1) without any problems: ./configure --prefix=/usr/share --datadir=/usr/share/php --bindir=/usr/bin - -libdir=/usr/share --includedir=/usr/include --with-_lib=lib --with-config-f ile-path=/etc --with-exec-dir=/usr/lib/php/bin --disable-debug --enable-bcma th --enable-calendar --enable-ctype --enable-dbase --enable-discard-path --e nable-exif --enable-filepro --enable-force-cgi-redirect --enable-ftp --enabl e-gd-imgstrttf --enable-gd-native-ttf --enable-inline-optimization --enable- magic-quotes --enable-mbstr-enc-trans --enable-mbstring --enable-memory-limi t --enable-safe-mode --enable-shmop --enable-sigchild --enable-sysvsem --ena ble-sysvshm --enable-track-vars --enable-trans-sid --enable-versioning --ena ble-wddx --with-bz2 --with-ftp --with-gdbm --with-gettext --with-gmp --with- imap=no --with-iodbc --with-jpeg-dir=/usr --with-mcal=/usr --with-mysql=/usr --with-ndbm --with-png-dir=/usr --with-xpm-dir=/usr/X11R6 --with-zlib=yes - -with-gd=shared --with-openssl --with-mm --with-apxs=/usr/sbin/apxs Since 4.3.5 I've got a compiler error and I can't fix this problem: ext/ctype/ctype.lo: file not recognized: File truncated collect2: ld returned 1 exit status make: *** [libphp4.la] Error 1 What's wrong? ___ Jan Urbansky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Can't to insert data ( via variable ) into MS-SQL
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Rob Adams wrote: > > > <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > $str = " INSERT INTO staff (name,job,subject) > > 1 2 3 > > > VALUES('$name','$job','$date','$subject',)"; > > 1 2 - 3 > > $date=date('Y-m-d H:i:s'); > > Any idea for me to fix this kind of problem ? I guess I wasn't explicit enough. I would start by chaning your insert statement to: insert into staff (name, job, date_field, subject) values ... (etc.) -- Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Local sysadmin DFW needed
On 26-Mar-2004 Roger Spears wrote: >> > I'm going to guess DFW is just south of BFE > It just seems like it. ;-> -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Can't to insert data ( via variable ) into MS-SQL
Rob Adams wrote: > <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Rob Adams wrote: > > > > > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > $str = " INSERT INTO staff (name,job,subject) > > > 1 2 3 > > > > VALUES('$name','$job','$date','$subject',)"; > > > 1 2 - 3 > > > > $date=date('Y-m-d H:i:s'); > > > > Any idea for me to fix this kind of problem ? > > I guess I wasn't explicit enough. I would start by chaning your insert > statement to: > > insert into staff (name, job, date_field, subject) values ... (etc.) > > -- Rob Hello Rob, Just enable global function of php.ini, then it is ok now ! Thank for your reply ! Edward. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 27 Mar 2004 17:38:21 -0000 Issue 2671
php-general Digest 27 Mar 2004 17:38:21 - Issue 2671 Topics (messages 181605 through 181616): REsource Identifier( PHP_MYSQL) 181605 by: Gimic 181606 by: David Robley 181607 by: Burhan Khalid 181609 by: Gimic 181610 by: Burhan Khalid Re: simple, but missing something? 181608 by: Burhan Khalid PHP5RC1 Windows problem 181611 by: Aidan Lister Re: multi-dim array from text file 181612 by: Burhan Khalid 4.3.5 compiler error 181613 by: Jan Urbansky Re: Can't to insert data ( via variable ) into MS-SQL 181614 by: Rob Adams 181616 by: edwardspl.ita.org.mo Re: Local sysadmin DFW needed 181615 by: Don Read Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- --- Begin Message --- Hey y'all, I'm having problems trying to get the MySql_Query() function to return the resource ID when using a $string as the argument to pass to it. It returns when I hard code the argument but not the string. Any ideas? here is what the function looks like: function GetVals() { $db = mysql_connect("localhost", "root"); $str_Query=("Select * from " . $subject); mysql_select_db("books",$db); $result = mysql_query($str_Query); echo $result; } but when I use the query: $result=mysql_query("Select * from math") it works. Am I setting my string up wrong? Because it's not running into any errors when I do this. --- End Message --- --- Begin Message --- [EMAIL PROTECTED] (Gimic) wrote in news:[EMAIL PROTECTED]: > Hey y'all, I'm having problems trying to get the > MySql_Query() function to return the resource ID when using a $string > as the argument to pass to it. It returns when I hard code the > argument but not the string. Any ideas? here is what the function > looks like: > > function GetVals() { > $db = mysql_connect("localhost", "root"); > $str_Query=("Select * from " . $subject); > > mysql_select_db("books",$db); > > $result = mysql_query($str_Query); > echo $result; > > } > but when I use the query: > $result=mysql_query("Select * from math") it works. Am I setting my > string up wrong? Because it's not running into any errors when I do > this. > The string $subject is almost certainly empty, as it is not passed as an argument to the function, nor is it declared global in the function. Try a little debugging, echoing your query and the output of mysql_error. For example: function GetVals() { $db = mysql_connect("localhost", "root"); $str_Query=("Select * from " . $subject); mysql_select_db("books",$db); $result = mysql_query($str_Query); echo "Query: $str_query".mysql_error(); echo $result; } Then either pass $subject as an argument to the function, or declare it global within the function. Lastly, if $string is passed from another script, make sure it is populated via the GET or POST globals. --- End Message --- --- Begin Message --- Gimic wrote: Hey y'all, I'm having problems trying to get the MySql_Query() function to return the resource ID when using a $string as the argument to pass to it. It returns when I hard code the argument but not the string. Any ideas? here is what the function looks like: function GetVals() { $db = mysql_connect("localhost", "root"); $str_Query=("Select * from " . $subject); mysql_select_db("books",$db); $result = mysql_query($str_Query); echo $result; } but when I use the query: $result=mysql_query("Select * from math") it works. Am I setting my string up wrong? Because it's not running into any errors when I do this. First thing, how would you know if it was returning any errors or not? Try mysql_errno() and mysql_error(). Secondly, I suspect that your "string" is not what you think. print_r($str_Query); and see what its giving you. --- End Message --- --- Begin Message --- The entire script looks like this: Where the name of the table is stored in the $_POST varible. The string isn't empty, yet it is empty. It may be a bug... Or do any of you see any problem with my varible scope? because I don't. "Gimic" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hey y'all, I'm having problems trying to get the > MySql_Query() function to return the resource ID when using a $string as the > argument to pass to it. It returns when I hard code the argument but not the > string. Any ideas? here is what the function looks like: > > function GetVals() { > $db = mysql_connect("localhost", "root"); > $str_Query=("Select * from " . $subject); > > mysql_select_db("books",$db); > > $result = mysql_query($str_Query); > echo $result; > > } > but when I use the query: > $result=mysql_query("Select * from math") it works. Am I setting my string > up wrong? Because it's not running into any errors when I do this. --- End Message --- --- Begin Mes
[PHP] Convert string and char in unicode format
Dear All, How to control php / freetds to convert data ( query / insert ) to unicode format ? Thank for you rhelp ! Edward. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] slow script
Hi all. I am developing a system using php 4.3.2 + apache 1.3.29. The db is a mssql msde (were going to mysql, but not yet due to some internal reasons). All things are running in a local, standalone station, because we had to use the app on line and off line states. The off-line one should have all stuff, so. It just connect to internet to send a data replication. The stations are windows 98. The problem is: I have to run this stuff in small boxes, like some pentium 200mhz with 64-80mb ram, and in these machines the system is very slow. The html page takes about 70 seconds to be showed in the browser. I saw cpu and ram, and are all normal, even the mssql. Just the apache activity goes up to 70% cpu. We notice that while the php is running, anything happens and suddenly(after ~70 seconds) the page arises. Our php code is a kind of big, about 160kb, and the html is generated equally big. I am going to break the jscript stuff it in some small peaces, but will not help to much, I guess. Well, if someboddy could point out me a way, a tip or a tool to discover what the script is doing while I am waiting its response, or just an ideia, I would really thank you. Gustavo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] slow script
> 200mhz with 64-80mb ram, and in these machines the system is very > slow. Sorry dude you just answered your question. Also aparantly ODBC is slow. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] slow script
Gustavo, 1) Read the manual - though I can understand how you might have missed this: http://us2.php.net/manual/en/function.microtime.php Basically, there's a function based on microtime that does benchmarking. This is vital to timing your script. Use it extensively. If you're not sure where to start, break your script into chunks and figure out where most of your time is being spent. 2) Evaluate where time is being spent. If it's on database-access-bound portions, not a lot you can do from the PHP-end. 3) Evaluate the remainder of your code. In many tight loops (many iterations, not a lot of actual processing per iteration), particularly those modifying arrays, I get much better performance using while() or for() loops instead of foreach() generally. Obviously, this isn't always applicable, but I have found few ways to optimize GD image manipulations while I've found plenty for tight loops, so I'm only giving you suggestions on what I know. 4) Consider some overall performance enhancing stuff. Like the Zend Optimizer (free) which can sometimes help a lot, sometimes not at all. Also I'd say turckmmcache or something like that, but I'm pretty sure there's no Windows 98 version. 5) Evaluate your code. 160 KB (kilobytes, I'm assuming) is a pretty huge amount of PHP code for data replication. I hope that lots of it is content-type things and not all PHP commands, otherwise I would guess (though I could be wrong - some applications are very complex) that you are not coding efficiently. Very few of my projects even approach 160 KB of pure PHP, even things as massive as a complete online store creation and management application I developed not too long ago. Good luck! Re-post to php-general if you have further questions! -Galen On Mar 27, 2004, at 1:43 PM, Luis Gustavo Faccioni Barcellos wrote: Hi all. I am developing a system using php 4.3.2 + apache 1.3.29. The db is a mssql msde (we’re going to mysql, but not yet due to some internal reasons). All things are running in a local, standalone station, because we had to use the app on line and off line states. The off-line one should have all stuff, so. It just connect to internet to send a data replication. The stations are windows 98. The problem is: I have to run this stuff in small boxes, like some pentium 200mhz with 64-80mb ram, and in these machines the system is very slow. The html page takes about 70 seconds to be showed in the browser. I saw cpu and ram, and are all normal, even the mssql. Just the apache activity goes up to 70% cpu. We notice that while the php is running, anything happens and suddenly(after ~70 seconds) the page arises. Our php code is a kind of big, about 160kb, and the html is generated equally big. I am going to break the jscript stuff it in some small peaces, but will not help to much, I guess. Well, if someboddy could point out me a way, a tip or a tool to discover what the script is doing while I am waiting its response, or just an ideia, I would really thank you. Gustavo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Measurement Problem
Hi, I am working on a PHP/MySQL solution to have a webpage where users can rate cigars. I ran into a problem though. One variable that exists is the length of the cigar. In the cigar world, the lengths are usually written like 6 1/8" or 155 mm or 4 15/16" or 125 mm. I don't want to make the length column in the database be a string with data like "6 1/8"" in it, because as the user submits cigars, different users could type it a different way, screwing up searches that are searching by length. I also want to have a real time metric conversion as well. So my question is, how should I do this? Should I have a float column with the lengths as mm and it converts it to inches? If so, then how would I convert 155.57500mm to 6 1/8", or 155mm to 6 1/8". It's hard to explain, but I can't come up with a good solution. Please ask if you need clarification. Any help is much appreciated! Thanks! Karl -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql table field choices
just a short one here... what would be the best type of field for a combo box that looks like this: ---pick a month--- January February and the same thing with the year... was thinking either int(2) for the month and int(4) for the year but would enum(1, 2, 3, 4...12) be better for the month and enum(2004, 2005, 2007) be better for the year?? dont know what one of those would be better/faster... and was thinking of timestamp(14) for the result of this function: /* StartTime: create a timestamp parameters: $day: text representation of the day of the month. examples: "next week", "third monday", "fourth saturday", and so on $month: valid month number of the year. valid values are 1-12 (without the leading 0). $year: any valid 4 digit year between 1970 and 2038 discription: StartTime(string day, int month, int year); return values: if successful returns a valid timestamp in the form of the total number of seconds between jan 1, 1970 and the time created. otherwise returns false if failed.*/ function StartTime($day, $month, $year) { if(!empty($day) && !empty($month) && !empty($year)){ //convert $day, $month, and $year into a valid timestamp $time= strtotime($day, mktime(0,0,0,$month,1,$year)); return $time; } else { return false; }}
Re: [PHP] Measurement Problem
On Sat, Mar 27, 2004 at 07:55:31PM -0700, Karl Timmermann wrote: > Hi, > > I am working on a PHP/MySQL solution to have a webpage where users can > rate cigars. I ran into a problem though. One variable that exists is > the length of the cigar. In the cigar world, the lengths are usually > written like 6 1/8" or 155 mm or 4 15/16" or 125 mm. I don't want to > make the length column in the database be a string with data like "6 > 1/8"" in it, because as the user submits cigars, different users could > type it a different way, screwing up searches that are searching by > length. I also want to have a real time metric conversion as well. > > So my question is, how should I do this? Should I have a float column > with the lengths as mm and it converts it to inches? If so, then how > would I convert 155.57500mm to 6 1/8", or 155mm to 6 1/8". It's hard to > explain, but I can't come up with a good solution. Please ask if you > need clarification. > > Any help is much appreciated! > > Thanks! > Karl > How about a drop down menu with valid lengths in them? That way you can control what the user enters. -- Jim Kaufman Linux Evangelist public key 0x6D802619 http://www.linuxforbusiness.net --- If you can't learn to do it well, learn to enjoy doing it badly. -- Ashleigh Brilliant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Measurement Problem
How about a MySQL table, like you're saying, with the lengths? Two columns: English and Metric. Then just do a select metric where english = 6 1/8 (my pseudo-SQL) with MySQL and get the length. I suspect there are only a limited number of standard lengths and this would work nicely. You could also do a standard mathematical metric-english conversion and then round to the nearest five. That might do the trick also, it would require less data input but there is the slight chance (you'd have to check examples) that you'll find some instance in which it produces the incorrect number. The trickier part will be going in the opposite direction, although that too is manageable. Good luck! -Galen On Mar 27, 2004, at 6:55 PM, Karl Timmermann wrote: Hi, I am working on a PHP/MySQL solution to have a webpage where users can rate cigars. I ran into a problem though. One variable that exists is the length of the cigar. In the cigar world, the lengths are usually written like 6 1/8" or 155 mm or 4 15/16" or 125 mm. I don't want to make the length column in the database be a string with data like "6 1/8"" in it, because as the user submits cigars, different users could type it a different way, screwing up searches that are searching by length. I also want to have a real time metric conversion as well. So my question is, how should I do this? Should I have a float column with the lengths as mm and it converts it to inches? If so, then how would I convert 155.57500mm to 6 1/8", or 155mm to 6 1/8". It's hard to explain, but I can't come up with a good solution. Please ask if you need clarification. Any help is much appreciated! Thanks! Karl -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php