Jump to content

advancedfuture

Members
  • Posts

    132
  • Joined

  • Last visited

    Never

Everything posted by advancedfuture

  1. So Im building this little link scraper. The problem I am having is when it outputs the links that are in the array its got duplicate elements. I'm trying to erase the dupes and only show unique values. I've tryed array_unique() with out success as well as in_array(). Any help would be appreciated! //PAGE WE ARE GETTING LINKS ON $diags = str_get_html(getDiagramLinks($html)); //GET THE DIAGRAM LINKS TO PAGES INTO ARRAY foreach($diags->find('a') as $f) { $diagLinks[] = $f->href; } //iterate through the array for($i=0; $i<sizeof($diagLinks); $i++) { //ignore if blank element if(trim($diagLinks[$i]) !== ' ') { echo $diagLinks[$i]. '<br>'; } } The Output: /partsearch/model.aspx?diagram_id=110375 /partsearch/model.aspx?diagram_id=110375 /partsearch/model.aspx?diagram_id=110376 /partsearch/model.aspx?diagram_id=110376 /partsearch/model.aspx?diagram_id=110377 /partsearch/model.aspx?diagram_id=110377 /partsearch/model.aspx?diagram_id=110378 /partsearch/model.aspx?diagram_id=110378 /partsearch/model.aspx?diagram_id=110379 /partsearch/model.aspx?diagram_id=110379 /partsearch/model.aspx?diagram_id=110380 /partsearch/model.aspx?diagram_id=110380
  2. Happy Holidays Fellow PHPFreaks! I wanted to know how can I combine these two queries, if possible at all. $query = "UPDATE users SET active='n' WHERE username='$payer_email'"; mysql_query($query); $query = "DELETE FROM services WHERE username='$payer_email'"; mysql_query($query);
  3. So I have gzip running to compress my css files, the problem i am running into is when the page loads, the css must not fully decompress because the page renders half the page without the CSS and the other half fine. I'm not sure what I do in this scenario. Any thoughts?
  4. I am trying to limit how many dbconnections I run. How can I combine these two mysql statements into one query.. if possible. //If the user cancels their subscription, deactivate their account and delete their advertisement. if($txn_type == "subscr_cancel") { $query = "UPDATE users SET active='n' WHERE username='$payer_email'"; mysql_query($query); $query = "DELETE FROM advertisements WHERE username='$payer_email'"; mysql_query($query); }
  5. Yeah I have a c++ / PHP background, the syntax is pretty similair. I am not strong on JavaScript, but with the project I have been working on I think I'm going to need to learn it. Thanks for the advice guys
  6. I am stuck scratching my head over this problem. Here is my situation. I have 3 dropdown boxed. Box 1 = States Box 2 = Counties Box 3 = Cities What I am trying to accomplish is when the user selects their state, mysql will return the counties in that state in box 2, then when a county is selected box 3 will populate with all the cities in the county. Problem is PHP is all server side, so by the time the page loads it is done, how do I go about this problem? Just need idea's.
  7. I could i suppose load the image into my db as blob data and have the img code request a dynamic URL, but I think there is probably easier way right?
  8. So we do a lot of craigslist marketing, and as you know craigslist does not allow javascript or anything else. I am programming a hit counter that will tell me how many times a page was viewed through a tracking pixel. I can make the counter thats no issue, the problem is I don't know how to go about finding out if the pixel was loaded. I know it is possible, I run a statistical tracker called tracktool, and whenever I do an image based ad (with the image hosted on the server) every page craigslist imageload gets recorded as a hit. (normal traffic is 40uvs a day without any ads) run an image ad traffic spikes to 500-600uvs, these have no links back to the site, so they arent visiting the site it is deff image impressions
  9. Thanks Susa.. Works flawlessly now... Sometimes I forget some of the simple mysql functions. =]
  10. So here is my delimma. I setup wildcard subdomains on my server. My subdomain format is county.state.mydomain.com I'm matching the subdomains against my database, to ensure it is a valid combo, if it isn't it should redirect to the main page 'www'. Problem is my if statement is not working as it should... if I enter lets say... ilovebats.ca.mydomain.com it runs the query no problem, but doesn't execute the header statement in my IF statement... which leads me to beleive i malformed the if statement. Any help would be appreciated. <?php //Get what subdomain we are on. strip the county and state variables //from the URL, and if it is www, set it to Orange County, CA include 'dbconnect.php'; $domain = explode('.',str_replace("mydomain.com"," ",$_SERVER['SERVER_NAME'])); $county = $domain[0]; $state = $domain[1]; //This variable is used for displaying the county without the slashes $county_slash = str_replace("-"," ",$county); //If we are on the root of the domain, set the variables to Orange County, CA if ($county == "www") { $county = "Orange"; $state = "CA"; } //Check to make sure subdomain is valid. If not redirect to www else { $query = "SELECT * FROM `zip_code` WHERE county='$county' AND state_prefix='$state'"; $results = mysql_query($query); if($results == 0) { header('LOCATION: http://www.mydomain.com'); exit; } } ?>
  11. I want to grab the subdomain name with PHP so I can generate database queries. for example my subdomain is san-jose.mydomain.com How would I go about grabbing the subdoman name with PHP? Thanks!
  12. Trying to echo a HTML tag that has variables in it. Kinda beating my head on the wall with this one unfortunately. How to I echo the anchor text with the ' and " in it. $output = $row['services_address'] . $row['services_address_2'] . $row['services_city'] . $row['services_state']; echo '<a href ="maps.php?address='.$output.'" onClick="window.open('maps.php?address='.$output.'','Page Name','height=500,width=500,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');">View Map</a>';
  13. Okay here is the situation. I have a database with 2 tables, advertisements and users. I want to select all usernames from advertisements table that are advertising in a specific zipcode. It checks the users table to make sure they have the available column set to 0 and the vendor_status colum set to 1. It should then return all usernames with ads running! But I am having problems with my query. Currently what it is doing is printing out the username from BOTH the users table, and the advertisements table! The tables look as follows Table Advertisements: username | advertisement_title | zip_code Table Users: username | available | vendor_status The query I am trying to get to work is as follows. SELECT advertisements.username FROM advertisements, users WHERE users.available='0' AND users.vendor_status='1' AND advertisements.zip_code='95119'
  14. So I having a problem on one of my pages. The page displays all related advertisements. However when I select the ad I want to delete and press the form button it just refreshes the page without deleting it! Anyone able to see what the problem is in my code? Much thanks! <?php //*********************************** //*********************************** // SHOW THE USER ADS. // //*********************************** //*********************************** //GET THE USERS ADS FROM THE DATABASE $query = "SELECT * FROM advertisements WHERE username = '$username'"; $results = mysql_query($query); $num = mysql_num_rows($results); echo '<form id="form1" name="form1" method="post" action="profile.php">'; echo '<table align="left" width="95%" border="0">'; if($num == 0) { echo "<center><strong>Sorry! You have no advertisements</strong></center>"; } else { //ECHO HEADING FOR ADS TABLE echo '<tr><td bgcolor="#0066FF"><input type="checkbox" id="all" name="all" value=""></td>'; echo '<td bgcolor="#0066FF"><strong>Title:</strong></td>'; echo '<td bgcolor="#0066FF"><strong>Tagline:</strong></td>'; echo '<td bgcolor="#0066FF"><strong>City:</strong></td>'; echo '<td bgcolor="#0066FF"><strong>Phone:</strong></td>'; echo '<td bgcolor="#0066FF"><strong>Service:</strong></td>'; echo '<td bgcolor="#0066FF"><strong>Zip:</strong></td></tr>'; //BEGIN LOOP TO OUTPUT ADS FOR USER while($rec=mysql_fetch_array($results)) { $adid = $rec['adid']; $advertisement_title = $rec['advertisement_title']; $advertisement_tagline = $rec['advertisement_tagline']; $advertisement_city = $rec['advertisement_city']; $advertisement_phone = $rec['advertisement_phone']; $advertisement_service = $rec['advertisement_service']; $zip_code = $rec['zip_code']; echo '<tr><td><input type="checkbox" id="'.$adid.'" name="'.$adid.'" value="'.$adid.'"></td>'; echo '<td>'.$advertisement_title.'</td>'; echo '<td>'.$advertisement_tagline.'</td>'; echo '<td>'.$advertisement_city.'</td>'; echo '<td>'.$advertisement_phone.'</td>'; echo '<td>'.$advertisement_service.'</td>'; echo '<td>'.$zip_code.'</td></tr>'; } echo '</table>'; echo '<input type="submit" name="delete" id="delete" value="Delete Checked" />'; echo '</form>'; //IF THE USER DELETES ADS CYCLE THROUGH ALL THE CHECKBOXES if($_POST['delete']) { foreach($_POST as $adid) { $query = "DELETE FROM advertisements WHERE adid='$adid' LIMIT 1"; $results = mysql_query($query) or die(mysql_error()); } //REFRESH THE USERS ADS LIST if($results) { echo '<meta http-equiv="refresh" content="0"/>'; } } } mysql_close(); ?>
  15. I have a textfield that I want to submit the data into an array The user would enter data such as 92444,1223,12344,2322 all seperated by commas. How would I got about putting $_POST['value'] into an array. I've tried $var = array($_POST['value']) but that doesnt seem to work.
  16. I am trying to execute some PHP code, I've done this before on my godaddy hosting account, but for some reason the code isn't working now that I ported it over to my private server. It WORKS if i put the PHP on a seperate page and send the info through action=... but the if statement is not working if i try to execute the code on the same page ): Here's the stripped down version of the code.... <form name="signup" id="signup" method="post" action=""> <div align="center"> First Name: <input type="text" name="first_name" id="first_name" /> <input type="submit" id="dosubmit" name="dosubmit" value="Sign Up!" /> </div> </form> <?php if(isset($_POST['dosubmit'])) { echo "CHEESE!"; } ?> am I doing something wrong? The code just isnt executing...
  17. I set it up, it is on my dedicated server. However I no longer use cPanel. Can i just rename upcp to keep it from running?
  18. The past couple of days I have been trying to figure out why mysql keeps losing the root password randomly and bringing all my websites down. Then I figured it out! I was SSHd into my server and saw a broadcast message "cPanel Layer 2 Update Complete" Then immediately afterwards I noticed all my sites were down giving "MySql Query Error", so I logged into mysql and reset my password and all sites came back up.. How can I stop this from happening? It is happening daily. It got so bad that my main site's homepage got crawled while it was down and indexed as "mysql query error" and my traffic went from 150 uniques a day to almost zero!
  19. okay I figured out somehow the database password was erased. I dont know HOW this happened. I think I might have been hacked. Any idea's on how I can see what happened?
  20. My site has been running for about 3 months now on my dedicated server. There has been no issue's whatsoever. All of the sudden about an hour ago it went down. As you can see at http://www.dial1auto.com I have made NO CHANGES at all to the database, or to the sites files. It just stopped working. I logged into the server, and the database is still there and everything. I don't know what to do I am rather lost.
  21. So I created a sitemap and submitted it to google, problem is I messed up on one of the variables. Instead of it saying services= it said service= so the pages all got indexed but its all messed up. I am trying to 301 mod rewrite the messed up URLs to the correct ones. I have written it like so RewriteRule ^services.php?st=(.*)&city=(.*)&service=(.*)$ services.php?st=$1&city=$2&services=$3 [R=301,L] However it is not redirecting! Am I doing something wrong?
  22. thank you for your input =) I think I will be well on my way to getting this done now. I <3 this community
  23. I was thinkin it would look something like this maybe... sorry real code mixed in with sudo code. $query = "SELECT * FROM vendors WHERE available='0'; $results = mysql_query($query) or die (mysql_error()); $num_rows = mysql_num_rows($results); if($num_rows > 0) { $counter = 0; //counter to spread out leads only 2x while($row = mysql_fetch_array($results)) { if($counter != 3) { //insert lead into column } } $counter++ } else { //mysql query reset available bits to 0; $counter = 0; //counter to spread out leads only 2x while($row = mysql_fetch_array($results)) { if($counter != 3) { //insert lead into column } } $counter++ }
  24. I was thinking I could set a column under the vendor name and with a default value of 0, and if they get a lead it sets the value to 1, and as leads come it it sends the lead to the next to vendors that have it set to zero... and if all vendors have the value set to 1, it will reset the value to 0 again. Would that work?
  25. yeah i could do that so it would only spread out the leads 2x, but im still kinda lost on how I would get it to say, okay these 2 got leads last time, now its time to give leads to this vendor
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.