Jump to content

Sharkadder

Members
  • Posts

    119
  • Joined

  • Last visited

Everything posted by Sharkadder

  1. Hi there, It is ok i sorted this now, happens that i had a parent outcome id field in my table and so each sub-outcome had a parent id which was linked to the main outcome ID. All i did was get the main outcome ID's from the database in ascending order, and then search for each sub-criteria who had that main outcome ID as their parent...then i was able to capture the information in the order i needed. Many thanks, Mark
  2. Hi there, I have an SQL table which has a field within it that holds data within a row. The field holds data for outcomes which can be listed as follows: Outcome 1 1.1 1.2 Outcome 2 2.1 2.2 1.3 Outcome 4 4.1 4.2 Outcome 3 3.1 1.4 etc. Basically, they are not in order as people have been typing them into the database table in a random order. Is there a way i can get it so that it shows everything to do with outcome 1 under outcome 1 etc. once i pull the rows from the database? e.g. Outcome 1 1.1 1.2 1.3 1.4 Outcome 2 2.1 2.2 etc. I have tried assending and decsending orders but they obviously show the numeric data first. Currently i am having to use several foreach loops in PHP to sort out the ordering and would like a more efficient way of doing this. Was not sure if i could do a command in MySQL direct. I am using MySQL 5.0 Many thanks
  3. Thanks dude i have added that code in now. I have got it all working and even the .value is now working which is really good since i modified the code to what you said. If i stumble across any other problems i shall post on here but i think it is sorted now, going to do some testing tomorrow on my script :-). Mark
  4. Hi dude, Thank you once again for the reply. Basically i have a loop which loops through all of the table rows from within a table, each iteration of the loop uses the number i which increments each time the loop goes around. This is why i have code such as: document.getElementsByTagName("tr") <---the i here is the TR element number for whichever iteration the loop is on. So if we look at what i am trying to achieve, I am trying to change the id and name of a select element and three input elements within TD tags using Javascript, alternatively i could use jQuery. I cannot use any server side languages as i allow people to add in a new row to the table by clicking on a button and so Javascript or Jquery is needed to re-number all of the ID's. e.g. i have a row which contains 4 cells, 1 is a select drop down box and the other three all contain an input box. Do you think that you could give me an example of how this could be achieved, and code which will work when using internet explorer? All i need to do is get the element from inside the TD tag and replace the ID and Name value from within it. Is there any way i can make use of GetElementbyID or GetelEmentByName and change the ID or name that way without innerHTML? Many thanks and hope you can help me with this problem..i try to stay away from Javascript and i mostly program in PHP but this has to be client side without needing to refresh the page, Mark
  5. Hi there and thank you for the reply. I have tried just about everything and silly internet explorer keeps kicking back error messages! Beginning to get frustrating now. Do you know of any function where i can pass it the tag name i am wanting to send HTML to e.g."document.getElementsByTagName("tr")" and to then replace the HTML to update the table row without innerHTML I have tried the following and it just does not work! //inside the head of the document function replaceHtml(el, html) { var oldEl = typeof el === "string" ? document.getElementById(el) : el; /*@cc_on // Pure innerHTML is slightly faster in IE oldEl.innerHTML = html; return oldEl; @*/ var newEl = oldEl.cloneNode(false); newEl.innerHTML = html; oldEl.parentNode.replaceChild(newEl, oldEl); /* Since we just removed the old element from the DOM, return a reference to the new element, which can be used to restore variable references. */ return newEl;}; //inside the body newHTML = document.getElementsByTagName("tr")[i].innerHTML.replace(document.getElementsByTagName("tr")[i].cells[j].childNodes[0].id,nameandid).replace(document.getElementsByTagName("tr")[i].cells[j].childNodes[0].name,nameandid).replace(document.getElementsByTagName("tr")[i].cells[j].childNodes[2].id,calendarid).replace(document.getElementsByTagName("tr")[i].cells[selecttdid].childNodes[0].name,selectname); //work around for innerHTMLdocument.getElementsByTagName("tr") = replaceHtml(document.getElementsByTagName("tr"),newHTML); IE just states an invalid procedure call on the line: var oldEl = typeof el === "string" ? document.getElementById(el) : el; Think you could amend my code to maybe work or perhaps tell me an alternative function. Many thanks, Mark
  6. Hi there, I have recently been trying some code out to replace the innerHTML contents from within a table row, i am now to discover that Internet Explorer which a lot of people still use insists of making innerHTML properties read only, although the code works flawlessly in Firefox and Google Chrome. The code i have currently got is shown below: document.getElementsByTagName("tr").innerHTML = document.getElementsByTagName("tr").innerHTML.replace(document.getElementsByTagName("tr").cells[j].childNodes[0].id,nameandid).replace(document.getElementsByTagName("tr").cells[j].childNodes[0].name,nameandid).replace(document.getElementsByTagName("tr").cells[j].childNodes[2].id,calendarid).replace(document.getElementsByTagName("tr").cells[selecttdid].childNodes[0].name,selectname); As you can see from the above code i am trying to tell a tag name TR which has an index of i innerHTML to change to itself but with some things replaced. You don't need to know what i am replacing inside the code as that code is all fine. What i would like to know is, what work around do i have to change the innerHTML using Javascript or JQuery? Some people have said to stick it into a Div tag but the problem is that the table is inside of a form and i am sending the elements from a form to a different page and so i would rather keep it inside the table row. I have also read that innerHTML can be used to modify specific cells from within a table i.e. contents inside a TD tag. Does anybody know how i can modify my code accordingly so that the debugger stops spitting out the "operation" error messages when i put debugging on due to trying to write to innerHTML? I have also tried using outerHTML and didn't seem to work either: document.getElementsByTagName("tr").outerHTML.replace(document.getElementsByTagName("tr").innerHTML,document.getElementsByTagName("tr").innerHTML.replace(document.getElementsByTagName("tr").cells[j].childNodes[0].id,nameandid).replace(document.getElementsByTagName("tr").cells[j].childNodes[0].name,nameandid).replace(document.getElementsByTagName("tr").cells[j].childNodes[2].id,calendarid).replace(document.getElementsByTagName("tr").cells[selecttdid].childNodes[0].name,selectname)); You will notice in the above i am trying to replace the innerHTML of an element(a TR tag at number i) with some things removed and again, because i am trying to modify the innerHTML...it was a no go again. Finally i have tried to modify a value property in internet explorer and this time it spits out a 5007 error saying that it is unable to set the value of the property, anybody know how i can get around this? My code again for this is below to what i currently tried: document.getElementById("unitstartdate"+totaltablerows).value = startdate; The ID's do exist and again this code worked fine in firefox and chrome, just not IE. I think i am more after a work around for both situations rather than you understanding what i am actually trying to replace etc. as the replace part of the code is fine, just will not write to HTML in Internet explorer using innerHTML, outerHTML or change a value of an element as mentioned. Any ideas are great. Mark
  7. Hi, I solved the problem with the following function, although it does require a loop. Not sure if there is a more efficent way but my page seems to load fine with it: //dropdown is the dropdown you selected and theForm is the formfunction checkselected(theForm, dropdown){for (i=0; i<theForm.length; i++) { //myval.options[myval.selectedIndex].innerHTML if (theForm.elements[i].type == "select-one") { if (dropdown.options[dropdown.selectedIndex].innerHTML == theForm.elements[i].options[theForm.elements[i].selectedIndex].innerHTML && theForm.elements[i].name != dropdown.name) { alert("You have already selected this unit. Please choose a different one."); //change index on selected dropdown back to zero dropdown.selectedIndex = 0; } }}}
  8. Hi there, I have 10 drop down boxes on a page where people can select some units they wish to study. Obviously people can pick more than one unit and so i want to avoid them from picking the same unit twice in each of the drop down boxes. I have looked into the disable function on drop down boxes but cannot figure out how i would go about disabling a drop down selection entry using Javascript. So far i have looked at the following jquery function below but it will not work on my php page as i do not have access to the head of the document on the platform i am on and just the body: $('select').change(function() { var ary = new Array(); $('select option:selected').each(function() { if ($(this).val().length > 0) { ary.push($(this).val()); } }); $('select option').each(function() { if ($.inArray($(this).val(), ary) > -1) { $(this).attr('disabled', 'disabled'); } else { $(this).removeAttr('disabled'); } });}); The example above is the sort of thing i am after but having studied the code, without it being in the head of the document it will not work and so it does not work when i change entry in the dropdown list. Does anybody have any modifications to the code or examples i can use to find out the values of all other dropdown's on a form and to then disable an index in the others where one is already selected on that index? Obviously i would need something to enable selections again. Even an alert box stating that the unit has already been picked and resetting back to original value would do. Many thanks, Mark
  9. Hi there, I have been looking up on how to use SOAP in relation to php and have managed to hit a bit of a snag with it. Basically on my server i get some information which is presented in xml format from sharepoint. I then wish to access this data from a php file on another server and print it out onto the screen. I have heard using a soap call is the best method for this. The problems i am having are as follows: Gaining authorisation to the xml file i which contains the soap contents i.e. how to log in with username and password Reading the soap content in php to capture some data and print it out Shown below is a copy of my data which is in an xml format: <xml><s:Schema id="RowsetSchema"><s:ElementType name="row" content="eltOnly" rs:CommandTimeout="30"><s:AttributeType name="ows_DocIcon" rs:name="Type" rs:number="1"><s:datatype dt:type="string" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows_LinkFilename" rs:name="Name" rs:number="2"><s:datatype dt:type="string" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows_Created" rs:name="Created" rs:number="3"><s:datatype dt:type="datetime" dt:maxLength="8"/></s:AttributeType><s:AttributeType name="ows_Author" rs:name="Created By" rs:number="4"><s:datatype dt:type="string" dt:lookup="true" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows_CheckoutUser" rs:name="Checked Out To" rs:number="5"><s:datatype dt:type="string" dt:lookup="true" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows__x007b_064b332a_x002d_4d9e_x002d_4e7e_x002d_8cf9_x002d_227b6c7972db_x007d_" rs:name="Learner Name" rs:number="6"><s:datatype dt:type="string" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows_StartDate" rs:name="Start Date" rs:number="7"><s:datatype dt:type="datetime" dt:maxLength="8"/></s:AttributeType><s:AttributeType name="ows_JobTitle" rs:name="Job Title" rs:number="8"><s:datatype dt:type="string" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows_Region" rs:name="Region" rs:number="9"><s:datatype dt:type="string" dt:maxLength="512"/></s:AttributeType><s:AttributeType name="ows_Learner_x0020_Email" rs:name="Learner Email" rs:number="10"><s:datatype dt:type="string" dt:maxLength="512"/></s:AttributeType></s:ElementType></s:Schema><z:row ows_DocIcon="xml" ows_LinkFilename="learner_name.xml" ows_Created="2012-03-20 16:26:24" ows_Author="17;#**** *****" ows__x007b_064b332a_x002d_4d9e_x002d_4e7e_x002d_8cf9_x002d_227b6c7972db_x007d_="****** ******" ows_StartDate="2012-03-20 00:00:00" ows_JobTitle="Director" ows_Region="Durham" ows_Learner_x0020_Email="******@hotmail.co.uk"/></rs:data></xml> Ok so that is the code for one learner record which i am wanting to parse in php...all i want to know is, what do i do to get the learner e-mail address? (the one with the value xxxxx@hotmail.com from the page which requires authorisation to view it. So far i have tried the following with no luck (hashed out the main part of url as contains confidential material): <?php$xml = simplexml_load_file("http://*********.co.uk:8088/OPS/_vti_bin/owssvr.dll?Cmd=Display&List={6A2E72AB-8F77-4B94-A7FA-DB00527CEFB4}&XMLDATA=TRUE");echo $xml->AttributeType() . "<br />";foreach($xml->children() as $child){echo $child->AttributeType() . ": " . $child . "<br />";}?> I have also tried the following php code to display the learner name field (that is the name starting with ows__ with letters, underscores and numbers as shown below). it just says failed to load external entity which i am unsure about: <?php$client = new SoapClient("http://*********.co.uk:8088/OPS/_vti_bin/owssvr.dll?Cmd=Display&List={6A2E72AB-8F77-4B94-A7FA-DB00527CEFB4}&XMLDATA=TRUE", array(trace=>true, 'login'=>"*******", 'password'=>"*****"));$res = $client->row(array('ows__x007b_064b332a_x002d_4d9e_x002d_4e7e_x002d_8cf9_x002d_227b6c7972db_x007d_'=>5));print $res;?> As you can see i have hashed all of the confidential details out but if somebody could maybe correct my php code so that i can gain access to the file, parse an element from the xml and then display it on the screen then that would be great. Obviously i do have more records but only displayed the first one for demonstration purposes. I also have access to the request and response generated by the server if you wish to see them or maybe point me in the direction on how i can use them instead to print out the values in php. Many thanks, Mark
  10. yeah i knew that much but just wodnered if it was good practise.anyways, cheers dude.
  11. ok i decided to try on a different person in case of data input error but the same thing occured. The name John O'Shea was tried and it worked well and it now works for both names.I looked at your code and the apostrophe was the same character, i then looked at what you said and the result now shows. Some of the suggested code must have been wrong as an error on my part but it now works well. Do you recommend using a slash before the apostrophe in the raw database or leave it without one?Thanks for all of the help and suggestions...i am not sure if i need the code which was first suggested for my post variables and if i can cut down the code then let me know but the problem is now solved.The name now shows
  12. Ok it still says no records found. The name is definately in the database and so i'm thinking the apostrophe isn't matching the one from the raw database. I have done as justsomeguy says and taken off the condition to search a category but it just says no results. If i change the name for one without an apostrophe in then it finds the name and so it's got to be to do with removing the apostrophe.Here is the current code: if (get_magic_quotes_gpc()) { $_GET = fixMagicQuotes($_GET); $_POST = fixMagicQuotes($_POST); $_REQUEST = fixMagicQuotes($_REQUEST); $_COOKIE = fixMagicQuotes($_COOKIE);}if (isset($_POST['search'])){ $searchterm = $_POST['SearchTerm']; $searchterm = trim(rawurldecode($searchterm)); #$searchterm = str_replace("\\","",$searchterm); print $searchterm; #$searchterm = trim(utf8_encode($searchterm)); $searchcategory = $_POST['Category']; $characterremove = array("/"," "); $searchcategory = str_replace($characterremove,"",$searchcategory); $con = mysql_connect('h50mysql107.secureserver.net','sensiswos','Sens1sw0s'); @mysql_select_db("sensiswos",$con) or die(mysql_error()); $searchcategory = mysql_real_escape_string($searchcategory, $con); $searchterm = mysql_real_escape_string($searchterm, $con); $playermanagersearch = mysql_real_escape_string($playermanagersearch, $con); mysql_query("SET NAMES utf8"); #$query="SELECT * FROM FootballPlayers WHERE lower($searchcategory) LIKE lower('%$searchterm%') AND lower(PlayerManager) LIKE lower('$playermanagersearch') COLLATE utf8_bin ORDER BY Name asc"; $query = "SELECT * FROM FootballPlayers WHERE lower(Name) LIKE '%Adam O\'Donnell%' AND lower(PlayerManager) LIKE '%' COLLATE utf8_bin ORDER BY Name asc"; $searchterm = str_replace(array('%', '_'), array('\\%', '\\_'), $searchterm); $playermanagersearch = str_replace(array('%', '_'), array('\\%', '\\_'), $playermanagersearch); print $query; $result=mysql_query($query) or exit(mysql_error()); print $result; $num=mysql_numrows($result); print $num; mysql_close(); updated printed query, result and number of rows count is: SELECT * FROM FootballPlayers WHERE lower(Name) LIKE '%Adam O\'Donnell%' AND lower(PlayerManager) LIKE '%' COLLATE utf8_bin ORDER BY Name ascResource id #30
  13. ok i added in the slight error check modification and still nothing. I get no errors from the search, just it doesn't appear to find anything.the record definately exists and is definately in the database without a \ before the apostrophe. What else do you think i could try?
  14. ok i tried that and it never worked, the query now shows this: Adam O'DonnellSELECT * FROM FootballPlayers WHERE lower(Name) LIKE lower('%Adam O\'Donnell%') AND lower(PlayerManager) LIKE lower('%') COLLATE utf8_bin ORDER BY Name asc
  15. Your code didn't work, still says no results found although i am no longer getting the numrows error. In fact your code doesn't work for any person in my database with or without apostrophe, so it must be going wrong somewhere. Below is a copy of my updated code and query, i moved the $searchterm and $playermanager = str_replace codes down a bit as no results were showing for anything when they were in the position you said: if (get_magic_quotes_gpc()) { @array_walk_recursive($_GET, 'stripslashes'); @array_walk_recursive($_POST, 'stripslashes'); @array_walk_recursive($_REQUEST, 'stripslashes'); @array_walk_recursive($_COOKIE, 'stripslashes');}if (isset($_POST['search'])){ $searchterm = $_POST['SearchTerm']; $searchterm = trim(rawurldecode($searchterm)); #$searchterm = str_replace("\\","",$searchterm); print $searchterm; #$searchterm = trim(utf8_encode($searchterm)); $searchcategory = $_POST['Category']; $characterremove = array("/"," "); $searchcategory = str_replace($characterremove,"",$searchcategory); $con = mysql_connect('h50mysql107.secureserver.net','sensiswos','Sens1sw0s'); @mysql_select_db("sensiswos",$con) or die(mysql_error()); $searchcategory = mysql_real_escape_string($searchcategory, $con); $searchterm = mysql_real_escape_string($searchterm, $con); $playermanagersearch = mysql_real_escape_string($playermanagersearch, $con); mysql_query("SET NAMES utf8"); $query="SELECT * FROM FootballPlayers WHERE lower($searchcategory) LIKE lower('%$searchterm%') AND lower(PlayerManager) LIKE lower('$playermanagersearch') COLLATE utf8_bin ORDER BY Name asc"; $searchterm = str_replace(array('%', '_'), array('\\%', '\\_'), $searchterm); $playermanagersearch = str_replace(array('%', '_'), array('\\%', '\\_'), $playermanagersearch); print $query; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close();} So i again type in Adam O'Donnell and it just says that no results are found. If i put the "$searchterm = str_replace(array..." and "$playermanagersearch = str_replace(array..." code before the query then it doesn't find anything, not even people who have no apostrophe in their name. Where it is in the code above i am back to the problem i had before, fidns names but not people with apostrophe in their name.the printed search term and query with the way the code is above now looks like this: Adam O\'DonnellSELECT * FROM FootballPlayers WHERE lower(Name) LIKE lower('%Adam O\\\'Donnell%') AND lower(PlayerManager) LIKE lower('%') COLLATE utf8_bin ORDER BY Name asc Any further help would be apprechiated on locating players with apostrophes in their names.
  16. Hi there,I have a mysql database which holds records about people. My aim was to search the database and display records found onto the screen, this was all working fine but i found that players who had apostrophe's in their name such as the name Adam O'Donnell brought up a mysql_numrows error on return.The name is typed into an input box and once you click the search button it will reload the page, send the name to php through a $_post command and then search the database. Here is the code i have tried so far: #the search term from the html form once submit was pressed $searchterm = $_POST['SearchTerm']; $searchterm = trim(rawurldecode($searchterm)); #replace any black slash's $searchterm = str_replace("\\","",$searchterm); print $searchterm; #get the search category from the html form $searchcategory = $_POST['Category']; $characterremove = array("/"," "); #remove any forward slashes from search category $searchcategory = str_replace($characterremove,"",$searchcategory); $con = mysql_connect('h50mysql107.secureserver.net','sensiswos','Sens1sw0s'); @mysql_select_db("sensiswos",$con) or die(mysql_error()); mysql_query("SET NAMES utf8"); $query="SELECT * FROM FootballPlayers WHERE lower($searchcategory) LIKE lower('%$searchterm%') AND lower(PlayerManager) LIKE lower('$playermanagersearch') COLLATE utf8_bin ORDER BY Name asc"; print $query; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); Ok so that is my code, when i run the query with a name without an apostrophe it works fine and returns a result, if i use a name with an apostrophe in i then get the following error generated once i print the query out: Adam O'DonnellSELECT * FROM FootballPlayers WHERE lower(Name) LIKE lower('%Adam O'Donnell%') AND lower(PlayerManager) LIKE lower('%') COLLATE utf8_bin ORDER BY Name ascWarning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/content/S/h/a/Sharkadder/html/worldfootballleagues/sql_testing/search.php on line 195 Ok so that is my code, i have tried using mysql_escape_string() when searching the database and that doesn't work and i have also tried doing a search without my removing the \\ as shown in the code above and that doesn't work.just to mention one final thing, the name is saved into the database without a \ before the apostrophe, so it is in the database as Adam O'Donnell and not Adam O\'Donnell. The other thing to mention is that i replace the \ after the page has reloaded because once i type the name in and submit it, on refresh the search term produces a \ before the apostrophe and so i replace it with blank.If you can help where i am going wrong then that would be great.Many thanks,Mark
  17. w3fools sounds American to me...not to stereotype, most American's are decent people but it's normally a bored idiot from there who create websites slating other people. Do people have bothing better to do? If there is a problem on w3schools then why not just e-mail them/post on here and just say say "this, that and t'other is wrong, can you please fix it?" Why bother being so bored you want to create a new website just bsically causing chaos...somebody obviously has a lot of time on their hands.Besides, w3fools website doesn't even look good, looks like it was created in front page by some teenager who has clearly not grown up fully yet. How much vertical scrolling do they need? The only type of websites that can get away with that are forums, online stores, and social networking websites.I just don't see why they needed to create another website linking to other places when they could have just been helpful and posted on here any problems instead of slating a website millions of people use in order to learn the basics of website design/development. They're obviously just trying to trive traffic away or some rubbish, i think they should spend their time more wisely and create a website to do something useful.
  18. ok i think i sorted it...when i printed the rows out it was saying 0 entries found for the last 3 clubs, i then trimmed the line and they must have been a space before the name which is why it found nothing. The space obviously came after looping through the array. Anyways it has worked now so thanks for that. I spent a whole 3 hours stareing wondering where i went wrong too...never to mind.Thanks for the help dude, the problem is now solved.
  19. Hi there,I have a foreach loop which loops through items in an array in PHP. Each value in the array is then checked and a column in a database table is checked. If the item is in the database i wish to print out the results onto the screen.The problem i have is that it seems to check the first item from the array and then it doesn't check the rest. I have looked on the internet about searching items in a foreach loop and doing a mysql query for each item and it seems to be a common problem.My code is as follows: $clubs = array(Liverpool[eng](1996-2004), Real Madrid(2004-2005), Newcastle United(2005-2009), Manchester United(2009-Present)); #loop through items in array $clubs foreach ($clubs as $club) { #split the club up by "(" to just leave the team name i.e. removing the years $clubname = explode("(", $club); #search through database where the teamname is equal to $clubname $query1 = "SELECT * FROM ClubID WHERE teamname = '$clubname[0]'"; $result1=mysql_query($query1) or exit(mysql_error()); $num1=mysql_numrows($result1); $i=0; while ($i < $num1) { #since the teamname might have been found more than once we do while loop here #print out the result and then increment inner loop print mysql_result($result1,$i,"teamname"); $i++; } } ok so that is my code, it prints out the first team name ok, i.e. Liverpool[eng] prints out fine but the rest do not, any ideas why it will not keep looping through the rest of the clubs inside the array $clubs? All of the teams do exist in the database and the spellings are all correct.Many thanks,Mark
  20. thanks dude it worked a charm...always helpful and full of the answers.I did contemplate a lookup table but this way works ok :-).
  21. Hi there,I currently have a mysql database which i would like to use to get values from a database. One of the columns in the database holds a value and if more than one value exists for an entry, the values are split up by commas for that row under the ClubID column. Here is a copy of my current query: $query="SELECT * FROM FootballPlayers WHERE ClubID LIKE '%$squad' COLLATE utf8_bin ORDER BY CASE WHEN Positions LIKE 'GK%' THEN 1 WHEN Positions LIKE 'RB%' THEN 2 WHEN Positions LIKE 'LB%' THEN 3 WHEN Positions LIKE 'SW%' THEN 4 WHEN Positions LIKE 'CD%' THEN 5 WHEN Positions = 'D' THEN 6 WHEN Positions LIKE 'RW%' THEN 7 WHEN Positions LIKE 'LW%' THEN 8 WHEN Positions LIKE 'DM%' THEN 9 WHEN Positions LIKE 'CM%' THEN 10 WHEN Positions LIKE 'AM%' THEN 11 WHEN Positions = 'M' THEN 12 WHEN Positions LIKE 'FW%' THEN 13 WHEN Positions LIKE 'ST%' THEN 14 WHEN Positions = 'A' THEN 15 ELSE 16 END"; Ok i would like the query above to search the database and to show items where ClubID is like $squad. $squad is always a number or more than one number split up by commas, e.g. 100 or 1,2,3,4 etc.The rest of the query is fine where it displays the rows depending on what playing position they equal. The problem is that if $squad is equal to a range of numbers split up by commas they it will not find anything and just show blank. e.g. if $squad = "2" and i am looking at ClubID column for a ClubID which contains "2" then nothing seems to get displayed as ClubID might say "1,2" or "2,8" etc. My question is, how can i search the database so that after the WHERE clause i can see if part of the string $squad is in the column ClubID for the current row.I have tried using LOCATE and FIND_IN_SET but i cannot appear to get them to work, maybe the right syntax is all i need :-). I am using mysql version 5.0 and the variable i search the database with is created using PHP. Any help is apprechiated.Thanks,Mark
  22. ok i've done that and phpmyadmin finds no results, here is the results from the query: MySQL returned an empty result set (i.e. zero rows). (Query took 0.0048 sec)SQL query:SELECT *FROM FootballPlayersWHERE TeamName LIKE 'Gençlerbirliği'ORDER BY CASE WHEN Positions LIKE 'GK%'THEN 1WHEN Positions LIKE 'RB%'THEN 2WHEN Positions LIKE 'LB%'THEN 3WHEN Positions LIKE 'SW%'THEN 4WHEN Positions LIKE 'CD%'THEN 5WHEN Positions = 'D'THEN 6WHEN Positions LIKE 'RW%'THEN 7WHEN Positions LIKE 'LW%'THEN 8WHEN Positions LIKE 'DM%'THEN 9WHEN Positions LIKE 'CM%'THEN 10WHEN Positions LIKE 'AM%'THEN 11WHEN Positions = 'M'THEN 12WHEN Positions LIKE 'FW%'THEN 13WHEN Positions LIKE 'ST%'THEN 14WHEN Positions = 'A'THEN 15ELSE 16ENDLIMIT 0 , 30 As i say, the query works if i do names without accents. The name in the query above is about the worst accented example i have. I check phpmyadmin again and some accented names are saving as follows within the database:GençlerbirliğiWith me converting them in php i don't know if it converts them right. If i search for the name with the character number instead of the accent in phpmyadmin it still shows zero results. The same goes for this code below in phpmyadmin: SELECT * FROM `FootballPlayers` WHERE `TeamName` LIKE 'Gençlerbirliği' Thanks
  23. Hi, sorry for not being around but i've been working on some other projects in my spare time and have now came back to this issue.Ok i have tried to print out the whole query in normal php and it comes up as follows once printed: SELECT * FROM FootballPlayers WHERE TeamName LIKE '%Gençlerbirliği%' ORDER BY CASE WHEN Positions LIKE 'GK%' THEN 1 WHEN Positions LIKE 'RB%' THEN 2 WHEN Positions LIKE 'LB%' THEN 3 WHEN Positions LIKE 'SW%' THEN 4 WHEN Positions LIKE 'CD%' THEN 5 WHEN Positions = 'D' THEN 6 WHEN Positions LIKE 'RW%' THEN 7 WHEN Positions LIKE 'LW%' THEN 8 WHEN Positions LIKE 'DM%' THEN 9 WHEN Positions LIKE 'CM%' THEN 10 WHEN Positions LIKE 'AM%' THEN 11 WHEN Positions = 'M' THEN 12 WHEN Positions LIKE 'FW%' THEN 13 WHEN Positions LIKE 'ST%' THEN 14 WHEN Positions = 'A' THEN 15 ELSE 16 END As you can see from above, the name is as it should be, so obviously it's going through the query ok.I then print out the result: $result=mysql_query($query) or exit(mysql_error());print $result; The outcome "Resource id #3" is then printed, not too sure what this means but it is printed.finally i try printing out the $num variable, i.e. the number of rows $num=mysql_numrows($result);print $num; Nothing is printed out when i try printing out $numI then tried the following in phpmyadmin: squad = "Gençlerbirliği";$query="SELECT * FROM FootballPlayers WHERE TeamName LIKE '%$squad%' ORDER BY CASE WHEN Positions LIKE 'GK%' THEN 1 WHEN Positions LIKE 'RB%' THEN 2 WHEN Positions LIKE 'LB%' THEN 3 WHEN Positions LIKE 'SW%' THEN 4 WHEN Positions LIKE 'CD%' THEN 5 WHEN Positions = 'D' THEN 6 WHEN Positions LIKE 'RW%' THEN 7 WHEN Positions LIKE 'LW%' THEN 8 WHEN Positions LIKE 'DM%' THEN 9 WHEN Positions LIKE 'CM%' THEN 10 WHEN Positions LIKE 'AM%' THEN 11 WHEN Positions = 'M' THEN 12 WHEN Positions LIKE 'FW%' THEN 13 WHEN Positions LIKE 'ST%' THEN 14 WHEN Positions = 'A' THEN 15 ELSE 16 END";$result=mysql_query($query) or exit(mysql_error());print $result; it brought out this result below: Ok as you can see, the name it tries to find in phpmyadmin is different, it says syntax error, i am not sure why as i have called the same sql database in this way before using php and it works fine for names without accents such as English names. The coding on the database is utf-8 general ci as it shows in phpmyadmin.Thanks and more help is apprechiated.
  24. Hi there,In a website i am creating i am having some problems with accented characters and comparing them with results from a MySQL database. Basically the accented word is searched but the database just says that no such entry is found. The database is for a website about football players and the problem i am having is with Turkish accented characters. A sample of what i have tried is below.teams.php (relevant code which calls squad.php)================================ print '<a href="/sql_testing/squad.php?squad='Gençlerbirliği'">Gençlerbirliği</a><br />'; ok so the above code will print what i put out and when you click on "Gençlerbirliği" it will load squad.php with the squad variable set as "Gençlerbirliği".Now on squad.php i do this:================== <?phpheader('Content-type: text/html;charset=utf-8');?><html><head></head><body><meta http-equiv="content-type" content="text/html; charset=utf-8" /> <?php if(isset($_GET['squad'])){ $squads = explode("=",$_SERVER['REQUEST_URI']); $squad = str_replace("%20&%20"," & ",$squads[1]); $squad = str_replace("%20"," ",$squad); $squad = trim(rawurldecode($squad));}else{ echo "No valid squad selected";}$con = mysql_connect('**********','*********','********');@mysql_select_db("*******",$con) or die(mysql_error());$query="SELECT * FROM FootballPlayers WHERE TeamName LIKE '%$squad%' ORDER BY CASE WHEN Positions LIKE 'GK%' THEN 1 WHEN Positions LIKE 'RB%' THEN 2 WHEN Positions LIKE 'LB%' THEN 3 WHEN Positions LIKE 'SW%' THEN 4 WHEN Positions LIKE 'CD%' THEN 5 WHEN Positions = 'D' THEN 6 WHEN Positions LIKE 'RW%' THEN 7 WHEN Positions LIKE 'LW%' THEN 8 WHEN Positions LIKE 'DM%' THEN 9 WHEN Positions LIKE 'CM%' THEN 10 WHEN Positions LIKE 'AM%' THEN 11 WHEN Positions = 'M' THEN 12 WHEN Positions LIKE 'FW%' THEN 13 WHEN Positions LIKE 'ST%' THEN 14 WHEN Positions = 'A' THEN 15 ELSE 16 END";$result=mysql_query($query) or exit(mysql_error());$num=mysql_numrows($result);mysql_close(); ok just to explain the above code, basically i am wanting to select a squad from the the table "footballplayers" where the team name is equal to the squad variable. I know i have not shown my print out code there but when i do go to print the row out where the squad equals to "Gençlerbirliği" it says no results found even though i have that team name in the database. The stuff after the order by statement is just ordering players by their position so that part is irrelevant.My question is, why will it not search the database properly with this name which has accented characters? The mysql database is using UTF-8 encoding and stores the name "Gençlerbirliği" as "Gençlerbirliği" when i look in phpmyadmin, so something must be wrong with the search variable's value. Sorry about not showing all of the php file, if you wish for it all shown then i can post the whole thing.p.s. no mysql error is generated from the die functions so i assume that it commits.Thanks,Mark
  25. ok i have tried that but now it said headers have already been sent, any idea how i can force the text to be in utf-8?here is the error on my apache server:Warning: Cannot modify header information - headers already sent by (output started at /home/****/****/****/teams.php:5) in /home/****/****/****/teams.php on line 19Line 19 is the line to set up the header information for UTF-8. I've astrixed some of the link above out so i don't really call the folders ****. ThanksEDITI try with the header code just above my <html> tag and it now works, thanks very much dude.
×
×
  • Create New...