[Solved] Echo an array value

Try this: $variable = $row[‘introtext’]; preg_match_all(‘/(src)=[^ ]+(\.gif|\.jpg|\.jpeg|\.png)/’,$variable, $out); print_r($out[0][0]); echo “http://mysiteurl.com/”.$out[0][0].” “; Read more about preg_match_all here 0 solved Echo an array value

[Solved] How to break the string after X letters? PHP

You are looking for this: wordwrap($text, $x_num_of_letters, $string_to_break, true); $x_num_of_letters should be an integer, of course. If you need to go to the next line in rendered HTML for example inside a <p>, you need to use <br> as $string_to_break. If you mean the next line of the file, use \n or \n\r. solved How … Read more

[Solved] How to fix information inside text box from disappearing upon submit and calculation?

OK, here is a fuller version of what you need: <?php function getDistance($addressFrom, $addressTo, $unit){ //Change address format $formattedAddrFrom = str_replace(‘ ‘,’+’,$addressFrom); $formattedAddrTo = str_replace(‘ ‘,’+’,$addressTo); //Send request and receive json data $geocodeFrom = file_get_contents(‘http://maps.google.com/maps/api/geocode/json? address=”.$formattedAddrFrom.”&sensor=false’); $outputFrom = json_decode($geocodeFrom); $geocodeTo = file_get_contents(‘http://maps.google.com/maps/api/geocode/json? address=”.$formattedAddrTo.”&sensor=false’); $outputTo = json_decode($geocodeTo); //Get latitude and longitude from geo data $latitudeFrom = … Read more

[Solved] Disable Button submit when over the due date [closed]

You should save the due date in the database. Then fetch it and compare it to the current date with PHP’s date_default_timezone_set() and date() functions and a simple if construct. http://php.net/manual/en/function.date-default-timezone-set.phphttp://www.php.net/manual/en/function.date.php 0 solved Disable Button submit when over the due date [closed]

[Solved] Check if row in table is ‘equal’ to other row

Try this: <?php if (!empty($_POST)) { $code = $_POST[‘code’]; mysql_connect(“$dbhost”,”$dbuser”,”$dbpass”); mysql_select_db(“$dbname”); $result = mysql_query(“SELECT * FROM files WHERE id=” . $code . ” LIMIT 1″); if (mysql_num_rows($result) > 0) { while($rows = mysql_fetch_array($result)) { echo ‘Exists’; $url = $rows[‘url’]; } } else { echo ‘Does not exist’; } } ?> 11 solved Check if row … Read more

[Solved] How to remove the zeros on the left using Php [closed]

ltrim — Strip whitespace (or other characters) from the beginning of a string You Can Use The code Below For a String or an Array: echo ltrim(“001221”, ‘0’); $array = array(“00051”, “205400”, “01022”, “0005”,”000000″); foreach($array as $item) { $new_item = ltrim($item, ‘0’); echo $new_item; } solved How to remove the zeros on the left using … Read more

[Solved] Javascript in php not working? [closed]

Your header() in code block 2 is calling for plain text. You should set this to a Javascript or HTML type output. Use one of the following header() calls instead. If you have javascript AND html in the output: header(‘Content-Type: text/html’); If your output is javascript ONLY (no html tags): header(‘Content-Type: application/javascript’); 1 solved Javascript … Read more

[Solved] Are this if statements equal? [closed]

Let us break it down. isset($_SESSION[‘id’]) == 1 The first part, the isset() call, will return a boolean value (true or false), depending on if the session id is set or not. When you compare an integer value with a boolean value, using the == operator, the integer will be coerced (or cast/type-juggled) into a … Read more

[Solved] 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 [closed]

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 [closed] solved 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 [closed]

[Solved] Get what’s written in the select menu [closed]

The browser won’t send that information to the server. Since you (presumably) wrote the HTML in the first place, you can keep a record of what values are associated with what labels. This is usually done using a database, but you could hard code it into an associative array into the script. Once you have … Read more