Re: [PHP]MySQL error, what's wrong here..
try this: $query = "SELECT songname FROM mp3 WHERE sgid = \"$id\""; (or a little cleaner: $query = sprintf("SELECT songname FROM mp3 WHERE sgid = \"%d\"", $id); ) instead of: $query = "SELECT songname FROM mp3 WHERE sgid = " .$id; - Original Message - From: "James Holloway" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, July 24, 2001 11:05 AM Subject: Re: [PHP]MySQL error, what's wrong here.. > Hi Chris, > > If you're using MySQL 3.23+, you might want to consider using something > like: > > SELECT songname FROM mp3 ORDER BY RAND() LIMIT 1 > > Not that this answers your original problem, but it seems to make more sense > than manually coding a random number (which is, perhaps, impractical > especiallyif you plan to add / take away entries to your table on a regular > basis). > > James > > "Chris Cocuzzo" <[EMAIL PROTECTED]> wrote in message > 014d01c113ca$dd3bf460$[EMAIL PROTECTED]">news:014d01c113ca$dd3bf460$[EMAIL PROTECTED]... > > > $id = rand(1,2); > > $query = "SELECT songname FROM mp3 WHERE sgid = " .$id; > > $result = mysql_query($query,$connection); > > $mp3d = mysql_fetch_array($result); > > ?> > > > > the server is telling me line 43(which starts with $mp3d) is not a valid > > mysql result resource. what am i doing wrong?? > > > > chris > > > > > > -- > PHP General 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 General 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] execution time
http://www.php.net/manual/en/function.set-time-limit.php the set_time_limit allows you to reset the max execution time.. the manual says: When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out. Wagner Tomy Editus S.A. - Original Message - From: "Pétur Björn Thorsteinsson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, July 27, 2001 2:03 PM Subject: [PHP] execution time > > I have a slight problem and was wondering if anyone could help. > > I have a php script that runs every 30 minutes. It takes the contents of a > directory (which is constantly being updated) and dumps them into a mysql > database. Recently this directory has become increasingly large and the php > script only updates a portion of it before it stops execution. > > To run the php script I use a lynx command in a crontab. I'm running suse > linux and apache on both machines (the machine containting the directory > and the other machine containing the database). > > I've tried changing the max execution time in php.ini file but it appears > to have no affect. When I took the php script and divided it into portions > and ran them one at a time it worked (except for one portion of the > script). the execution time of the script doesn't matter to me, I just need > it to run. > > When I run the php script through a browser, and the script doesn't > complete, I get a 'page cannot be displayed' message (while I am expecting > a 'fatal error, exceeded max execution time' error message). > > Maybe it could be fixed by using something other than lynx to run the php > script internally, but I don't know of any alternatives. > > hope someone can help.. > > > -petur > > > > -- > PHP General 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 General 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] 2D array
$my2darray = Array(); while($row = mysql_fetch_row($result)) { array_push($my2darray, $row); } OR: for($i = 0; $i < mysql_num_rows($result); $i++) { $row = mysql_fetch_row($result); $my2darray[$i] = $row; } Wagner Tomy Editus S.A. - Original Message - From: "AJDIN BRANDIC" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, July 27, 2001 2:18 PM Subject: [PHP] 2D array > Hi > > I have been trying to do this for hours now. > I have a while loop (rows from mysql db) and on each pass I want to pussh > a new element into a 2D array, bot always end up with the last element of > the while loop. So: > > table mytable > myname myphone myemail > john 254688 [EMAIL PROTECTED] > tom789787 [EMAIL PROTECTED] > > $myquery="select * from mytable"; > > while ($myrow = mysql_fetch_array($myrows)) { > .. .. . . . > > $my2darray = array ($myname => array ($myphone,$myemail)); > > } > > $mycount=count(my2darray); // returns 1 > > while (list($key,$value) = each ($my2darray)) { > echo"$key,"; > echo"$value[0]"; > echo"$value[1]"; > // retuns only one row with tom,798779,[EMAIL PROTECTED] > } > > How do I push multiple entries into a 2d array? > > I tried $my2darray[]=array(... > > Regards > > Ajdin > > -- > PHP General 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 General 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] 2D array
$my2darray = Array(); while(list($myname, $myphone, $myemail) = mysql_fetch_row($result)) { $my2darray[$myname] = array($myphone, $myemail); } Wagner Tomy Editus S.A. - Original Message - From: "AJDIN BRANDIC" <[EMAIL PROTECTED]> To: "Wagner Tomy" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Friday, July 27, 2001 2:34 PM Subject: Re: [PHP] 2D array > Wag, > > I do not wish to push whole of the row into an array. > Also I need the id of the parent array to be $myname; > > Ajdin > > On Fri, 27 Jul 2001, Wagner Tomy wrote: > > > $my2darray = Array(); > > > > while($row = mysql_fetch_row($result)) { > > array_push($my2darray, $row); > > } > > > > OR: > > > > for($i = 0; $i < mysql_num_rows($result); $i++) { > > $row = mysql_fetch_row($result); > > $my2darray[$i] = $row; > > } > > > > Wagner Tomy > > Editus S.A. > > > > - Original Message - > > From: "AJDIN BRANDIC" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Friday, July 27, 2001 2:18 PM > > Subject: [PHP] 2D array > > > > > > > Hi > > > > > > I have been trying to do this for hours now. > > > I have a while loop (rows from mysql db) and on each pass I want to pussh > > > a new element into a 2D array, bot always end up with the last element of > > > the while loop. So: > > > > > > table mytable > > > myname myphone myemail > > > john 254688 [EMAIL PROTECTED] > > > tom789787 [EMAIL PROTECTED] > > > > > > $myquery="select * from mytable"; > > > > > > while ($myrow = mysql_fetch_array($myrows)) { > > > .. .. . . . > > > > > > $my2darray = array ($myname => array ($myphone,$myemail)); > > > > > > } > > > > > > $mycount=count(my2darray); // returns 1 > > > > > > while (list($key,$value) = each ($my2darray)) { > > > echo"$key,"; > > > echo"$value[0]"; > > > echo"$value[1]"; > > > // retuns only one row with tom,798779,[EMAIL PROTECTED] > > > } > > > > > > How do I push multiple entries into a 2d array? > > > > > > I tried $my2darray[]=array(... > > > > > > Regards > > > > > > Ajdin > > > > > > -- > > > PHP General 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 General 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 General 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 General 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] Grabbing data up to \n
$data = file("myfile"); $data = array of the lines from myfile ( they still contain the newline character ) Wagner Tomy Editus Luxembourg S.A. - Original Message - From: "Jeff Lewis" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, July 27, 2001 5:14 PM Subject: [PHP] Grabbing data up to \n I am grabbing lines of a file using: $buffer = fgets($fd, 4096); How can I grab the line up to \n or does this do it? Like if the line is only a few characters, it will only grab up to \n? And if the line up to the \n is a huge message will I still be able to grab all of it with the 4096? Jeff -- PHP General 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] text imports
http://www.php.net/manual/en/function.chop.php Returns the argument string without trailing whitespace, including newlines Wagner Tomy Web Developer Editus S.A. - Original Message - From: "Karl Phillipson" <[EMAIL PROTECTED]> To: "'Alexander Wagner'" <[EMAIL PROTECTED]>; "MindHunter" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, August 07, 2001 12:53 PM Subject: [PHP] text imports > Hi, > > I have been given a (notepad generated) text file which contains a list of > countries in a format such as: > > United Kingdom, > United States, > Blah, > Blah, > Blah, > > I have imported the data into a countries table in a mySQL database using > the excellent 'mysqlfront' prog. No probs on the import itself except for > some pesky pipes that I believe to be carriage returns. > > Anyone know a way I can strip these out so I have nice clean data. > > Ta in adavance. > > Karl > > > > Saffron Hill Ventures > 67 Clerkenwell Road > London > EC1R 5BL > > Saffron Hill: 0207 693 8300 > -- PHP General 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] PHP inside code problem
try this: if (!($html_support)) { $user_message = htmlspecialchars(stripslashes($user_message)); } Wagner Tomy Web Developer Editus S.A. - Original Message - From: "Nick K." <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, August 07, 2001 12:11 PM Subject: [PHP] PHP inside code problem hi there - if ($act = "add") //Add the message... { if (!empty($user_name) && !empty($user_ip) && !empty($user_message) && !empty($user_sex)) { if (!($html_support)) { $user_message = htmlspecialchars("$user_message"); } $user_message = ereg_replace("\n","","$user_message"); $userinfo = "$user_name!¡Ó!¡Ó$user_sex!¡Ó!¡Ó$user_ip!¡Ó!¡Ó$user_message!¡Ó!¡Ó$user_date"."\n"; $fp = fopen("$filename",'a'); flock($fp,2); fwrite($fp, $userinfo); flock($fp,1); fclose($fp); header("Location: index.php"); setcookie("cuser",$user_name,time()+(3600*24*365),"/","$SERVER_NAME"); exit; } } - The code above is what I use for processing messages Everytime when I'm trying to use the function, htmlspecialchars(), it'll replace " with " . After that, I save the data and print out again, the result will add "\" after the data... ( I don't want the extra "\") There is an example. When I try to type in ^^" to be my new message, it suppose to show the same thing. However, in the saved data, it shows !¡Ó!¡Ó^^\" (!¡Ó!¡Ó is what I use to different from different filez) I don't want the extra "\" however, I tried the way in below: I use $user_message = eregi_replace("<","<","$user_message"); $user_message = eregi_replace(">",">","$user_message"); instead of the original one which is $user_message = htmlspecialchars("$user_message"); however, when I check the saved file, it still have and extra \ before the characters " . god damn it I run this code in windows98SR2, maybe it's micro$oft's problem, is it? plz help me.thx dudes nick -- PHP General 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] text imports
ah k, yes that's the way to do it in SQL ;p Tomy Wagner Web Developer Editus S.A. - Original Message - From: "Karl Phillipson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, August 07, 2001 1:08 PM Subject: RE: [PHP] text imports > Yup, thanks Wagner. > > I can do this within PHP itself using trim or chop, I was hoping for a > snippet of SQL code that would do it from the command line. > > This is what have done: > > LOAD DATA LOCAL INFILE 'C:\MYDIR\countries.txt' INTO TABLE DBNAME.COUNTRY > LINES TERMINATED BY ',' (COUNTRY_NAME) > > == > Karl Phillipson > PHP SQL Programmer > > Saffron Hill Ventures > 67 Clerkenwell Road > London > EC1R 5BL > > Saffron Hill: 0207 693 8300 > Direct Line: 0207 693 8318 > > > -Original Message- > From: Wagner Tomy [mailto:[EMAIL PROTECTED]] > Sent: 07 August 2001 12:00 > To: Karl Phillipson; 'Alexander Wagner'; MindHunter; > [EMAIL PROTECTED] > Subject: Re: [PHP] text imports > > > http://www.php.net/manual/en/function.chop.php > > Returns the argument string without trailing whitespace, including newlines > > Wagner Tomy > Web Developer > Editus S.A. > - Original Message - > From: "Karl Phillipson" <[EMAIL PROTECTED]> > To: "'Alexander Wagner'" <[EMAIL PROTECTED]>; "MindHunter" > <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Tuesday, August 07, 2001 12:53 PM > Subject: [PHP] text imports > > > > Hi, > > > > I have been given a (notepad generated) text file which contains a list of > > countries in a format such as: > > > > United Kingdom, > > United States, > > Blah, > > Blah, > > Blah, > > > > I have imported the data into a countries table in a mySQL database using > > the excellent 'mysqlfront' prog. No probs on the import itself except for > > some pesky pipes that I believe to be carriage returns. > > > > Anyone know a way I can strip these out so I have nice clean data. > > > > Ta in adavance. > > > > Karl > > > > > > > > Saffron Hill Ventures > > 67 Clerkenwell Road > > London > > EC1R 5BL > > > > Saffron Hill: 0207 693 8300 > > > > > -- > PHP General 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 General 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] text imports
RE: [PHP] text importstry this: LOAD DATA LOCAL INFILE 'C:\MYDIR\countries.txt' INTO TABLE DBNAME.COUNTRY LINES TERMINATED BY ',\n' (COUNTRY_NAME) or if it does not work, simply drop the commas and use the newline character as separator ? Tomy Wagner Web Developer Editus S.A. - Original Message - From: Karl Phillipson To: 'Wagner Tomy' ; [EMAIL PROTECTED] Sent: Tuesday, August 07, 2001 1:16 PM Subject: RE: [PHP] text imports So if this is the way to do it in SQL, is there a way to get rid of the pipe linefeeds using SQL too? If not I s'pose the solution is to run a php 'trim' script, grab the data, perform the modifications and then re-insert the data back into the table Bit long winded but if that's the only way? == Karl Phillipson PHP SQL Programmer Saffron Hill Ventures 67 Clerkenwell Road London EC1R 5BL Saffron Hill: 0207 693 8300 Direct Line: 0207 693 8318 -Original Message- From: Wagner Tomy [mailto:[EMAIL PROTECTED]] Sent: 07 August 2001 12:06 To: Karl Phillipson; [EMAIL PROTECTED] Subject: Re: [PHP] text imports ah k, yes that's the way to do it in SQL ;p Tomy Wagner Web Developer Editus S.A. - Original Message - From: "Karl Phillipson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, August 07, 2001 1:08 PM Subject: RE: [PHP] text imports > Yup, thanks Wagner. > > I can do this within PHP itself using trim or chop, I was hoping for a > snippet of SQL code that would do it from the command line. > > This is what have done: > > LOAD DATA LOCAL INFILE 'C:\MYDIR\countries.txt' INTO TABLE DBNAME.COUNTRY > LINES TERMINATED BY ',' (COUNTRY_NAME) > > == > Karl Phillipson > PHP SQL Programmer > > Saffron Hill Ventures > 67 Clerkenwell Road > London > EC1R 5BL > > Saffron Hill: 0207 693 8300 > Direct Line: 0207 693 8318 > > > -Original Message- > From: Wagner Tomy [mailto:[EMAIL PROTECTED]] > Sent: 07 August 2001 12:00 > To: Karl Phillipson; 'Alexander Wagner'; MindHunter; > [EMAIL PROTECTED] > Subject: Re: [PHP] text imports > > > http://www.php.net/manual/en/function.chop.php > > Returns the argument string without trailing whitespace, including newlines > > Wagner Tomy > Web Developer > Editus S.A. > - Original Message - > From: "Karl Phillipson" <[EMAIL PROTECTED]> > To: "'Alexander Wagner'" <[EMAIL PROTECTED]>; "MindHunter" > <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Tuesday, August 07, 2001 12:53 PM > Subject: [PHP] text imports > > > > Hi, > > > > I have been given a (notepad generated) text file which contains a list of > > countries in a format such as: > > > > United Kingdom, > > United States, > > Blah, > > Blah, > > Blah, > > > > I have imported the data into a countries table in a mySQL database using > > the excellent 'mysqlfront' prog. No probs on the import itself except for > > some pesky pipes that I believe to be carriage returns. > > > > Anyone know a way I can strip these out so I have nice clean data. > > > > Ta in adavance. > > > > Karl > > > > > > > > Saffron Hill Ventures > > 67 Clerkenwell Road > > London > > EC1R 5BL > > > > Saffron Hill: 0207 693 8300 > > > > > -- > PHP General 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 General 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] if(!$submit)
> Fair enough, so then I add if (isset(!$submit)) and I then get an error; try if(!isset($submit)) instead Tomy Wagner Web Developer Editus S.A. - Original Message - From: "Tarrant Costelloe" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, August 07, 2001 4:47 PM Subject: [PHP] if(!$submit) > When using if (!$submit) I get an error saying: > Warning: Undefined variable: submit in C:\Inetpub\webpub\default.php on line > 1 > Fair enough, so then I add if (isset(!$submit)) and I then get an error; > Parse error: parse error, expecting `T_VARIABLE' or `'$'' > Could someone please tell me the more than likely simple sollution. > > Thanks > > Taz > > -- > PHP General 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 General 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]