Jump to content

kevinkhan

Members
  • Posts

    142
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

kevinkhan's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. i have alot of numbers with 10 digits like this 0987654321 I want a sql query that will remove the 0 and add 353. Is there any body that can help me with this please?
  2. Does anyone know any good tutorials or examples on using cookies to store session ids. i want to store username and password in a session and want to store the session id in a cookie and when a user comes back to the site i want the website to remember the session. At the moment i am only using sessions and when i close the browser i have to re enter my user name and password to gain access to the site. Any ideas on how to do this?
  3. I have an array like this Array ( [0] => Array ( [id] => 139 [name] => Eithne Maun [contactNo] => 877692398 [email] => eithne@yahoo.co.uk [address] => [county] => Cork [country] => Ireland [sourceOfContact] => Phone [type] => Corporate [dateAdded] => 2012-11-26 [companyName] => [dateOfBirth] => ) ) I want to loop through each element in the array and only display the lines below if the value is not blank Number: <?php htmlout($contact[0]['contactNo']);?><br /> Email: <?php htmlout($contact[0]['email']);?><br /> Address: <?php htmlout($contact[0]['address']);?><br /> County: <?php htmlout($contact[0]['county']);?><br /> Country: <?php htmlout($contact[0]['country']);?><br /> Type of Contact: <?php htmlout($contact[0]['type']);?><br /> Company Name: <?php htmlout($contact[0]['companyName']);?><br /> Date of Birth: <?php htmlout($contact[0]['dateOfBirth']);?><br /> Is there a function with a loop that i could use??
  4. Im just wondering if anyone can help me out. Iv been trying to figure this out all day. I have these variables $booking['occasion'] $booking['date'] $booking['venue'] and I want to make a description out of them like this. $description = "Deposit for supplying a DJ for an $occasion on the $date in the $venue"; I want to display the description over 3 or 4 lines in a pdf file like this $pdf->writeHTMLCell(139, 5, '20', '125', $line1, '', 1, 1, true, 'L', true); $pdf->writeHTMLCell(139, 5, '25', '125', $line2, '', 1, 1, true, 'L', true); $pdf->writeHTMLCell(139, 5, '30', '125', $line3, '', 1, 1, true, 'L', true); $pdf->writeHTMLCell(139, 5, '35', '125', $line4, '', 1, 1, true, 'L', true); $pdf->writeHTMLCell(139, 5, '40', '125', $line5, '', 1, 1, true, 'L', true); I want to wrap the description to a next line after every 68 characters but only want to wrap after completed words Can anyone help me create a function to split the desicprtion into 3 or 4 lines so far I have this code which I know is along the lines that I want. $description = "Deposit for suppling a DJ and Equipment for a $occasion on the $date in $venue"; $decriptionLength = strlen($description); if($decriptionLength <= 68){ $line1 = $description; } elseif($decriptionLength > 68) { $line1 = substr($description, 0, 68); $line2 = substr($description, 68, 136); } This code will wrap the text even in the middle of a word so I don’t want this. I know this might be a lot to ask but if anyone can come up with some code I would be greatly appreciated.
  5. I have this code curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_URL, $link); $wall = curl_exec($ch); but the $link is a facebook wall page that takes a couple of seconds to load fully. and you have to scroll down the page before more loads or you have to click older posts when i run the script the $wall doesnt have the full page. Is there a way that i can delay the $link from saving the file so that it reads more of the page??
  6. The above code doesnt seem to work. The first array $_names is created from names in a textarea box and the $imageArray is created from the names of all images in an images folder here is my complete code which might be more helpful. <?php include_once $_SERVER['DOCUMENT_ROOT'] . '/facebook/photoApp/security/includes/helpers.inc.php'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Results</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <body> <table border="1"> <tr> <?php foreach ($names as $name): ?><th><?php htmlout($name); ?></th><?php endforeach; ?> </tr> <tr> <td><img src="../images/corkpartydjs@gmail.com/Aidan_Lambert_1.jpg" width="204"/></td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td><img src="../images/corkpartydjs@gmail.com/Aidan_Lambert_2.jpg" width="204"/></td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td><img src="../images/corkpartydjs@gmail.com/Aidan_Lambert_3.jpg" width="204"/></td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td><img src="../images/corkpartydjs@gmail.com/Aidan_Lambert_4.jpg" width="204"/></td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> </table> <p><a href="?">New search</a></p> </body> </html> and here is the processing file <?php include_once $_SERVER['DOCUMENT_ROOT'] .'/facebook/photoApp/security/includes/functions.inc.php'; if (isset($_GET['action']) and $_GET['action'] == 'search') { $user = $_GET['user']; $names = $_GET['names']; $names = nl2br($names); //red($names); $names = str_replace ( '<br />' , "\t" , $names ); $_names = str_replace( " " , "_" , $names); //blue($_names); $_names = explode("\t",$_names); $names = explode("\t",$names); // print_r($_names); echo "<pre>"; print_r($_names); echo "</pre>"; if ($handle = opendir($_SERVER['DOCUMENT_ROOT'] .'/facebook/photoApp/images/'.$user)) { // echo "Directory handle: $handle\n"; //echo "Entries:\n"; /* This is the correct way to loop over the directory. */ $imageArray = array(); while (false !== ($entry = readdir($handle))) { array_push($imageArray, $entry); } } sort($imageArray); echo "<pre>"; //print_r($imageArray); echo "</pre>"; foreach($_names as $value) { $parts = explode('_',$value); blue(count($parts)); $numberOfParts = count($parts); $last_name = $parts[$numberOfParts-1]; blue($last_name); foreach($imageArray as $matching_value) { if(strpos($last_name,$matching_value)) { echo $matching_value; } } } include $_SERVER['DOCUMENT_ROOT'] . '/facebook/photoApp/security/results.html.php'; exit(); } // Display search form include $_SERVER['DOCUMENT_ROOT'] . '/facebook/photoApp/security/includes/db.inc.php'; $result = mysqli_query($link, 'SELECT email FROM facebook_user'); if (!$result) { $error = 'Error fetching facebook users from database!'; include 'error.html.php'; exit(); } while ($row = mysqli_fetch_array($result)) { $users[] = array('email' => $row['email']); } include 'searchform.html.php'; ?> Thanks for your help guys
  7. i have an array called $imageArray like this Array ( [0] => 'Dashka'_Darren_Sheehan_1.jpg [1] => 'Dashka'_Darren_Sheehan_10.jpg [2] => 'Dashka'_Darren_Sheehan_2.jpg [3] => 'Dashka'_Darren_Sheehan_3.jpg [4] => 'Dashka'_Darren_Sheehan_4.jpg [5] => 'Dashka'_Darren_Sheehan_5.jpg [6] => 'Dashka'_Darren_Sheehan_6.jpg [7] => 'Dashka'_Darren_Sheehan_7.jpg [8] => 'Dashka'_Darren_Sheehan_8.jpg [9] => 'Dashka'_Darren_Sheehan_9.jpg [10] => . [11] => .. [12] => Aaron_Kidney_1.jpg [13] => Aaron_Kidney_10.jpg [14] => Aaron_Kidney_11.jpg [15] => Aaron_Kidney_12.jpg [16] => Aaron_Kidney_13.jpg [17] => Aaron_Kidney_14.jpg [18] => Aaron_Kidney_15.jpg [19] => Aaron_Kidney_16.jpg [20] => Aaron_Kidney_17.jpg [21] => Aaron_Kidney_18.jpg and i also have another array called $_names Array ( [0] => 'Dashka'_Darren_Sheehan [1] => Beefit_Gyms [2] => Aaron_Kidney [3] => Dean_Mitchell [4] => Colin_O_Neill [5] => Keith_McManus ) if a name in array $_names exists in the $imageArray i want to insert the images for that person into one column of a table like this <tr> <?php foreach ($names as $name): ?><th><?php htmlout($name); ?></th><?php endforeach; ?> </tr> <tr> <td><img src="../images/'Dashka'_Darren_Sheehan_1.jpg" width="204"/></td> <td><img src="../images/Aaron_Kidney_1.jpg" width="204"/></td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td><img src="../images/'Dashka'_Darren_Sheehan_2.jpg" width="204"/></td> <td><img src="../images/Aaron_Kidney_2.jpg" width="204"/></td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> can anyone help me write the logic for this?? I cant figure it out...
  8. I want to extract the name within the anchor tag of the following code takin from a source file. Has worked at <a href="http://www.facebook.com/pages/Bridewell-bar/110926698934250" data-hovercard="/ajax/hovercard/page.php?id=110926698934250">Bridewell bar</a> is there anyway i can remove all the code before "Has worked at" and use the code below to extract the name $page is full source code of page include('simple_html_dom.php'); code to remove every thing before "Has worked at" $job = str_get_html($page); $job = $jobd->find(' next <a> tag',0); $job = $job->value; Any ideas and can somebody help me write the code. iv tryed using strpos function but can figure it out
  9. when i insert this code into my php script my cron job wont work include($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'facebook' . DIRECTORY_SEPARATOR . 'globalFunctions.php'); it is giving this error Warning: include(/facebook/globalFunctions.php) [function.include]: failed to open stream: No such file or directory in /home/cork/public_html/facebook/fbFriendAdder/all/addFrndOfFrnd.php on line 13 Warning: include() [function.include]: Failed opening '/facebook/globalFunctions.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cork/public_html/facebook/fbFriendAdder/all/addFrndOfFrnd.php on line 13 what is causing this problem and why does it work fine when i run the script manually??
  10. ok iv set up a simple demo this is the code im running include('simple_html_dom.php'); include('config.php'); include('connect.php'); include('functions.php'); include($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'globalFunctions.php'); test(); echo "test variable = ".$test; exit; this is the function which is in globalFunctions.php which is two directories back ../../ function test() { $test = 10; global $test; } how come when i run script i am not getting variable echoed
  11. No none of the above suggestions worked
  12. i am running a file in the following folder on my hosting server /httpdocs/folder1/folder2/script.pjp how do i include a file that is located at the root of the hosting server /httpdocs/globalFunctions.php iv tried $maindir = dirname(__FILE__) . DIRECTORY_SEPARATOR; require $maindir . DIRECTORY_SEPARATOR . "globalFunctions.php"; include('http://www.domainname.com/globalFunctions.php'); and include('../../globalFunctions.php'); but none of these work any ideas
  13. im testing the following script and it wont send 1 2 3 until the script has finished executing. What can i do to flush the buffer after every echo statement?? <?php echo "1"; ob_flush();flush(); sleep(5); echo "2"; ob_flush();flush(); sleep(5); echo "3"; ob_flush();flush(); ?>
  14. I am getting the following error when i run the bellow script Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /usr/local/pem/vhosts/100175/webspace/httpdocs/corkdesigns.ie/facebook/wall/testing.php on line 46 fetching.. Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /usr/local/pem/vhosts/100175/webspace/httpdocs/corkdesigns.ie/facebook/wall/testing.php on line 23 define("COOKIE_FILE", "cookies.txt"); $email = 'xxxxxxxx'; $pass= 'xxxxxxxxx'; if(file_exists(COOKIE_FILE)) { unlink(COOKIE_FILE); } $qryString = 'charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&locale=en_US&email='.urlencode($email).'&pass='.urlencode($pass).'&pass_placeholder=&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84'; if (fb_login($email,$pass)){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?login_attempt=1'); curl_setopt($ch, CURLOPT_POSTFIELDS,$qryString); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_FILE); curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_FILE); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $page = curl_exec($ch); } echo $page; function fb_login($login_email, $login_pass){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?login_attempt=1'); curl_setopt($ch, CURLOPT_POSTFIELDS,'charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&locale=en_US&email='.urlencode($login_email).'&pass='.urlencode($login_pass).'&pass_placeholder=&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_FILE); curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_FILE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)"); $html = curl_exec($ch); $err = 0; $err = curl_errno($ch); curl_close($ch); if ($err != 0){ echo 'error='.$err."\n"; return(false); } else { echo 'fetching..'; //echo $html; return(true); } } What could the problem be?? if i set CURLOPT_FOLLOWLOCATION to 0 it still wont work
  15. i have tryed putting ini_set('output_buffering', 0); at the start of the script but this still wont work.. when i transfered over the files to another hosting company it echoed out the statements straight away as the script ran. What could the problem be and does anyone know what i could do to fix this problem My hosting company said it was probably a coding error.
×
×
  • 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.