Finding Only Records That Don't Match
I have a MySQL query that is supposed to pull records from a 'links' database. In the website, users can vote on links so I register a vote in a vote table with a link id and a user id. I need a way to pull all links that do not have a matching record in the vote table that has a specific user_id. Code:
SELECT *
FROM links, votes
WHERE votes.link_id = links.id
AND votes.user_id != 1
The problem is that there may be several records in the vote table for a single link_id. If user 1 has voted on link 800, and so has user 2, then this query will still pull link 800 because it finds a record in votes where the user_id is not 1. How can I change it so that NO records from the links table are pulled if the votes table has a record for the link_id and the user_id? If user 1 has voted on link 800 then I want to completely ignore link 800. If user 1 has not voted on 800 then I want to pull link 800.
View Complete Forum Thread with Replies
Related Forum Messages:
Finding Records
Need to setup a query that checks a certaid field for any value, what is the syntax for that? $query = ("SELECT * FROM `tbl_customers` WHERE `sales_rep` LIKE '%$any_value%'");
View Replies !
Finding Records Within The Last 48 Hours?
I can't seem to find anything on querying to find records dated within the last 48 hours. Not just two days/calendar dates, but 48 actual hours. I'm hoping to do something like: SELECT record FROM table WHERE postdate > (NOW - 48hrs) does that make sense?
View Replies !
Finding Number Of Records
I'm attempting to query a database to find out how many occurances of a particular value exist. So I'm trying to select where the same VendorNumber occurs less than twice, or more than twice. If it only occurs twice I do not care. I would like to also be able to see what the Value of the VendorNumber is. I've tried various syntax with count, distinct, and having, but I'm not sure I understand how it all works. In brief, I have a table called Vendor, which has the following entries for the VendorNumber field: 123123 123456 123456 123789 123789 123789 I'd like the query to tell me there is 1 occurance of less than 2, and there is 1 occurance of more than 2. It would be fine if these are separated out into two different queries to put into a php page. I'd also like to see the VendorNumber displayed.
View Replies !
Finding Unique Records
I have a database full of people details. And I want to extract each unique Nationality, then count how many of the nationality there are. Make sense? So i end up with a table like: English: 23 French: 36 German: 2 etc
View Replies !
Do A DELETE Statement To Remove Any Records That Don`t Match.
I`m just trying to figure out the best method to delete my records and wondered if it was possible to do a DELETE statement to remove any records that don`t match. Here is my code so far: $Query="select blah its huge:-)"; $RESULT=mysql_query($Query); $my_rows=mysql_num_rows($RESULT); for ($a=0; $a<$my_rows; $a++){ mysql_data_seek($RESULT, $a); $Array = mysql_fetch_array($RESULT); printf("%s<BR>", $Array['Email']);} My Query returns Matched Records, what I would like to achieve is deletion of the records that didn`t match, would it be possible to do that under the printf statement. So delete all the records in the table that don`t match up to $Array['Email']??
View Replies !
Finding Records Relative To The Primary Key
To enable 'previous' and 'next' arrows on a page, I need a way to query my database and find the two records that have next lowest and the next highest value of the primary key field "primaryid". I realize that these values won't necessary be the current record "-1" or "+1", since after deletions a newly created record doesn't have just the next value up from the existing highest value for the primary key field. Code:
View Replies !
Finding Matches In A Table And Then Moving That Match To Another Table?
Ok, I have a database that has a table called critiera in this table is to fields on is ID and the other is critiera. Now I want to filter out all the one that don't apple to the list and move the one that match to a different database. I know how to open a connection, close, select but I don't know how I would inside of a database use another one as the way to create the list of critieras....
View Replies !
Match Array Key To Query Match
I have an array that I output through a loop. It's a list of states. Now I need to run a query ona table and if I find any results associated with this state in db mark this table with, say <strong>State</strong> tags. Having difficulties figuring it out. I'd hate to run a query 50 times to get the results. There's gotta be a better way.
View Replies !
Dont Add Twice
I have a form and a word is put in to a database, but i dont want the same word goin in twice. so for example when user puts a word in there and its already in there it will produce an error. <?php { $sql = "INSERT INTO search (search_word) VALUES ('$trimmed')"; $result= mysql_query($sql, $conn) or die(mysql_error()); } ?>
View Replies !
Preg Match To Match A Url
Trying to use preg_match to match the following form http://www.example.com/user-45...what am i doing wrong? preg_match("/^http[://]+[www]+.[a-z0-9-_]+.[a-z.]{2,6}+[/a-z0-9-_]$/i",$_POST['url'])
View Replies !
Is_int() Dont' Work With GET
how do i get a variable throught $_GET['']; and then check if it's a integer. i tried is_int() that doesn't work what i'm trying to do. is check if a var is an integer cause it goes into a db query. if (!is_int($_GET['tutid']) || !is_int($_GET['pageno'])) { // display error msg. }else{ // do query } that doesn't work.
View Replies !
Are There Still Browsers That Dont Work With PHP?
Spent some time searching google and haven't found any information stating that there are, or ever was, a browser that didnt handle PHP. Anyone know anything otherwise? If so, how could one test a browser for PHP capabilities? My thought on this is that if there is a browser that doesn't handle PHP, it's so old that I shouldn't worry about it. Anyone know of someone still using a Tandy?
View Replies !
LOGIN - Cookies Dont Set
my login allows you to login with for example 'steven' when your username is 'Steven' this throws off some things. how do i make it so when they login its an exact match also the cookies dont set if anyone wants to take a stab at that! Code:
View Replies !
PHP Variables Dont Show Up
folks, I am writing a RSS feed as below. You will notice that, in <link> </link> tabs I am trying to output a PHP variable value (which is a URL)Problem is that although I see the value being output OK on commandline execution on the server, e.g. %php foo.php, when I load the page in the browser, the out put for that variable is empty!! i.e. If I see the page source then I dont see <link>value-of-the-variable</link> instead, the tabs show up as <link> </link> I am at my wits end on how to get this working. any ideas? Code:
View Replies !
Images Dont Get Stored..
i am trying to store images in a database and then show them depending on what user is logged in . i wrote ( and borrowed) the following code : PHP Code: <? ob_start(); include "include/session.php"; ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>HALL OF FAME</title> <meta name="GENERATOR" content="Arachnophilia 4.0"> <meta name="FORMATTER" content="Arachnophilia 4.0"> </head> <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"> </body> </html> <? $host = "localhost";
View Replies !
Sessions Dont Expire
This code is at the top of all of my files for a certain application, and all of the files are in the same directory: $expireTime = 10 * 60;// 10 minutes session_set_cookie_params($expireTime); // start the session @session_start(); @header("Cache-control: private"); //IE 6 Fix the problem is that after 10 minutes, the scripts seem to still remember all SESSION variables. I have to manually unset the SESSION variables, or kill the session entirely, in order for the SESSION variables to go away. basically, what I'm trying to do here is unset all SESSION variables after 10 minutes of inactivity.
View Replies !
Image Dont Show
I want to have members with image1.jpg as their avatar not to show in the random if statement. How would I add that to the following statement? Code: if ( $b = sql_query("user","`user`,`day`,`month`,`year`,`location`,`gender`,`city`,`state`"," ORDER BY rand() LIMIT 0,1",TRUE) )
View Replies !
Displaying Priorty Records And Normal Records In The One Dataset.
I have a page which displays the records from the database and uses paging to display the records in groupes of 10 per page. I now want to be able to show results depending on the database field (display) in the database (can be set to either "full" or "limited"). If the record and the field display is equal to "full" i want to then display this record at the top of the record set and display all the fields. If the record is equal to "limited" i want to display different results and they must show after all the records which are equal to "full". I can't output two different recordsets as i use paging and only want to show 10 records per page. Code:
View Replies !
Php Sees The Images, The Public Dont
Could anyone tell me if they know how to let php access a directory to display images etc, but prevent public from simply typing "www.mysite.com/gifs/thisfile.gif". I am pretty sure it has something to do with .htaccess files, but as I am relatively new to all this, I'm a wee bit stumped! Any code, links to good tutorials, or any help at all will be greatly appreciated! Oh, by the way, the php script is displayed only if members have logged in via a mySQL db, if you needed to know that.
View Replies !
Include Security -what Works, What Dont?
comment on the following methods of preventing cross site scripting and/or other nastiness: 1: $pages = array('home','contact','about','links' ); // could also build this array with readdir('MySafeDir') ?? if( in_array($_GET['page'], $pages) ) { include $_GET['page'].".php";} else {die("Nice Try."); } 2: include "my_prefix_".$_GET['page'].".php"; 3: include "my_safe_dir/".$_GET['page'].".php"; 4: include_path=".:/myIncludes"; include $_GET['page'].".php";
View Replies !
Wildcard * Dont Work On Server
I am * wildcard in my localhost phpMyAdmin 2.5.3. Problem comes if I use it online in my server using phpMyAdmin - 2.9.0.2. It only accepts if I indicate all field names one by one. heres the code: <? $sql = "SELECT * FROM tbl_news WHERE news_id = $news_id"; It only works if I use: <? $sql = "SELECT content, picsmall, piclarge, news_id, title, dt_created FROM tbl_news WHERE news_id = $news_id"; What shall I replace * so I dont have to write all of my field names in the query?
View Replies !
Php + Math = Dont Wanna Work
this thing has been pissing me off for over an hour now..and its so simple im about ready to throw my computer out the window $usrid = $_SESSION['uId']; $totpost = $_SESSION['totalpost'] + 1; $totrank = $_SESSION['elranking'] + 1; $_SESSION['elranking'] = $totrank; $_SESSION['totalpost'] = $totpost; $query2 = "UPDATE elusers SET `totalPOST` = '".$totpost."', `elranking` = '".$totrank."' WHERE `uId` = ".$usrID.""; am i doing wrong here.
View Replies !
Download Link For Exe Files Dont Work!
i'm developing a php app that shows folders and subfolders with their content so someone can download files from those browsers. the problem is: the download does not work for exe files! http://www.scotland.ca/dmspro/_uplo...4Std_Manual.PDF works and http://www.scotland.ca/dmspro/_uplo...-%20netants.zip works too! but http://www.scotland.ca/dmspro/_uplo...ils/wrar320.exe and http://www.scotland.ca/dmspro/_uplo...ISO_v6_5_en.exe do not work!!! where could be the problem there??
View Replies !
Sessions Dont Seem To Be Working With Internet Explorer
I wrote an authentication class in php4. The sessions dont seem to be working with internet explorer, just with FF. here is the code below, a cookies notice pops up when you try and login: <?php class auth { var $UserID; var $AdminLevel; var $FirstName; var $LastName; var $DateAdded; var $MobileTelephone;...
View Replies !
MySQL Dont Show Older Than Today
I'm making a database for upcoming shows. so, what I wonder now, is there a way to show only upcoming shows, and just exclude the shows older than todays date? what I've got atm is: Code:
View Replies !
If Textbox Containes Default Value Dont Display
I have a form that the user fills out and submits the information gets stored in mysql. then a php file pulls information from mysql and displays it on a page. On the form theres a drop down box that is optional "Second Cass" the default value is Select One if the user doesnt select one then select one is stored in mysql which I dont care about that, but when the php file pulls the information and displays it if the information from that drop down is select one I dont want to display it if its any thing else it can display it. Code:
View Replies !
DELETE RECORDS - Database Adding New Records
iv got the database adding new records, and now I want it to display all of the records that are there buy name and id number, then i want u to be able to type in the id number of the customer u wish to delete and it shoudl delete it, sounds good buts its not actually deleting the record. it says it does, but its not doing it. Code:
View Replies !
Problems With The Listing Of Records, Editing Of Records
I'm having problems with the listing of records, editing of records, and deleting of records. I'm not sure what I'm doing wrong. The listing script is calling the add entry script. So I add the record, the database is updated, and nothing else happens. I don't get a list of records from that table. When I did SQL programming off the mainframe, you did a simple select statement. I'm not sure why the PHP list script is calling the add entry script. Code:
View Replies !
Dont Want The File Names In The Browser Address Field
Is there a way in PHP where the file name do not appear in the browser address field. eg. the url of a file is : http://www.somedomain.com/somepage.php. but when a link to this page is clicked, only http://www.somedomain.com should show up in the browser address field.
View Replies !
For Gurus: Bug In Php? Recursive Foreach Dont Work Properly.
Looks like there is a bug in php. If I have function which uses foreach to run trough array recursively, the lop-level foreach interupted by lover-level foreach'es. If I use simply 'for' everything is ok. Example: I have an array of 3 objects connected hierarchically by their variables id and parentId, here is the hierarchy: id=1 parentId=0 ....id=2 parentId=1 ....id=3 parentId=1 I start digging from item with id=1 down to its chils and top-level foreach NEVER REACH ELEMENT 3!!! Top-level foreach just stops. <?php function prn($s){ echo($s.'<br>'); } $nodes = array(); $nodes[0] = new node(1, 0); $nodes[1] = new node(2, 1); $nodes[2] = new node(3, 1); $nodes[3] = new node(4, 0); classnode{ var $id; var $parentId; function node($id, $parentId){ $this->id = $id; $this->parentId = $parentId; } function dig($level){ global $nodes; $l = '' for($i=0; $i<$level; $i++) $l.='..' prn($l.'looking for childs of '.$this->id.' {'); foreach($nodes as $n){ prn($l.$n->id.' (parent '.$n->parentId.')'); if($n->parentId == $this->id){ $n->dig($level+1); } } prn($l.'}'); } } $nodes[0]->dig(0); ?> The output should look like this: looking for childs of 1 { 1 (parent 0) 2 (parent 1) ...looking for childs of 2 { ...1 (parent 0) ...2 (parent 1) ...3 (parent 1) ...} 3 (parent 1) ...looking for childs of 3 { ...1 (parent 0) ...2 (parent 1) ...3 (parent 1) ...} } But it looks like this: looking for childs of 1 { 1 (parent 0) 2 (parent 1) ...looking for childs of 2 { ...1 (parent 0) ...2 (parent 1) ...3 (parent 1) ...} }
View Replies !
Php Java Bridge Dont Work With Windows Xp And Apache 2.0.5
I have the java bridge library working fine on a windows 2000 and running apache 1.3 but cannot for whatever reason get it to work on windows xp and apache 2.0.5 Ive included the following in php.ini: [java] java.class.path = "c:PHPextJavaBridge.jar;" java.home = "c:SunAppServerjdkin" java.library.path = "c:PHPext" Ive installed j2ee 1.4 and jdk 5. I have installed the latest pecl package. The JavaBridge.jar and php_java.dll is in ext folder. I look in the apache error log file and always see this error: Unable to load dynamic library 'c:/php/extphp_java.dll' - The specified procedure could not be found. in Unknown on line 0 What is going on?
View Replies !
Contact Form Not Working - Dont Recive Any Emails
I have a contact form on my site, which when the user fills out all the forms it takes them to the thank you page, and if they dont fill it out proprely it tells them, so this is all fine except i dont recive any emails, lol could this be becasue i cant do it from my own computer? Code:
View Replies !
I Dont Want To Include Blank Form Fields When Emailed
I have at least 45 fields in my form and only 8 of them are required namely, NAME, GENDER, DATE OF BIRTH, AGE, HEIGHT, WEIGHT, EMAIL AND CONTACT NO. The rest is optional. The problem is, I dont want to include the blank fields which have not been filled up when the SUBMIT button is clicked. I just want the fields which has been filled up to appear in the mail recipient. I understand that I have to use an array, foreach and the if statement, but i don't have any idea how to implement it.
View Replies !
Function Inside A Class Function Dont Pass Variables...
Im using xajax class, and i just made a custom class called mantenimientos that use objects of this xajax class. Something like this: class mantenimiento { public $titulo; public $ajax_sRequestURL; function __construct($titulo,$ajax_url){ $this->titulo = $titulo; $this->ajax_sRequestURL = $ajax_url; } function exec_ajax(){ //Here i can use $this with no problem $xajax = new xajax($this->ajax_sRequestURL); $xajax->registerFunction("call_fun"); //I have to do this to have acces to the class itself when im inside a function global $mant ; $mant = $this; function call_fun(){ //next line give me access to the mantenimiento class properties. //I havent found other way of doing it. global $mant; $objResponse = new xajaxResponse(); $objResponse->addAlert('XAJAX CALLED:'.$mant->titulo); return $objResponse->getXML(); } $xajax->processRequests(); } My problem is that $mant->titulo lost it value when i im inside the funciton, but only when that value comes from other var. for example: if i do this: $mant = new mantenimiento('This is the title','index.php'); or $titulo = 'This is the title' $mant = new mantenimiento($titulo,'index.php'); When i execute the xajax_call_fun, it shows an alert box with the text "XAJAX CALLED:This is the title" but if i do something like this: $titulo = gettitulo_from_database(); or $titulo = $_POST['titulo']; The alert box show the mensaje with out the value of the $mant->titulo Im getting crazy with this....!
View Replies !
Open On Open / Save Box Dont Work With Download Script
I have a download script. I'm storing files above webroot and using download script for making files available for download to users. Now the problem is that when file download open/save dialogue box comes... if the user clicks on save they can save the file and then they can open it without any problem . But if they click on open then they can't open the file. It says file path not found or there was some error file could not be open.....
View Replies !
PDF Mix & Match
I was wondering if anyone had any experience of splitting & appending PDF's? A client has a huge pdf, and he wants to give the user the ability to mix and match the chapters that they want to download. The final final will be 1 pdf, but may consist of various different chapters chosen from a list. The chapters will be ripped from 1 master pdf. Oh, and the PDF is not just text it contains all manner of images,links & the like! And that is what is required. I was wondering if anyone had any pointers regarding this? I'm thinking PDFLib, but I haven't fully looked into it yet.
View Replies !
Match Only Three
I have this code: $numbers = array("04","13","18","21","30","46","(05)"); foreach($data as $key => $value) { if($data[$key][5] == $numbers[0] && $data[$key][6] == $numbers[1] && $data[$key][7] == $numbers[2] && $data[$key][8] == $numbers[3] && $data[$key][9] == $numbers[4] && $data[$key][10] == $numbers[5] && $data[$key][11] == $numbers[6] )//did they win the jackpot? { echo "You have Won!<br /><br />"; } else { echo "You did not win this time :(<br /><br />"; } } The above code will check the $data[$key] array and match the values against the values in the $number array. That is fine. However what if I wanted to see if only 3 values in the $numbers array matched the numbers in the $data[$key] array. How would I do that?
View Replies !
Where Match () Against ()
i would like to change the following line WHERE MATCH (artists.artist) AGAINST ('$id') to WHERE DOESN'T MATCH (artists.artist) AGAINST ('$id') ie i would like to show all results where $id does not occure.
View Replies !
|