Jump to content

drewdan

Members
  • Posts

    47
  • Joined

  • Last visited

Everything posted by drewdan

  1. Yes sorry, my idea is based purely on postal areas, if wont give you the closest person to you, it will just provide results in that postal area, in a sense imitating the functionality of closest too. The problem is, if there is no one in that postal area it will return nothing instead of searching the next postal area. You would need to provide further information, co-ordinates and the lark and a way of searching co-ordinates within a radius of 10 miles etc. Sounds like a big job!
  2. Upload the image to the filesystem and then insert the file name into the DB like you would an ecommerce store? That way you can qiery the database for your image and get the correct filename for it to call it. Or use the glob() function to return an array with all of the files in said directory, your images directory for example. How are you planning on displaying the image? P.S. Welcome to the Forum!
  3. You could do it by postal area. So for example, if I enter "NP10 0AS", you query could search for people within "NP10", or even wider to "NP"
  4. Well, I cannot argue with that! I withdraw all my previous statements about w3schools etc. Stick to PHP Freaks!
  5. Are they not the same people then? I have been living a lie! Its not fantastic, but can be a good point to start off.
  6. You're quite right, that would only if those 4 fields were all that were in the database, though, I imagine there would be some more. Can you show us your code you are using to connect to the database? (with users pass etc ommited). $conn = mysqli_connect("localhost","username","password") or die(mysqli_error($conn)); mysqli_select_db($conn, "databasename") or die(mysqli_error($conn)); $sql = "INSERT INTO `donation` (`username`, `time`, `productid`, `price`) VALUES ('" . $user . "', '" . $date . "', '" . $prodid . "', '" . $amount . "')"; $sql_res=mysqli_query($conn, $sql) or die(mysqli_error($conn)); That would be my prefered way of connecting too and running a query on a mysql database. I assume that your database connection would be in here: include("db.php"); Is this file including correctly?
  7. W3C has php tutorials as well as tutorials for other languages. Can be useful to check various php functions
  8. are you getting any error message? how are you testing the API?
  9. Thanks for the information. I am currently building a CMS which will be perfect for businesses and rather affordable. It will be licensed software instead of sold which will mean people wont ever see the code behind it. I am trying to make it self sufficent so it does not require other services like GA, it also has a module library which allows users to search through a library of addon features, (image gallery, newsletter subscriptions etc) and then install them with just one click. I am trying to avoid open source (although it does use some now, but that will be replaced soon) so I am building these things from scratch. It will mean businsses can manage their website instead of having to pay a programmer to do it, which most small businesses are afraid of, or cannot afford to do. It is supposed to make Joomla and other such open source solutions look like an amateur attempt, but it is years away from that for the moment.
  10. mysql_query requires to variables if I am not mistaken. The string and the connection. I cannot see this here. mysql_query("INSERT INTO `donation` (`username`, `time`, `productid`, `price`) VALUES ('" . $user . "', '" . $date . "', '" . $prodid . "', '" . $amount . "')") or die(mysql_error()); I would use mysqli_query and do it like this: $sql = "insert into donation values('$user', '$date', '$prodid', '$amount')"; $sql_res = mysqli_query($conn, $sql) or die(mysqli_error($conn)); The $conn variable would be your database connection. Seperating the sql string from the query helps me to see things better, it may be a little less efficent, but it helps me follow my code better. Hope this helps!
  11. Why not look on the W3C website and work through the things on there. Do you know any other languages? If you dont know any other programming languages it would be good to start learning the logic of programming, loops and the lark. I started learning PHP when someone asked me to make an ecommerce website. So I learnt how to do that first, creating sql queries and running them on a database and then returning the info in a table. Have fun with it!
  12. I have had a look at the data. It seems to mainly be page views, unique page views, repeat visitors. Which could be calculated by just collecting the IP address and Time and working that out. GA also seems to be able to work out which country the user is from. I was wondering if that was using the IP to work this out, or if it was data passed from the browser? Any ideas?
  13. Hello everyone, Merry Christmas! I am trying to make a system that allows me to track users of the website and create statistics similar to those found in Google Analytics. My question is what kind of data should I be collecting? I am currently collecting IP address, time, the name of the accessed page, the referer and the browser type. Any thoughts of any other data I should collect? Thanks guys!
  14. Hi all, Its resolved now. For anyone who is interested: if($_REQUEST['action']=="ajax2") { $sql="select * from vehicle_image where vehicle_id=".$_REQUEST["id"].""; $sql_res=mysqli_query($conn, $sql) or die(mysqli_error($conn)); echo ' <script> function changeImage(src) { $(\'#theimage\').attr("src", "../timthumb.php?src=images/"+src+"&w=400&h=400&zc=2\""); } </script>'; while($array=mysqli_fetch_array($sql_res)) { $src=$array['image_src']; $variable = "\"../timthumb.php?src=images/$src&w=66.6&h=66.6\""; $content .= "<img onclick=\"changeImage('$src')\" style=\"float:left;\" src=" . $variable . ">"; } echo $content; exit(); } Cheers!
  15. Right, new update, whats actually happening, or not happening in this case is: onclick=\"changeImage(" . $variable. ")\" When this gets to runtime, the changeImage() remains empty. The variable definately contains information as futher along it makes the image appear. Just doesnt wanna appear in the brackets!
  16. Thanks for your reply! There are not really any errors as such. There are no php errors which suggests my PHP is fine, yet firebug says there is a syntax error and nothing else with the contents of changeImage() which suggests I have created the string incorrectly using the PHP. Using var_dump($content) gave me this: string(624) "" Does that mean anything? I have been looking at this for so long now I dont really quite know what to do with it, my brain is trying to avoid thinking when I look at it! You can see the script in "action" here: http://commercial-motors.com.82-165-151-28.hostiauwebhost.co.uk/man-truck/30-man-sales-topused If you click More Info... for Test Vehicle 1 a div box should appear with the content. The $content variable is responsible for the little images in the bottom right and clicking on of them should change the large image to whatever the small image was. Does this make any sense? Or should I give up and start again! Thanks for your help!
  17. Hi Guys, I am currently writing some pretty messy code and I am having problems with it. I bascially have a script which will change the source of an image using jquery, but all of this is generated through a PHP file. So basically I have this being called using ajax: $sql="select * from vehicle_image where vehicle_id=".$_REQUEST["id"].""; $sql_res=mysqli_query($conn, $sql) or die(mysqli_error($conn)); while($array=mysqli_fetch_array($sql_res)) { $src=$array['image_src']; $variable = "\"../timthumb.php?src=images/" . $src. "&w=66.6&h=66.6\""; $content .= "<img onclick=\"changeImage(" . $variable. ")\" style=\"float:left;\" src=" . $variable . ">"; } echo $content; The line I am having the problems with is the $content .= line. specifically the onclick=" this bit here " part. However I write the code, however I escape the characters, it causes an error with different bits of the code, at the moment the problem with this is that is doesnt form the variable in the function properly. I am using FireBug to check that things are workly properly as when you use jQuery the source code does not update. Firebug says there is something wrong after changeImage( so I can only assume its my character escaping, but I really dont know. Any help on this would be great!
  18. Jessica is quite right, you are missing a closing }. If you indent your code, it will make it easier to see when you have opened a { and then closed it }. This is a common mistake for me when using if statements. Welcome to the Forum!
  19. Thanks for your help. I had put an underscore somewhere it shouldnt have been, so the variable it was trying to pass contained no data. Which is why my server wasnt being very happy! As soon as I built the XML up and found the only two variables were actually missing data and not all of them it became nice and simple. Brill!
  20. What languages have you worked with previously? What kind of experience do you have? I used to find it quite hard when I first started, but when I got my head around the syntax and learnt the structure ie loops, making functions etc it became much easier. Its difficult to jump into the deep end. But like Kicken said, keep that PHP manual handy, I have been programming in PHP for 2 years, and I still keep mine on my desk just in case! Best of luck, and welcome to the forum!
  21. You could assign a unix timestamp to all of the entries in the database, and then get your cron job to run every minute to see if any emails need to be sent, or you could use ajax and the setinterval function in javascript to run the sendmail script you have every 30 seconds, but you would have to update your database to know when someone has been sent an email or not and limit the sending to 4 emails. The other choice is, get a dedicated server you can find some pretty cheap servers these days!
  22. I was always quite fond of Sams Teach yourself PHP, MySQL and Apache, still have a copy for reference on my desk. It is good as it talks you through several small projects, like making a shopping cart or a forum. Its pretty simple but effective. You could always use the W3Schools website for reference. Its pretty handy too!
  23. Hi Guys, I am trying to write a script which will automate the creating of accounts for customers on a plesk server. I am having some difficulty though. This script will be used for when I get IPN from Paypal. For the moment, I am just running it to get it to work. It will search tables in a database to get the relevant information and then should create an xml file post it to my server with the relevant details which will create an account, however, when I am trying to create the xml file through the code, and I put the variables into the script, I get errors returned stating their is no data being passed through. Any advice anyone could provide would be very handy! Thanks Andrew <?php include("includes/conn.php"); //get todays date for the payment schedule database date_default_timezone_set(GMT); $n=gmdate("m"); $y= gmdate("Y"); $d=gmdate("d"); $time = mktime(0,0,0,$n,$d,$y); //get ID number of transaction so database can be updated $id="1"; //update the payment schedule and mark this transaction as paid $update_payment_schedule = "update paymentschedule set payment_paid='1' AND payment_paiddate = '$time' where payment_id='$id'"; $update_payment_schedule_res = mysqli_query($conn, $update_payment_schedule) or die(mysqli_error($conn)); //get the customer number from payment schedule $get_customer_number = "select * from paymentschedule where payment_id='$id'"; $get_customer_number_res = mysqli_query($conn, $get_customer_number) or die(mysqli_error($conn)); while($arCustomerNumber=mysqli_fetch_array($get_customer_number_res)) { $customer_number = $arCustomerNumber['customer_id']; } //update the hosting tables $update_hosting = "update hosting set hosting_accountstatus='3' where customer_id='$customer_number'"; $update_hosting_res = mysqli_query($conn, $update_hosting) or die(mysqli_error($conn)); //get_customer_details $get_customer_details = "select * from customer where customer_id='$customer_number'"; $get_customer_details_res = mysqli_query($conn, $get_customer_details) or die(mysqli_error($conn)); while($arCustomerDetails = mysqli_fetch_array($get_customer_details_res)) { $customerfirstname = $arCustomerDetails['customer_firstname']; $customerlastname = $arCustomerDetails['customer_lastname']; $customerfullname = $customer_firstname . " " . $customer_lastname; $customercompanyname = $arCustomerDetails['customer_companyname']; $customerfirstlineaddress = $arCustomerDetails['customer_firstlineaddress']; $customercity = $arCustomerDetails['customer_city']; $customercounty = $arCustomerDetails['customer_county']; $customerpostcode = $arCustomerDetails['customer_postcode']; $customerphone = $arCustomerDetails['customer_phone']; $customeremailaddress = $arCustomerDetails['customer_emailaddress']; } function generatePassword($length=9, $strength=0) { $vowels = 'aeuy'; $consonants = 'bdghjmnpqrstvz'; if ($strength & 1) { $consonants .= 'BDGHJLMNPQRSTVWXZ'; } if ($strength & 2) { $vowels .= "AEUY"; } if ($strength & 4) { $consonants .= '23456789'; } if ($strength & { $consonants .= '@#$%'; } $password = ''; $alt = time() % 2; for ($i = 0; $i < $length; $i++) { if ($alt == 1) { $password .= $consonants[(rand() % strlen($consonants))]; $alt = 0; } else { $password .= $vowels[(rand() % strlen($vowels))]; $alt = 1; } } return $password; } $panel_password = generatePassword(9,4); //--------------------------------------------------------------------------------------------- //script to add new client to the server //--------------------------------------------------------------------------------------------- function addClient() { $xmldoc = new DomDocument('1.0', 'UTF-8'); $xmldoc->formatOutput = true; // <packet> $packet = $xmldoc->createElement('packet'); $packet->setAttribute('version', '1.6.3.0'); $xmldoc->appendChild($packet); // <packet/domain> $client = $xmldoc->createElement('customer'); $packet->appendChild($client); // <packet/domain/get> $add = $xmldoc->createElement('add'); $client->appendChild($add); // <packet/domain/get/filter> $geninfo = $xmldoc->createElement('gen_info'); $add->appendChild($geninfo); $geninfo->appendChild($xmldoc->createElement('cname', $customercompanyname)); $geninfo->appendChild($xmldoc->createElement('pname', $customerfullname)); $geninfo->appendChild($xmldoc->createElement('login', $customeremailaddress)); $geninfo->appendChild($xmldoc->createElement('passwd', $panel_password)); $geninfo->appendChild($xmldoc->createElement('status', '0')); $geninfo->appendChild($xmldoc->createElement('address', $customerfirstlineaddress)); $geninfo->appendChild($xmldoc->createElement('city', $customercity)); $geninfo->appendChild($xmldoc->createElement('pcode', $customerpostcode)); $geninfo->appendChild($xmldoc->createElement('country', 'GB')); return $xmldoc; } //--------------------------------------------------------------------------------------------------------------------------------------- //end of add new client script //-------------------------------------------------------------------------------------------------------------------------------------- function curlInit($host, $login, $password) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "https://{$host}:8443/enterprise/control/agent.php"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, false); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_HTTPHEADER, array("HTTP_AUTH_LOGIN: {$login}", "HTTP_AUTH_PASSWD: {$password}", "HTTP_PRETTY_PRINT: TRUE", "Content-Type: text/xml") ); return $curl; } function sendRequest($curl, $packet) { curl_setopt($curl, CURLOPT_POSTFIELDS, $packet); $result = curl_exec($curl); if (curl_errno($curl)) { $errmsg = curl_error($curl); $errcode = curl_errno($curl); curl_close($curl); throw new ApiRequestException($errmsg, $errcode); } curl_close($curl); return $result; } function parseResponse($response_string) { $xml = new SimpleXMLElement($response_string); if (!is_a($xml, 'SimpleXMLElement')) throw new ApiRequestException("Cannot parse server response: {$response_string}"); return $xml; } function checkResponse(SimpleXMLElement $response) { $resultNode = $response->domain->get->result; // check if request was successful if ('error' == (string)$resultNode->status) throw new ApiRequestException("The Panel API returned an error: " . (string)$resultNode->result->errtext); } $host = '*****'; $login = '*****'; $password = '******'; $curl = curlInit($host, $login, $password); try { $response = sendRequest($curl, addClient()->saveXML()); $responseXml = parseResponse($response); checkResponse($responseXml); } catch (ApiRequestException $e) { echo $e; die(); } // Explore the result foreach ($responseXml->xpath('/packet/client/add/result') as $resultNode) { $server_customer_id = (string)$resultNode->id; } $insert_into_domain = "insert into domains values('', '$domainname', '$server_customer_id', 'vrt_host', '82.165.151.28', '$customeremailaddress', '$panelpassword')"; $insert_into_domain_res = mysqli_query($conn, $insert_into_domain) or die(mysqli_error($conn)); ?> Thanks in advance for your help!
  24. Hello Everyone! My name is Andrew and I am the Managing Director of a web design and hosting company called Hostiau. I am something of an amateur developer who is looking to develop his skills by using them on a daily basis. In addition, I want to help new programmers who are taking the same journey as me! So hello all!
×
×
  • 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.