PHP - Mysql Said: #1273 - Unknown Collation: 'ucs2_german2_ci'
i am trying to upload a .sql file on godaddy database and i am getting this error . Help me.
Similar TutorialsHey all, I keep getting this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2 When I use the script below. I'm finding it a bit confusing because everything about it continues to work, it's just it gives me an error. When the script runs, the outcome is "Success! Your dog now looks far more energetic! Looks like this food is all used up." Followed by the error, which cuts the remainder of the page off. Does anybody know why it's doing this? $dogyay = $_POST['dogid']; $checkenergy = "SELECT energy FROM dogs WHERE id=$dogyay"; $energylevel = mysql_query($checkenergy) or die(mysql_error()); $row = mysql_fetch_array($energylevel) or die(mysql_error()); if($row['energy'] >= 100) { echo "<b>Oops!</b> Looks like your dog is full right now...";} else{ echo "<b>Success! Your dog now looks far more energetic!</b><br><br>"; $sql11="UPDATE dogs SET energy=energy + 50 WHERE id=$dogyay"; $result11=mysql_query($sql11); $sql12="UPDATE items SET uses = uses - 1 WHERE itemid=$id"; $result12=mysql_query($sql12); $checkuses = "SELECT uses FROM items WHERE itemid=$id"; $useslevel = mysql_query($checkuses) or die(mysql_error()); $row = mysql_fetch_array($useslevel) or die(mysql_error()); if($row['uses'] == 0) { echo "Looks like this food is all used up.<bR><br>"; mysql_query("DELETE FROM items WHERE itemid='$id'") or die(mysql_error());} Thanks ! Hey, So what im trying to do is put my database variables into a session array. So this is what im trying to accomplish... $_SESSION['Name_of_Row'] = $value This is the script I wrote: Code: [Select] Function setupSession(){ session_start(); $query = "SELECT * FROM users WHERE u_id ='{$this->u_id}'"; $result = mysql_query($query); $row = mysql_fetch_array($result); foreach($row as $key => $value){ if(!empty($value)){ $_SESSION[$key] = $value; } } } When that runs I get the following warning. Can anyone tell me what this means and how to fix it? Error: Notice: Unknown: Skipping numeric key 0 in Unknown on line 0 I'm a newbie, can you please help? I'm getting a mysql error "Unknown column 'E0000001' in 'where clause'" The id is in the URL: ...user-profile.php?id=E0000001 My Query $query = mysqli_query($con, "SELECT * FROM UserList WHERE UserID=".$id) or die (mysqli_error($con)); Thank you Edited September 18, 2019 by ACBMSEYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '["rid"]., SELECT refid1 FROM oto_members WHERE id='13', SELECT refid2 FR' at line 5 With this script area: $affiliate1=('.$_REQUEST["rid"].'); $affiliate2=("SELECT refid1 FROM oto_members WHERE id='".$_REQUEST["rid"]."'"); $affiliate3=("SELECT refid2 FROM oto_members WHERE id='".$_REQUEST["rid"]."'"); $affiliate4=("SELECT refid3 FROM oto_members WHERE id='".$_REQUEST["rid"]."'"); $affiliate5=("SELECT refid4 FROM oto_members WHERE id='".$_REQUEST["rid"]."'"); $affiliate6=("SELECT refid5 FROM oto_members WHERE id='".$_REQUEST["rid"]."'"); $affiliate7=("SELECT refid6 FROM oto_members WHERE id='".$_REQUEST["rid"]."'"); $affiliat8e=("SELECT refid7 FROM oto_members WHERE id='".$_REQUEST["rid"]."'"); $affiliate9=("SELECT refid8 FROM oto_members WHERE id='".$_REQUEST["rid"]."'"); $affiliate10=("SELECT refid9 FROM oto_members WHERE id='".$_REQUEST["rid"]."'"); $qry="INSERT INTO ".$prefix."members(firstname,lastname,email,address,city,state,postcode,country,telephone,username,password,refid1,refid2,refid3,refid4,refid5,refid6,refid7,refid8,refid9,refid10,geo,paypal_email,joindate,mtype,groupid,cb_id,status,signupip) VALUES('".$_REQUEST["firstname"]."','".$_REQUEST["lastname"]."','".$_REQUEST["email"]."','".$_REQUEST["address"]."','".$_REQUEST["city"]."','".$_REQUEST["state"]."','".$_REQUEST["postcode"]."','".$_REQUEST["country"]."','".$_REQUEST["telephone"]."','".$_REQUEST["username"]."','".md5($_REQUEST["password"])."', $affiliate1, $affiliate2, $affiliate3, $affiliate4, $affiliate5, $affiliate6, $affiliate7, $affiliate8, $affiliate9, $affiliate10 ,'".$_REQUEST["geo"]."','".$_REQUEST["paypal_email"]."',NOW(),".$_REQUEST["mtid"].",$eogroup,'".$_REQUEST["cb_id"]."','$memberstatus','$signupip')"; Hi All, I want to display lists of words (utf8 encoded) correctly ordered in Spanish, where "ch" and "ll" are considered as letters in the alphabet. For French, I use the following : $col = new Collator('fr_FR'); $col->setAttribute(Collator::FRENCH_COLLATION, Collator::ON); $col->asort(<array-to-sort>); What would be the equivalent for spanish? Thanks! Hello! I have a strange error on my PHP script and i dont how to fix it. If someone can help me, please help me then! Here is my error: Code: [Select] logout(); } else { $iq = mysql_query("SELECT * FROM users WHERE username='{$signin_username}' AND password='{$signin_password}' AND suspended='0' LIMIT 1;"); $ir = mysql_fetch_array($iq); $_SESSION['me'] = $ir; } } } } else { die("The configuration did not recieve appropriate variables to accept your request."); } if ($set['next_clearup'] < time ()) { $next_clearup = time () + 60 * 60 * 24; mysql_query ('' . 'UPDATE settings SET set_value=\'' . $next_clearup . '\' WHERE set_name=\'next_clearup\' LIMIT 1;'); mysql_query ('UPDATE users SET ads_clicked=\'\' WHERE ads_clicked!=\'\''); } } ?> Warning: include(THDIRindex.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\Upload\index.php on line 16 Warning: include() [function.include]: Failed opening 'THDIRindex.php' for inclusion (include_path='.;\xampp\php\PEAR') in C:\xampp\htdocs\Upload\index.php on line 16 And here is the PHP file the error is in: Code: [Select] <?php session_start(); include_once('lib/lib.php'); include_once('lib/configuration.php'); $ddir = THDIR.$do->get_file_url(); include($ddir); if(file_exists(HEADER)) { include_once(HEADER); } if($contents) { print $contents; } if(file_exists(FOOTER)) { include_once(FOOTER); } ?> Help ASAP if you can! Hey, I've got a query in which a variable is interpreted as a column and I don't why this is caused. $upgrade_time_sql = "SELECT * FROM todo_upgrades WHERE profile_id = ".$profile_id." AND level = ".$profile_data['level2_'.$show.'']." AND type = ".$show.""; $upgrade_time_res = mysql_query($upgrade_time_sql) or die (mysql_error()); $show is filled with the content "storage" The mysql_error is "Unknown column 'storage' in 'where clause'" Thanks for helping. Hey im kind of new to PHP me and my mate was working on a script and we can not seem to get this working: Its connected through mysql. And it shows Quote Notice: Undefined index: username in C:\xampp\htdocs\stick_arena.php on line 21 Notice: Undefined index: userpass in C:\xampp\htdocs\stick_arena.php on line 22 Notice: Undefined index: action in C:\xampp\htdocs\stick_arena.php on line 23 Notice: Undefined index: usercol in C:\xampp\htdocs\stick_arena.php on line 24 Notice: Undefined index: stats in C:\xampp\htdocs\stick_arena.php on line 25 Here are the lines Quote // declare variables $username = sanitize($_POST['username']); $password = sanitize(md5($_POST['userpass'])); $action = sanitize($_POST['action']); $usercol = sanitize($_POST['usercol']); $stats = sanitize($_POST['stats']); Here is the full script for that page: Click here please help as soon as possible. im using 000webhost as a test site and when i run this code it redirects me to there err page but with no error message. the sql query works fine in phpmyadmin and i added the rest of the code to try the php side. i "think" the problem is the echo $rows"value's" as im unsure of what the $vars should be <?php include("config.php"); // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql = "SELECT make, COUNT(*) AS total, SUM(IF(comments = \'pass\', 1, 0)) AS withComments FROM dsgi_serval GROUP BY make ORDER BY COUNT(*) DESC"; $result=mysql_query($sql); echo "$sql"; echo "$result"; ?> <table><tr> <td colspan="4"><strong>List data from mysql </strong> </td> </tr> <tr> <td align="center"><strong>make</strong></td> <td align="center"><strong>Total</strong></td> <td align="center"><strong>Validated</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td><?php echo $rows['make']; ?></td> <td><?php echo $rows['total']; ?></td> <td><?php echo $rows['withcomments']; ?></td> </tr> <?php } ?> </table> <?php mysql_close(); ?> I Am getting along with php better than I was previously. But this 68 year old brain still refuses to learn very fast! Here is the error I'm receiving when I'm trying to open the db: Parse error: syntax error, unexpected T_VARIABLE in /home/taft65/public_html/memProtest.php on line 197 <?php error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR); $host = "localhost"; $dbname="database;" Failing ------>$username = "user"; $password="drDedf#hj"; I understand you do not need to declare varibles in PHP, Correct? I checked the db to ensure that I'm calling the correct value. NuSpherePhpEd to validate the code. I also check it with DSV PHP Editor. Both come up with the same error. I'm also using MyPhpAdmin to create the database and tables. I know also to place this calling info in another folder and include it by calling it with a php include statement. I just have it within the code to quickly test it. Thank you for any assistance. Bob... Hi there, I am NOT a PHP coder, but I have a site that is written in PHP and I am getting an error that keeps filling up my site cache and I just cannot figure it out - I know it has something to do with my images on the site, but none of them are out of the ordinary (GIFs and JPEGs, the only character apart from letters or numbers that i have used is the "_" and there are no spaces). I have looked around at the error I am getting - but I will be honest in that I dont really understand what the problem is or how to resolve it. Here is the error I get: PHP Warning: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Unknown modifier 'C' in /home/smcclean/public_html/includes/modules/additional_images.php on line 48 This relates to the following line of code: if(preg_match("/" . $products_image_base . "/i", $file) == 1) { I would really appreciate a steer as to how I could resolve this. Many thanks Hey I have a script that builds an array but for some reason there is a loose integer in the variable which is confusing me and i think its the cause of my syntax errors in javascript. But i got no idea where it is coming from =/ Here is the function i use: Code: [Select] <?php function img($id) { $img = array(); $img['tiles'] = $this->db->getAll("SELECT DISTINCT t.id, CONCAT('data/tiles/',filename) AS f FROM `map_tiles` AS mt INNER JOIN `tiles` AS t ON (mt.tile=t.id) WHERE mt.map_id={$this->db->qstr($id)}"); echo print_r($img); die; //exit(json_encode($img)); // turned off for testing ?> The echo returns this: Code: [Select] Array ( [tiles] => Array ( [0] => Array ( [id] => 10 [f] => data/tiles/floor.png ) ) ) 1 <----- why does this appear? And could this cause a syntax error if sent back for JS processing? As you can see there is 1 showing at the end but i don't see why =/ Any ideas if thats suppose to happen ? So I've been working on this site for a few days now, and it's coming along slow but well. I'm trying to learn as much as possible about the coding I'm doing because it's a bit outside my skill range, so I'm taking my time. I'm using a switch statement to dictate navigation, and netsted switches inside as well. Everything was going great until I started continuing to add code to each case of the switch, then all of a sudden 2 of the cases show up blank, but nothing else is affected. I spend an hr last night and this morning, looking and redoing, to get the same result. Can someone take a look at this and advise please? <?php switch ($_GET['page']) { case 'news': switch ($_GET['id']) { case $_GET['id']: $id = $_GET['id']; $link = mysql_connect ($host, $user, $pass); mysql_select_db ($db, $link); $query = "SELECT * from news WHERE id = '$id'"; $result = mysql_db_query ($db, $query, $link); while ($row = mysql_fetch_array($result)){ echo ("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"2\" class=\"Main-Header\"><a href=\"index.php?page=news&id=".$row['id'] . "\">".$row['title'] . "</a></td> </tr> <tr> <td colspan=\"2\" class=\"Main-PostInfo\">Posted By: $row[author] on $row[date]</td> </tr> <tr> <td colspan=\"2\" class=\"Side-Content\">$row[content]</td> </tr> </table><br /> "); } break; default: $link = mysql_connect ($host, $user, $pass); mysql_select_db ($db, $link); $query = "SELECT * from news'"; $result = mysql_db_query ($db, $query, $link); while ($row = mysql_fetch_array($result)){ echo ("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"2\" class=\"Main-Header\"><a href=\"index.php?page=news&id=".$row['id'] . "\">".$row['title'] . "</a></td> </tr> <tr> <td colspan=\"2\" class=\"Main-PostInfo\">Posted By: $row[author] on $row[date]</td> </tr> <tr> <td colspan=\"2\" class=\"Side-Content\">$row[content]</td> </tr> </table><br /> "); } break; } break; case 'about'; $link = mysql_connect ($host, $user, $pass); mysql_select_db ($db, $link); $query = "SELECT * from aboutvow"; $result = mysql_db_query ($db, $query, $link); while ($row = mysql_fetch_array($result)){ echo ("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td class=\"Main-Header\">$row[title]</td> </tr> <tr> <td class=\"Side-Content\">$row[content]</td> </tr> </table><br /> "); } break; case 'roster': switch ($_GET['id']) { case $_GET['id']: $id = $_GET['id']; $link = mysql_connect ($host, $user, $pass); mysql_select_db ($db, $link); $query = "SELECT * from roster WHERE id = '$id'"; $result = mysql_db_query ($db, $query, $link); while ($row = mysql_fetch_array($result)){ echo ("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td width=\"30\" colspan=\"2\" class=\"Main-Header\">-VoW- $row[gamename]</td> </tr> <tr> <td colspan=\"2\" class=\"Main-PostInfo\">SECTION 1: PERSONAL INFORMATION</td> </tr> <tr> <td class=\"Side-Content-Left\">Name</td> <td class=\"Side-Content-Right\">$row[firstname] $row[lastname]</td> </tr> <tr> <td class=\"Side-Content-Left\">Location</td> <td class=\"Side-Content-Right\">$row[location]</td> </tr> <tr> <td class=\"Side-Content-Left\">Age</td> <td class=\"Side-Content-Right\">"); date_default_timezone_set('America/New_York'); function calculateAge($dob){ return floor((time() - strtotime($dob))/31556926); } $age = calculateAge("$row[dob]"); echo ("$age</td> </tr> <tr> <td class=\"Side-Content-Left\">Connection</td> <td class=\"Side-Content-Right\">$row[connection]</td> </tr> <tr> <td colspan=\"2\" class=\"Main-PostInfo\">SECTION 2: CONTACT INFORMATION</td> </tr> <tr> <td class=\"Side-Content-Left\">Email</td> <td class=\"Side-Content-Right\">$row[email]</td> </tr> <tr> <td class=\"Side-Content-Left\">Steam</td> <td class=\"Side-Content-Right\">$row[steamfriends] ($row[steamemail])</td> </tr> <tr> <td class=\"Side-Content-Left\">Xfire</td> <td class=\"Side-Content-Right\">$row[xfire]</td> </tr> <tr> <td colspan=\"2\" class=\"Main-PostInfo\">SECTION 3: DAY OF DEFEAT INFORMATION</td> </tr> <tr> <td class=\"Side-Content-Left\">DoD Experience</td> <td class=\"Side-Content-Right\">"); date_default_timezone_set('America/New_York'); function calculateExp($exp){ return floor((time() - strtotime($exp))/31556926 + 8); } $exp = calculateExp("$row[dodexp]"); echo ("$exp Years</td> </tr> <tr> <td class=\"Side-Content-Left\">Class</td> <td class=\"Side-Content-Right\">$row[class]</td> </tr> <tr> <td class=\"Side-Content-Left\">SteamID</td> <td class=\"Side-Content-Right\">$row[steamid]</td> </tr> <tr> <td colspan=\"2\" class=\"Main-PostInfo\">SECTION 4: MATCH INFORMATION</td> </tr> <tr> <td colspan=\"2\" class=\"Main-Content\">-VoW- $row[gamename] has no match history</td> </tr> </table><br /> "); } break; default: $link = mysql_connect ($host, $user, $pass); mysql_select_db ($db, $link); $query = "SELECT * from roster"; $result = mysql_db_query ($db, $query, $link); while ($row = mysql_fetch_array($result)){ echo ("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"5\" class=\"Main-Header\">Roster</td> </tr> <tr> <td width=\"101\" class=\"Main-Roster-Left\">Name</td> <td width=\"124\" class=\"Main-Roster\">Status</td> <td width=\"241\" class=\"Main-Roster\">SteamID</td> <td width=\"175\" class=\"Main-Roster\">Class</td> <td width=\"452\" class=\"Main-Roster\">Recruitment Date</td> </tr> <tr> <td class=\"Main-Roster-Content-Left\"><a href=\"index.php?page=roster&id=".$row['id'] . "\">".$row['gamename'] . "</a></td> <td class=\"Main-Content-Roster\">$row[status]</td> <td class=\"Main-Content-Roster\">$row[steamid]</td> <td class=\"Main-Content-Roster\">$row[class]</td> <td class=\"Main-Content-Roster\">$row[admin_recdate]</td> </tr> </table>"); } break; } break; case 'servers': switch ($_GET['id']) { case 1: echo "ID is 1"; break; case 2: echo 'ID is 2'; break; default: echo 'No ID - display main servers'; break; } break; case 'forum'; echo ("FORUM HERE"); break; default: $link = mysql_connect ($host, $user, $pass); mysql_select_db ($db, $link); $query = "SELECT * from news ORDER BY date DESC LIMIT 5"; $result = mysql_db_query ($db, $query, $link); while ($row = mysql_fetch_array($result)){ echo ("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"2\" class=\"Main-Header\"><a href=\"index.php?page=news&id=".$row['id'] . "\">".$row['title'] . "</a></td> </tr> <tr> <td colspan=\"2\" class=\"Main-PostInfo\">Posted By: $row[author] on $row[date]</td> </tr> <tr> <td colspan=\"2\" class=\"Side-Content\">$row[content]</td> </tr> </table><br /> "); } break; case 'recruitment': switch ($_GET['action']) { case 'apply': echo "APPLICATION HERE"; break; case 'submit': echo 'SUBMIT APPLICATION'; break; case 'status': echo 'APPLICATION STATUS'; break; default: echo 'No ACTION - display main recruitment'; break; } break; } ?> The problem I am having is getting the default news case and default roster case to print. Everything else shows up properly. Sorry for the messy code, I"m working on it! Hello again, Though this question is somewhat related to my prior note, I thought it was probably different enough to justify a separate topic... So, I have a link at site1.com/dir/admin/?param1=value¶m2=value, etc, which I want to redirect to site2.com with all the rest being the same. Thanks to your help, it's working with two specified parameters However, there is a relatively short list of potential parameters (maybe 5?) but not all of them are passed in all calls to the link. In other words, sometimes the link is called with param1 and param2, sometimes with 1 and 3, sometimes with 1,2, and 4, etc. What is the best way to do the redirect which would ensure that all the parameters which are sent to the initial link are then included in the redirect? Is there a way to search the incoming link and grab all parameters in it? Or do I put together the list of possible parameters and then grab the values with $_GET for all of them and then pass all of them even if the values are null (not sure whether the app will accept that or not...) I hope I'm stating the question clearly enough! Thanks in advance for your help! I'm using the php mail function and sending to Gmail accounts it shows "Unknown Sender" This is my header: Code: [Select] $headers = "From: XXXXX\r\nReply-To: XXXX@XXXXX.com"; $headers .= "\r\nContent-Type: text/html; charset='iso-8859-1' Content-Transfer-Encoding: 7bit"; I read somewhere that removing the "\r" would work but no luck... any help would be awesome I GET QuoteFatal error: TPL: [in line 0]: syntax error: file 'm/pg/_categories' does not exist in C:\WebServ\httpd\libs\tpl\class.template.php on line 943 unset($_templatelite_tpl_vars); else: $_templatelite_tpl_vars = $this->_vars; echo $this->_fetch_compile_include($this->_vars['TPLx'].'m/pg/_categories'.$this->_vars['HTML'], array()); $this->_vars = $_templatelite_tpl_vars; WITH FILES http://testynarkotykowe.j13x.pl/index.txt && http://testynarkotykowe.j13x.pl/indexpg.txt HOW TO FIX IT Im trying to make a script that draws the track for a game that i in development, Im stuck on something though. For some reason my script is drawing lines from 0,0 to the x,y of the start position to the x,y of the end position. I have no idea why. Here is the script <?php header ("Content-type: image/png"); $im = ImageCreate (700, 400); $background = ImageColorAllocate ($im, 255, 255, 255); $line = ImageColorAllocate ($im, 0, 0, 0); $trackcode = file_get_contents('test.txt'); $type = split("#", $trackcode); $line = split(",", $type[0]); $sline = split(",", $type[1]); for($i=0; $i<count($line); $i++) { $section = split(" ", $line[$i]); for($j=0; $j<count($section); $j+=2) { $startx = base_convert($section[$j],32,10); $starty = base_convert($section[$j+1],32,10); $endx = base_convert($section[$j+2],32,10); $endy = base_convert($section[$j+3],32,10); //echo "startx: $startx | starty: $starty | endx: $endx | endy: $endy <br>"; imageline ($im,$startx,$starty,$endx,$endy,$line); } } ImagePng ($im); ImageDestroy ($im); ?> You can echo the data if you want to see the raw coordinates. You will need to make a file called test.txt and put this in it for it to work Code: [Select] 42 1i 5u a,8e a 8e -a 8e -u 8e -1i 92 -18 92 0 9m a aa 0 au -a au a,8e -1i 9m -26 au -1i aa -18 9m -1i 92 -18,6i a 84 a,b8 -a b8 a cg u d4 k do u do a do -a do -u cg -1i bs -18,do -u d4 -k bs -18,b8 -a bs -k bs 0 cg a d4 0 d4 -k,e2 k e2 -1i em -18,e2 -u em -k em u,fa -u fu -k gi -u fa -1i em -18,fu -k fu k fu u,gi k gi -u,fa -u em -k,6i a 5u a,gs -u gs 0 gs a i4 u jc a jc -u,gs -18 gs -u,gs -18 hg -1i hg 0 gs a,hg 0 i4 a io 0 jc a,io 0 io -1i jc -18 jc -u,jm a ku u li k m6 u m6 a,jm a jm -a ka -k ka 0 ku a li 0 li -k m6 -u m6 a,li -k ka -18 ku -1i m6 -u,mg a no u p0 a p0 -a oc -k no -u,oc -k p0 -u no -1i no -18 no -a,mg a n4 0 no a oc 0 no -a,qi a qi k r6 u r6 0 t2 u t2 a se 0 t2 -a,qi a qi -a,qi -1i qi 0,qi -1i rq -26 t2 -1i t2 -u t2 -a,r6 -18 rq -1i se -18 t2 -1i,se -18 se -k rq -a r6 -k r6 -18,qi -1i r6 -18,tc k u0 u,tc k tc 0 tc -18 u0 -1i u0 u,ua a vi u 10q a 10q -k 10q -1s 106 -26 106 -1i,ua a ua -a ua -u uu -k uu 0 vi a 106 0 106 -k 10q -u,ua -u vi -1i 106 -18 106 -1i,106 -k vi -u uu -k,114 a 12c u 130 k 11o 0 11o -a,114 a 114 -a 114 -u 12c -1i 13k -u 130 -k 130 -a 130 0 13k -a 13k -u,130 -k 12c -u 11o -k 114 -u,11o -k 11o -a,13u k 13u -u 13u -18 14i -1i 14i 0,13u k 14i u 14i 0,17m a 19i 1i 1es 1i 3d2 1i,pa a q8 a,8e a 9m u au a,e2 k em u,gi k fu u,42 1i -1mm 1i,17m a 14s a#9m -1i 9m -a aa 0,9m -a 92 0,bs 0 cg -a cg -u,cg -a d4 0,bs -k cg -u,em -k fa -a fa a fu 0,fa -a fu -k,em 0 fa a,hg 0 i4 -a io 0,hg -k i4 -u i4 -a,i4 -u io -k,ka 0 ku -a li 0,ku -a ku -u,ka -k ku -u,no -1i mg -u mg -a n4 0,mg -u no -a,no -u n4 -k,r6 -18 rq -u rq -a,rq -u se -18,tc -18 tc -1s u0 -1i,uu 0 vi -a vi -u,vi -a 106 0,11o -k 12c -a 12c a,12c -a 130 -k,130 0 12c a,14i -1i 156 -18 156 -k 14i -u# I have no idea why it isnt working properly, any help will be greatly appreciated. I have searched this forum as well as over 200 other forums and have not found the answer that is specific to my question. I have shortened my code drastically to assist in resolving this quickly -
I have a search form that has criteria for the search criteria with "virtual" "columns" in an array but it's not working. If I search one column at a time it works just fine but when I try to search 8 columns with one select I get the following error: SELECT Error: Unknown column 'achievements' in 'where clause'.
When a user selects search in Achievements, I need it to look at all 8 columns that are associated with achievements and bring back the results that match - the same as if the user selects search in Associations, I need it to look at all 5 columns and bring back the results that match.
My shortened code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Search</title> </head> <body> <form name="search" action="" method="POST"> <p>Search:</p> <p> Achievements/Associations: <input type="text" name="find1" /> in <Select NAME="field1"> <Option VALUE="achievements">Achievements</option> <Option VALUE="associations">Associations</option> </Select> <br><br> Secondary Education: <input type="text" name="find2" /> in <Select NAME="field2"> <Option VALUE="edu1sectype">Highest Certificate Attained</option> <Option VALUE="edu1secname">Highest Grade Passed</option> <Option VALUE="edu1secinst">Name of High School</option> <Option VALUE="edu1secdate">Date Completed</option> <Option VALUE="edu1secinsttyp">Type of Institution</option> <Option VALUE="subjects">Subjects</option> </Select> <br><br> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </p> </form> <?php $searching = $_POST['searching']; $find1 = $_POST['find1']; $field1 = $_POST['field1']; $find2 = $_POST['find2']; $field2 = $_POST['field2']; if ($searching =="yes") { echo "<br><b>Searched For:</b> $find1 $find2<br>"; echo "<br><h2>Results</h2><p>"; //If they did not enter a search term we give them an error // Otherwise we connect to our Database include_once "connect_to_mysql.php"; mysql_select_db("table_name") or die(mysql_error()); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim($find); $find = mysql_real_escape_string($find); $field = mysql_real_escape_string($field); $data = mysql_query("SELECT * FROM table_name WHERE upper(".$field1.") LIKE '%$find1%' AND upper(".$field2.") LIKE '%$find2%' ") or die("SELECT Error: ".mysql_error()); $result = mysql_query("SELECT * FROM table_name WHERE upper($field1) LIKE '%$find1%' AND upper($field2) LIKE '%$find2%' ") or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($result); echo "There are $num_rows records:<br>"; echo '<center>'; echo "<table border='1' cellpadding='5' width='990'>"; // set table headers echo "<tr><th>Reference</th> <th>First Name</th> <th>Last Name</th> </tr>"; //get images and names in two arrays $name= $row["name"]; $surname= $row["surname"]; $achieve1 = $row["achieve1"]; $achieve2 = $row["achieve2"]; $achieve3 = $row["achieve3"]; $achieve4 = $row["achieve4"]; $achieve5 = $row["achieve5"]; $achieve6 = $row["achieve6"]; $achieve7 = $row["achieve7"]; $achieve8 = $row["achieve8"]; $assoc1 = $row["assoc1"]; $assoc2 = $row["assoc2"]; $assoc3 = $row["assoc3"]; $assoc4 = $row["assoc4"]; $assoc5 = $row["assoc5"]; $edu1sectype = $row["edu1sectype"]; $edu1secinst = $row["edu1secinst"]; $edu1secname = $row["edu1secname"]; $edu1secdate = $row["edu1secdate"]; $edu1secinsttyp = $row["edu1secinsttyp"]; $subject1 = $row["subject1"]; $subject2 = $row["subject2"]; $subject3 = $row["subject3"]; $subject4 = $row["subject4"]; $subject5 = $row["subject5"]; $subject6 = $row["subject6"]; $subject7 = $row["subject7"]; $subject8 = $row["subject8"]; $compsoft1name = $row["compsoft1name"]; $compsoft2name = $row["compsoft2name"]; $compsoft3name = $row["compsoft3name"]; $compsoft4name = $row["compsoft4name"]; $compsoft5name = $row["compsoft5name"]; $compsoft6name = $row["compsoft6name"]; $achievements = array('achieve1', 'achieve2', 'achieve3', 'achieve4', 'achieve5', 'achieve6', 'achieve7', 'achieve8'); $associations = array('assoc1', 'assoc2', 'assoc3', 'assoc4', 'assoc5'); $subjects = array('subject1', 'subject2', 'subject3', 'subject4', 'subject5', 'subject6', 'subject7', 'subject8' ); $compsoft = array('compsoft1name', 'compsoft2name', 'compsoft3name', 'compsoft4name', 'compsoft5name', 'compsoft6name'); while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td ALIGN=LEFT>" . $row['id'] . "</td>"; echo "<td ALIGN=LEFT>" . $row['name'] . "</td>"; echo "<td ALIGN=LEFT>" . $row['surname'] . "</td>"; echo "</tr>"; } echo "</table>"; //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query"; } } ?> </body> </html>Any assistance will be greatly appreciated as I have been working on this website for the past 4 months which has totalled over 150 pages and this is one of the last pages left to program and it's taken 6 days to get to this search page to this point. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=321386.0 Hi there I'm trying to insert audi files' records into mysql database this is how the records insertion looks like: Code: [Select] $fileName = $_FILES['uploaded']['name'];//name $tmpName = $_FILES['uploaded']['tmp_name'];//temp location $fileSize = $_FILES['uploaded']['size'];//size of the file $fileType = $_FILES['uploaded']['type'];//type of file $error = $_FILES['uploaded']['error'];//verifys errprs $ext = substr($fileName, strrpos($fileName, '.') +1); //this will get the extention out of the file name e.g. .mp3 //check that a file is passed by and no errors if(isset($fileName) && $error == 0 && $fileSize != 0){ //condition to accept only certain file types/extentions if($ext == "mp3" || $ext == "wma" || $ext == "wav"){ //get file content $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } //query to retrieve user's id $userid = mysql_query("select userID from user where username = '$username'"); //to get id by username $row = mysql_fetch_assoc($userid); $userid = $row['userID']; $query = "INSERT INTO tracks (trackName, userID, tag, price, file, fileName, fileSize, fileType) VALUES ('$tname','$userid','$tag','$price','$content','$fileName','$fileSize' , '$fileType)"; mysql_query($query) or die (mysql_error()); when i send it i get this error: Unknown column 'application' in 'field list' i did set data type for the fileType field to varchar. when i remove the fileType all together the record is inserted successfully into database though. ?!! can anyone help please |