[PHP-DB] Select distinct field won't return distinct value
I want select distinct field and return value of that field, but I have problem which is: select distinct returns duplicate value. eg, I wan select distinct customer name and id from the customer table. one customer may have different cus_ids since cus_ids are auto increment and depend on the purchased items. so what I want is to select distinct customer name so that I can print customer name and customer id once. here is algorithm; select distinct cus_name, cus_id from customers order by cus_name asc While row is not empty do{ echoa href=\page?cus=cus_id\costomer name/abr /; }
Re: [PHP-DB] Select distinct field won't return distinct value
I thank you all. problem solved using two queries as TQ mentioned. On 6/6/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Correct me if I'm wrong, but it sounds like you have something like this: 123 Joe 124 Joe 125 Sue 126 John 127 Joe 128 Frank 129 Sue And you want to output something like: Joe 123, 124, 127 Sue 125, 129 John 126 Frank 128 But what you're getting is: Joe 123 Joe 124 ..etc You have two ways you can solve this: 1. Do two SQL queries: SELECT DISTINCT cus_name FROM customers while ($result) { // forgive the pseudo-code SELECT cus_id FROM customers WHERE cus_name = $result['cus_name'] while ($result2) { echo $output; } } Or.. 2. Collect data into an array and process 'distinctness' on output SELECT cus_name, cus_id FROM customers while ($result) { $cus_arr[$cus_name][] = $cus_id; } foreach ($cus_arr as $cus_name = $cus_idarr) { echo $cus_name as ids: . implode(, , $cusidarr) . br\n; } There may be some tricky ways in SQL to get the data the way you want it, but ultimately it's not worth the bending over backwards for (do I remember right that you can do it with crosstab queries? don't even know if MySQL will do those properly). Easier just to do it with one of the methods above. Good luck! -TG = = = Original message = = = I want select distinct field and return value of that field, but I have problem which is: select distinct returns duplicate value. eg, I wan select distinct customer name and id from the customer table. one customer may have different cus_ids since cus_ids are auto increment and depend on the purchased items. so what I want is to select distinct customer name so that I can print customer name and customer id once. here is algorithm; select distinct cus_name, cus_id from customers order by cus_name asc While row is not empty do echoa href=\page?cus=cus_id\costomer name/abr /; ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Need a Help!
I have table and insert data using song_id, that means one artist can have many song_ids. my question is how can I query distinct artist with his/her song_id while I will not get duplicate data like duplicate artist? my code is like this $content .=form id=\form1\ method=\post\ action=\\ select name=\Quick\ onchange=\MM_jumpMenu('parent',this,0)\ option value=\#\Select Artist/option; $result= $db-sql_query(SELECT distinct(artist), id FROM .$prefix._lyrics order by artist asc); if ($db-sql_numrows($result)) { while($row = $db-sql_fetchrow($result)) { extract($row); $content .=option value='modules.php ?name=$module_nameamp;file=artistamp;c_id=$id'$artist/option; } } $content .=/select /form; that code is fine except it gives me duplicate artist, so I want get rid off that duplicate. any help
Re: [PHP-DB] problem of retrieving urls from mysql
I am getting link from visitor using form, that means I don't have control what they would type. e.g they may type http://www.suggestedlink.com/myfav.wav, www.suggestedlink.com/myfav.ram and http://suggestedlink.com/myfav.mp3 or so I am looking general version which can handle all. and on top of that I wanted to play music file in to the default player, but it did not work. I used something like this. select music_file from music where id=\$id\ $temp = $result src=\$temp\ so everything is working fine except I got file not found, and the file path is something like this http://www.mydomain.com/www.suggestedlink/myfav.mp3 so what should I do. On 12/7/05, Edward Gray [EMAIL PROTECTED] wrote: actually, you may want to check the source of the page. if the url does not start with http://; (or https, or ftp, etc.), browsers will assume the link is on the current server. how are you storing the urls? as full urls, as domain/path/file.htm, ? if all of your urls should start with http://;, you could either store them in the database that way or echo 'http://' . $temp; hope this helps. Edward Gray Web Development Team University of Mary Washington 540-654-1564 Bastien Koert [EMAIL PROTECTED] 12/06/05 1:44 PM $url = str_replace(www.mydomain.com,,$url) bastien From: Mohamed Yusuf [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] problem of retrieving urls from mysql Date: Tue, 6 Dec 2005 09:51:18 -0800 I would like to store and retrieve urls, but I have problem which is I get my url + the other url, Instead I should get another url only $temp = linkurl; echo $temp; the echo prints something like this http://www.mydomain.com/www.otherlink.com so I wan get rid off my url and get only other link, so how can I do that? thanks in advance -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] problem of retrieving urls from mysql
I would like to store and retrieve urls, but I have problem which is I get my url + the other url, Instead I should get another url only $temp = linkurl; echo $temp; the echo prints something like this http://www.mydomain.com/www.otherlink.com so I wan get rid off my url and get only other link, so how can I do that? thanks in advance
[PHP-DB] problem of transmitting variable from page to another page.
I am transmitting variable from one of my pages and I would like to match that variable into mysql data. it won't return data. my code is this. ?php for ($j=A; $j = Z; $j++) { echo | ba href='alpha.php?artist=$j'$j/a/b |; if ($j == Z) { break; } } ? this code in my index page prints alphabetical letters from A-Z. and I woul like to transmit that variable into my alpha.php page and select mysql database what ever the value of $j is, but i have problem I can't figured out what is wrong. can somebody help me.
[PHP-DB] php upload
I heard that the maximum file size which php can upload is setted to 2MB, so is it a possible to reset the maximum_file_size to a larger bytes and if it is possible how can I achieve that?
[PHP-DB] Can't Upload ram file
the script I am using can upload images like, jpg, gif or png to the server, but it can't upload music file to the server like ram and rm. any help?
Re: [PHP-DB] Can't Upload ram file
? $uploadDir = 'media/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; // the files will be saved in filePath $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo Error uploading file; exit; } if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $username=; $password=; $database=; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query = INSERT INTO upload2 (name, size, type, path ) . VALUES ('$fileName', '$fileSize', '$fileType', '$filePath'); mysql_query($query) or die('Error, query failed : ' . mysql_error()); include 'library/closedb.php'; echo brFile uploadedbr; } ? On 11/18/05, Bastien Koert [EMAIL PROTECTED] wrote: show code, maybe checks are being done to only allow images or certain extensions... Bastien From: Mohamed Yusuf [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] Can't Upload ram file Date: Fri, 18 Nov 2005 06:19:24 -0800 the script I am using can upload images like, jpg, gif or png to the server, but it can't upload music file to the server like ram and rm. any help?
Re: [PHP-DB] Can't Upload ram file
here is the code ? $uploadDir = 'media/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; // the files will be saved in filePath $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo Error uploading file; exit; } if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $username=; $password=; $database=; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query = INSERT INTO upload2 (name, size, type, path ) . VALUES ('$fileName', '$fileSize', '$fileType', '$filePath'); mysql_query($query) or die('Error, query failed : ' . mysql_error()); include 'library/closedb.php'; echo brFile uploadedbr; } ? On 11/18/05, Bastien Koert [EMAIL PROTECTED] wrote: show code, maybe checks are being done to only allow images or certain extensions... Bastien From: Mohamed Yusuf [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] Can't Upload ram file Date: Fri, 18 Nov 2005 06:19:24 -0800 the script I am using can upload images like, jpg, gif or png to the server, but it can't upload music file to the server like ram and rm. any help?
[PHP-DB] Problem of Upload media file
I am trying to upload music file to server using php and saving file path to the MySql, But I am getting this error message *Warning*: move_uploaded_file(music/media/): failed to open stream: No such file or directory in */home/somally/public_html/music/upload2.php* on line *36*. line 36 is reference of this code *$uploadDir = 'www/music/media/';* so what am I missing?, any help?
Re: [PHP-DB] Problem of Upload media file
the permissions are right, I mean they are all setted to 777. On 11/17/05, Bastien Koert [EMAIL PROTECTED] wrote: Check your permissions on the folder...you may need to make them 777 to allow read/write by all for the upload Bastien From: Mohamed Yusuf [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] Problem of Upload media file Date: Thu, 17 Nov 2005 08:58:15 -0800 I am trying to upload music file to server using php and saving file path to the MySql, But I am getting this error message *Warning*: move_uploaded_file(music/media/): failed to open stream: No such file or directory in */home/somally/public_html/music/upload2.php* on line *36*. line 36 is reference of this code *$uploadDir = 'www/music/media/';* so what am I missing?, any help?
Re: [PHP-DB] Problem of Upload media file
here is the complete code, so you can check it ? $uploadDir = 'www/media/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; // the files will be saved in filePath $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo Error uploading file; exit; } include 'library/config.php'; include 'library/opendb.php'; if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $query = INSERT INTO upload2 (name, size, type, path ) . VALUES ('$fileName', '$fileSize', '$fileType', '$filePath'); mysql_query($query) or die('Error, query failed : ' . mysql_error()); include 'library/closedb.php'; echo brFile uploadedbr; } ? end On 11/17/05, Micah Stevens [EMAIL PROTECTED] wrote: Keep in mind you're referring to a filesystem path, and a relative one to boot, so what you're telling php is, that your upload directory is: /home/somally/public_html/music/music/media/ Which doesn't sound like what you intend. Also don't trust the php line numbers if you have significant whitespace in your code, sometimes it can get screwey. Look for your move_uploaded_file statement. -Micah On Thursday 17 November 2005 8:58 am, Mohamed Yusuf wrote: I am trying to upload music file to server using php and saving file path to the MySql, But I am getting this error message *Warning*: move_uploaded_file(music/media/): failed to open stream: No such file or directory in */home/somally/public_html/music/upload2.php* on line *36*. line 36 is reference of this code *$uploadDir = 'www/music/media/';* so what am I missing?, any help? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem of Upload media file
so should I change the directory? where I want to upload file is www.somalilyrics.com/music/media/http://www.somalilyrics.com/music/media/, therefore what about if I say *$uploadDir = 'music/media/'; *is that fine? if it is not fine would you please show me how I have to do it? On 11/17/05, Micah Stevens [EMAIL PROTECTED] wrote: Well, the error doesn't match the code, but the code says to upload the file to: /home/somally/public_html/music/www/media/ Is that correct? On Thursday 17 November 2005 9:41 am, Mohamed Yusuf wrote: here is the complete code, so you can check it ? $uploadDir = 'www/media/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; // the files will be saved in filePath $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo Error uploading file; exit; } include 'library/config.php'; include 'library/opendb.php'; if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $query = INSERT INTO upload2 (name, size, type, path ) . VALUES ('$fileName', '$fileSize', '$fileType', '$filePath'); mysql_query($query) or die('Error, query failed : ' . mysql_error()); include 'library/closedb.php'; echo brFile uploadedbr; } ? end On 11/17/05, Micah Stevens [EMAIL PROTECTED] wrote: Keep in mind you're referring to a filesystem path, and a relative one to boot, so what you're telling php is, that your upload directory is: /home/somally/public_html/music/music/media/ Which doesn't sound like what you intend. Also don't trust the php line numbers if you have significant whitespace in your code, sometimes it can get screwey. Look for your move_uploaded_file statement. -Micah On Thursday 17 November 2005 8:58 am, Mohamed Yusuf wrote: I am trying to upload music file to server using php and saving file path to the MySql, But I am getting this error message *Warning*: move_uploaded_file(music/media/): failed to open stream: No such file or directory in */home/somally/public_html/music/upload2.php* on line *36*. line 36 is reference of this code *$uploadDir = 'www/music/media/';* so what am I missing?, any help? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem of Upload media file
Many thanks for your help. it works. On 11/17/05, Micah Stevens [EMAIL PROTECTED] wrote: No. It's not okay.. you're already in the music directory.. if you want it in the media subdir, just put 'media/' On Thursday 17 November 2005 10:40 am, Mohamed Yusuf wrote: so should I change the directory? where I want to upload file is www.somalilyrics.com/music/media/http://www.somalilyrics.com/music/media/ http://www.somalilyrics.com/music/media/ , therefore what about if I say *$uploadDir = 'music/media/'; *is that fine? if it is not fine would you please show me how I have to do it? On 11/17/05, Micah Stevens [EMAIL PROTECTED] wrote: Well, the error doesn't match the code, but the code says to upload the file to: /home/somally/public_html/music/www/media/ Is that correct? On Thursday 17 November 2005 9:41 am, Mohamed Yusuf wrote: here is the complete code, so you can check it ? $uploadDir = 'www/media/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; // the files will be saved in filePath $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo Error uploading file; exit; } include 'library/config.php'; include 'library/opendb.php'; if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $query = INSERT INTO upload2 (name, size, type, path ) . VALUES ('$fileName', '$fileSize', '$fileType', '$filePath'); mysql_query($query) or die('Error, query failed : ' . mysql_error()); include 'library/closedb.php'; echo brFile uploadedbr; } ? end On 11/17/05, Micah Stevens [EMAIL PROTECTED] wrote: Keep in mind you're referring to a filesystem path, and a relative one to boot, so what you're telling php is, that your upload directory is: /home/somally/public_html/music/music/media/ Which doesn't sound like what you intend. Also don't trust the php line numbers if you have significant whitespace in your code, sometimes it can get screwey. Look for your move_uploaded_file statement. -Micah On Thursday 17 November 2005 8:58 am, Mohamed Yusuf wrote: I am trying to upload music file to server using php and saving file path to the MySql, But I am getting this error message *Warning*: move_uploaded_file(music/media/): failed to open stream: No such file or directory in */home/somally/public_html/music/upload2.php* on line *36*. line 36 is reference of this code *$uploadDir = 'www/music/media/';* so what am I missing?, any 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
[PHP-DB] text with html tags apeared in text area.
hi I have php form. one of my textarea gets data with html tags from database, so I would like to remove those html tags like br /, therefore is there anyway that i can remove those tags in the data and then the data can appear as text in the textarea.