PHP - Imagerotate Problems
Hello everyone,
I am trying to rotate an image, but when I run my script I get: Fatal error: Call to undefined function imagerotate() in test.php on line 15 When I run phpinfo(), it shows GD support is enabled. Anyone have any ideas on how to get this to work? Thanks! weee Similar TutorialsI would like to select a color that isn't in an image, any thoughts on the best way? Maybe this isn't even the best way to do this. I am using imagerotate, and for the 3rd parameter, I would like the uncovered area to be transparent. I have done this, but I had to use a color then make every color in the image of that color transparent. so, either what is the best way: A. Is there a good way to do this? B. save every pixel color in an array then loop though the array testing colors that are not in the array and setting that as the transparent value. C. Other. What? Im trying to make a script that previews the level for a game, but im having issues with transparency and the rotation of each image. you can see the problem he http://beta.trackmill.com/DUI/preview/ here is the php file <?php header('Content-Type: image/png'); $image = imagecreatefrompng('images/Background.png'); function radiansToDegrees($radians) { return $radians * 180 / pi(); } $map = file_get_contents('map.txt'); $blocks = split("<obj", $map); for($i=2; $i<count($blocks); $i++) { $arg = split(" ", $blocks[$i]); $n = str_replace("n", "", str_replace("=", "", str_replace('"', "", $arg[1]))); $x = str_replace("x", "", str_replace("=", "", str_replace('"', "", $arg[2]))); $x = $x * 20 - 13; $y = str_replace("y", "", str_replace("=", "", str_replace('"', "", $arg[3]))); $y = $y * 22 + 15; $a = str_replace("a", "", str_replace("=", "", str_replace('"', "", $arg[4]))); $a = radiansToDegrees($a); $t = str_replace("t", "", str_replace("=", "", str_replace('"', "", $arg[5]))); $e = str_replace("e", "", str_replace("=", "", str_replace('"', "", $arg[6]))); $f = str_replace("f", "", str_replace("=", "", str_replace('"', "", str_replace('/>', "", $arg[7])))); $blockimage = imagecreatefrompng("images/$n.png"); $blockimage = imagerotate($blockimage, -$a, 0, 0) ; imagealphablending($blockimage, false); imagesavealpha($blockimage, true); imagecopy($image, $blockimage, $x, $y, 0, 0, imagesx($blockimage), imagesy($blockimage)); //echo "$i | $n - $x - $y - $a - $t - $e - $f <br>"; } imagepng($image); imagedestroy($image); ?> if you require the .zip containing the images etc, just reply and i will upload it as soon as possible class curl2{ private $curl_init; private $CURLOPT_URL; public function connect(){ $this->curl_init = curl_init(); } public function debug(){ curl_setopt($this->curl_init, CURLOPT_VERBOSE, TRUE); $fp = fopen("curl2.txt", "w"); curl_setopt($this->curl_init, CURLOPT_STDERR, $fp); curl_setopt($this->curl_init, CURLOPT_RETURNTRANSFER, TRUE); } public function setUrl($url = null){ $this->CURLOPT_URL = $url; curl_setopt($this->curl_init, CURLOPT_URL, $this->CURLOPT_URL); } public function execute(){ $out = curl_exec($this->curl_init); curl_close($this->curl_init); return $out; } } $curl2 = new curl2; $curl2->connect(); $curl2->setUrl("http://www.linuxformat.co.uk"); $curl2->debug(); echo $curl2->execute(); It display a blank page like attachment result1.jpg, but if I move the $fp = fopen("curl2.txt", "w"); curl_setopt($this->curl_init, CURLOPT_STDERR, $fp); curl_setopt($this->curl_init, CURLOPT_RETURNTRANSFER, TRUE); from function debug() and join it with function execute() like this: public function execute(){ $fp = fopen("curl2.txt", "w"); curl_setopt($this->curl_init, CURLOPT_STDERR, $fp); curl_setopt($this->curl_init, CURLOPT_RETURNTRANSFER, TRUE); $out = curl_exec($this->curl_init); curl_close($this->curl_init); return $out; } it return me Linuxformat content ( expected result ) like result2.jpg below is the working code : class curl2{ private $curl_init; private $CURLOPT_URL; public function connect(){ $this->curl_init = curl_init(); } public function debug(){ curl_setopt($this->curl_init, CURLOPT_VERBOSE, TRUE); } public function setUrl($url = null){ $this->CURLOPT_URL = $url; curl_setopt($this->curl_init, CURLOPT_URL, $this->CURLOPT_URL); } public function execute(){ $fp = fopen("curl2.txt", "w"); curl_setopt($this->curl_init, CURLOPT_STDERR, $fp); curl_setopt($this->curl_init, CURLOPT_RETURNTRANSFER, TRUE); $out = curl_exec($this->curl_init); curl_close($this->curl_init); return $out; } } $curl2 = new curl2; $curl2->connect(); $curl2->setUrl("http://www.linuxformat.co.uk"); $curl2->debug(); echo $curl2->execute(); Why I couldn't split "CURLOPT_STDERR, CURLOPT_RETURNTRANSFER" with "curl_exec" I'm trying to either update my database if some data matches the if statement, or insert the data in a new row if it doesn't match (if possible). The code will update the database just fine if the data matches, but if not, it won't insert the new data. (When I leave off the if statement it will insert just fine). I fear I'm not using the if...else correctly. Thanks for any help. <?php header("Location: admin_schedule.php"); include("opendatabase.php"); $date=("$_POST[gamedate]"); $week=("$_POST[Week]"); $game=("$_POST[Game]"); $hometeam=("$_POST[team_name_1]"); $awayteam=("$_POST[team_name_2]"); $check = mysql_query("SELECT week_id,game_id FROM schedule"); $row[] = mysql_fetch_array($check); if ($row[week_id]='$week' && $row[game_id]='$game') { mysql_query("UPDATE schedule SET week_id = '$week', game_id = '$game', date = '$date', H_team = '$hometeam', A_team = '$awayteam' WHERE week_id = '$week' AND game_id = '$game'"); } else { mysql_query("INSERT INTO schedule (week_id,game_id,date,H_team,A_team) VALUES('$week','$game','$date','$hometeam','$awayteam')"); } mysql_close($con); the image in my comments box wont show up it gives me an error Code: [Select] Notice: Undefined index: avatar in /home/ecabrera/public_html/profile.php on line 277 and i dont whats wrong with it Code: [Select] // display comments $perpage = 10; $start=0; if(@$_GET['s']) $start = $_GET['s']; $query = mysql_query("SELECT * FROM profile_comments WHERE profile_id='$getid' ORDER BY id DESC LIMIT $start, $perpage"); $numrows = mysql_num_rows($query); if ($numrows > 0){ $next = $start + $perpage; $prev = $start - $perpage; while($row = mysql_fetch_assoc($query)){ $user_id = $row['user_id']; $user_name = $row['user_name']; $comment = nl2br($row['comment']); $date = $row['date']; $avatar = $row['avatar']; echo "<img src='avatars/$avatar'></img><a href='$site/profile?id=$getid'></a> <b> on $date</b><br />"; echo "<div style='margin-left: 10px;'>$comment</div><hr>"; } } else echo "This user has no profile comments.<br />"; // end diplay comment area Hi I have plans in developing a connect function for remote login to my web side. I can't find any useful on Google. Some idees on how to code a API connect button? Something similiar to Facebook connect, Twitter connect etc. BUT this should not rely on facebook api. I'm going to make my own stand alone api. I know I need to use REST in backend, but I'm missing the knowledge to know how to send / recive the login data, and how to know when a user are online or not. I'm greatfull for any help. Also links. And also tips on how to make a developer plattform for apps, much like the way Facebook have it. Hello, Alright I am having a few issues here. Let me explain what I am doing...this is a script that allows a customer to split an order..he can split certain items out of one order and it will create another order with the items he split added to this order, and then subtracting the items from the old order. The products are stored in one field called products, they are stored in a delimited list like this qty, product name, price each, product id | qty, product name, price each, product id |etc. Now, before you say why are you storing your products like that?? The reason I have to store my products like so is because the customer does not want the products stored in the order table to be dependent off the products table like they were before. In that case if he modified a product it would modify all of the orders with that product stored in them. Make sense? I am aware a delimited list probably wasn't the best way to do this but it was the best way I could think of. Ok here is my list of issues. 1) Everytime you split an order, it is not creating a new order to store the items that were split into. It created an order the first time I did it, and now all it does is it keeps updating the products field in that order, rather than creating a new order. 2) Next I do not know how I can update the old products (stored in the $prod array). It needs to update the products qtys after the order was split, and then if all of the qty for that product were moved to the new order it just needs to remove that product from the $prod array rather than updating the quantity. The code is below. Please let me know if I can provide any more information to help! Thanks everyone! // Get Old Order $get_order = @mysql_query("SELECT * FROM orders WHERE order_id = {$_POST['order_id']}"); $order = @mysql_fetch_assoc($get_order); // Get Old Order Items $products = $order['products']; //breaking products text down for display $prod = array(); $_products = explode('|', $products); foreach ($_products AS $p) $prod[] = explode(',', $p); /* $get_items = @mysql_query("SELECT product_id, qty FROM order_items WHERE order_id = {$order['order_id']}"); $items = array(); while(($row = @mysql_fetch_assoc($get_items)) !== false) { $items[] = $row; } */ if(empty($prod)) { header("Location: tracking.php"); die(); } // Create New Order mysql_query("INSERT INTO orders SET customer_id = {$order['customer_id']}, order_status = {$order['order_status']}, order_date = '{$order['order_date']}', order_date_paid = '{$order['order_date_paid']}', order_shipping = '{$order['order_shipping']}', order_shipping_fee = '{$order['order_shipping_fee']}', order_insurance = '{$order['order_insurance']}', order_insurance_fee = '{$order['order_insurance_fee']}', order_insurance_total = '{$order['order_insurance_total']}', order_grand_total = '{$order['order_grand_total']}', order_date = '{$order['order_date']}', order_filled = '{$order['order_filled']}', order_ship_date = '{$order['ship_date']}'"); $get_new_order = @mysql_query("SELECT MAX(order_id) AS order_id FROM orders") or die(mysql_error()); $new_order_id = @mysql_result($get_new_order, 'order_id', 0); // Add Items to New Order & Remove Items from Old Order $new_items = array(); $_new_items = ''; foreach($prod as $p2) { for($i = 0; $i < $p2[0]; $i++) { if(!empty($_POST[trim($p2[3]).'_'.$i])) { $new_items[trim($p2[3])]++; } } } //construct new static products list foreach($new_items as $id=>$qty) { $get_product = mysql_query("SELECT name, price FROM products WHERE product_id = '{$id}'"); $got_product = mysql_fetch_assoc($get_product); $_new_items .= $qty.','.$got_product['name'].','.$got_product['price'].','.$id.'|'; //echo $id.' - '.$qty.'<br>'; } //remove last character in products text before going into DB $_new_items = substr_replace($_new_items ,"",-1); //update products field in new order mysql_query("UPDATE orders SET products = '{$_new_items}' WHERE order_id = '{$new_order_id}'"); I want to gettwitter feeds, this gives me a xml http://twitter.com/statuses/user_timeline.rss?screen_name=fleuragemapvv&count=3 based on this: http://www.w3schools.com/PHP/php_xml_simplexml.asp i try to get the xml with: <?php$xml = simplexml_load_file("http://twitter.com/statuses/user_timeline.rss?screen_name=fleuragemapvv&count=3");?>() i get this error: Quote Warning: simplexml_load_file(http://twitter.com/statuses/user_timeline.rss?screen_name=fleuragemapvv&count=3): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /home/vhosting/x/vhost0033377/domains/doekewartena.nl/htdocs/www/temp/twitter03.php on line 2 Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://twitter.com/statuses/user_timeline.rss?screen_name=fleuragemapvv&count=3" in /home/vhosting/x/vhost0033377/domains/doekewartena.nl/htdocs/www/temp/twitter03.php on line 2 i have no clue, i'm very new to php can i even use simplexml_load_file cause it has no .xml file type extention. First Since I first started learning PHP, I've been writing code for forms like this: $name = $_POST["name"]; if ($name == "") { echo "You didn't type anything"; } I've written scripts like this and tested them on a GOdaddy server, and they always worked fine. Now, after testing scripts like that on my own server (WAMP2 [PHP5, Mysql, Apache]), I get an error saying "Unidentified index: name", and so I have to nest that if statement AS WELL AS the variable assignment inside another if statement like this: if (isset ($_POST["name"])) { $name = $_POST["name"]; if ($name == "") { echo "you didn't type anything. } } The error doesn't actually stop the script from running, but a medium sized box appears in the browser with the error message contained that's after the element in the document of which is getting an invalid error. Which way is truly the correct way? Because now that I have to use the second way in order for my scripts to run correctly on my own server, I have to write more code and it all gets disorganized and more complicated to read. So...is this a configuration thing that I can tweak in WAMP2 to stop messages like that from popping up? Or is the second way the way you're supposed to do it? Also, I was wondering why ereg got deprecated and what the replacement of it is in PHP5? I've asked before and even googled it but I simply get taken to a "Pearl" function on PHP.net. I'm not sure what it is, or how to use it, and haven't got any hints from either PHP.net or anywhere else. Any suggestions? Hi, I hope someone can help me. I am trying to generate a script for our Intranet that tells me which birthdays = today. My field in my table = d/m/y, eg 09/05/2011 (9 May 2011). How do I get the script to just look at the day & month, not the year? My script looks like this: Code: [Select] <?php echo date("d/m/Y") . "<br />"; $myDate = date('d/m/Y'); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("dbname", $con); $sql = "SELECT * FROM detail WHERE dob='$mydate'"; $result=mysql_query($sql); echo mysql_num_rows($result); ?> Hi... I have a string (called $textData) with the following format: Code: [Select] 1. e4 {[%emt 0:00:10]} c5 {[%emt 0:00:04]} 2. c3 {[%emt 0:02:15]}etc I need to replace the square brackets/special chars within that string with " "... so my first thought was to use preg_match to find the matches.. then preg_replace/str_replace to update them. To find the patterns, I think this is correct: preg_match('/\{([^\}]*)\}/', $textData, $matches); echo print_r($matches, true); // returns Array ( [0] => {[%emt 0:00:10]} [1] => [%emt 0:00:10] ) // returns nothing else I expected the preg_match to search through the whole of $textData. Then I could replace the square brackets/special chars with a spaces. Thank you for your time!! I seem to be having a problem with directorys I cam mkdir("$userid,0755") but when i come to remove it with rmdir it doesn't remove it the directory is empty even through ftp and my control panel it won't let me delete it or change the file permissions from 755 any ideas? I want to pull the last 8 entries from a database. Code: [Select] $result = mysql_query("SELECT * FROM `sites` ORDER BY id DESC LIMIT 8"); The problem is when I ORDER BY ASC the elements are displayed fine but in ORDER BY DESC the are messed up. Why? and how do I fix it ORDER BY DESC ORDER BY ASC CSS Code: [Select] html { font-family: segoe ui, arial, helvetica, sans-serif; height: 100%; overflow: hidden; } body { background-image: linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%); background-image: -o-linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%); background-image: -moz-linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%); background-image: -webkit-linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%); background-image: -ms-linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%); background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0.16, #FFFFFF),color-stop(0.79, #E8E8E8)); background-repeat: no-repeat; } #sites { width: 56%; padding: 10px; position: relative; left: 50%; margin-left: -29%; top: 150px; } .siteWidget { margin: 5px; padding: 10px; width: 200px; float: left; text-align: center; -webkit-transition: all 0.25s ease-in-out; -moz-transition: all 0.25s ease-in-out; } .siteWidget .img { height: 150px; -moz-box-shadow: 2px 2px rgba(0,0,0,0.25); -webkit-box-shadow: 2px 2px rgba(0,0,0,0.25); box-shadow: 2px 2px rgba(0,0,0,0.25); margin-bottom: 10px; } .siteWidget .img:hover { box-shadow: 0 0 10px rgba(0, 0, 0, 1); -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 1); -moz-box-shadow: 0 0 10px rgba(0, 0, 0, 1); } a { text-decoration: none; colour: black; } a:visited { color: black; } a:hover { color: #e90000; } h3 { margin: 0; padding: 0; } html/PHP Code: [Select] <? ob_start(); include('config.php'); ?> <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title>Site Selector</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <?php if (!isset($_POST['submit'])) { ?> <form action="index.php" method="post"> <table> <tr> <td> <h3>Add New Site: </h3> </td> <td> <input type="text" name="siteName" placeholder="Name" /> </td> <td> <input type="text" name="siteUrl" placeholder="URL" /> </td> <td> <input type="submit" name="submit" value="Add Site" /> </td> </tr> </table> </form> <div id="sites"> <?php //load the pages from the Database $result = mysql_query("SELECT * FROM `sites` ORDER BY id ASC LIMIT 8"); if (mysql_num_rows($result) == 0) { echo 'No entries'; } else { while ($row = mysql_fetch_assoc($result)) { ?> <div class="siteWidget"> <div class="img"><a href="http://<?=$row['url']?>"><img src="http://pagepeeker.com/t/m/<?=$row['url']?>" border="0"></a></div> <a href="http://<?=$row['url']?>" name="<?=$row['name']?>"><?=$row['name']?></a> </div> <? } } } else { //Get the data $siteName = secure($_POST['siteName']); $siteUrl = secure($_POST['siteUrl']); if (!$siteName || $siteUrl) { header("Location: index.php"); } else { $query = mysql_query("INSERT INTO `sites` (name, url) VALUE($siteName, $siteUrl)"); if (mysql_num_rows($query)) { header("Location: index.php"); } else { echo 'Site not Added!<br />'; echo '<a href="index.php">Go Back</a>'; } } } ?> <div style="clear:both;"></div> </div> </body> </html> HTML ONLY Code: [Select] <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title>Site Selector</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <form action="index.php" method="post"> <table> <tr> <td> <h3>Add New Site: </h3> </td> <td> <input type="text" name="siteName" placeholder="Name" /> </td> <td> <input type="text" name="siteUrl" placeholder="URL" /> </td> <td> <input type="submit" name="submit" value="Add Site" /> </td> </tr> </table> </form> <div id="sites"> <div class="siteWidget"> <div class="img"><a href="http://google.ca"><img src="http://pagepeeker.com/t/m/google.ca" border="0"></a></div> <a href="http://google.ca" name="Google">Google</a> </div> <div class="siteWidget"> <div class="img"><a href="http://facebook.com"><img src="http://pagepeeker.com/t/m/facebook.com" border="0"></a></div> <a href="http://facebook.com" name="Facebook">Facebook</a> </div> <div class="siteWidget"> <div class="img"><a href="http://coldcallradio.com"><img src="http://pagepeeker.com/t/m/coldcallradio.com" border="0"></a></div> <a href="http://coldcallradio.com" name="Cold Call Radio">Cold Call Radio</a> </div> <div class="siteWidget"> <div class="img"><a href="http://redbarradio.net"><img src="http://pagepeeker.com/t/m/redbarradio.net" border="0"></a></div> <a href="http://redbarradio.net" name="Red Bar Radio">Red Bar Radio</a> </div> <div class="siteWidget"> <div class="img"><a href="http://youtube.com"><img src="http://pagepeeker.com/t/m/youtube.com" border="0"></a></div> <a href="http://youtube.com" name="YouTube">YouTube</a> </div> <div class="siteWidget"> <div class="img"><a href="http://coldcallradio.com/wp-admin"><img src="http://pagepeeker.com/t/m/coldcallradio.com/wp-admin" border="0"></a></div> <a href="http://coldcallradio.com/wp-admin" name="Cold Call Radio Admin Panel">Cold Call Radio Admin Panel</a> </div> <div class="siteWidget"> <div class="img"><a href="http://apple.ca"><img src="http://pagepeeker.com/t/m/apple.ca" border="0"></a></div> <a href="http://apple.ca" name="Apple Canada">Apple Canada</a> </div> <div class="siteWidget"> <div class="img"><a href="http://trios.com"><img src="http://pagepeeker.com/t/m/trios.com" border="0"></a></div> <a href="http://trios.com" name="triOs College">triOs College</a> </div> <div style="clear:both;"></div> </div> </body> </html> Hello there, well basically what this function does is look at all the entry's to find a unused port in the database but when I run the function the first time if the table is empty mysql_insert_id works fine, but then if I run it again the mysql_insert_id keeps returning 0, I am using it immediately after the query but its not working properly, can anybody shed some ideas into the matter, anything is appreciated!, thanks for your time!: function addServerToBuildPool($ServerGame, $ServerOwner, $ServerSlots, $ServerBox) { $Server = mysql_fetch_array(mysql_query("SELECT * FROM xhost_boxs WHERE box_id = '".mysql_real_escape_string($ServerBox)."'")); $AddServer = mysql_query("INSERT INTO xhost_servers (server_game, server_slots, server_owner, server_ip, server_is_setup) VALUES('".mysql_real_escape_string($ServerGame)."', '".mysql_real_escape_string($ServerSlots)."', '".mysql_real_escape_string($ServerOwner)."', '".mysql_real_escape_string($Server['box_ip'])."', 'No')"); $ServerID = mysql_insert_id(); $FindPort = mysql_query("SELECT server_port FROM xhost_servers ORDER BY server_id ASC"); $Port = 0; while($row = mysql_fetch_assoc($FindPort)) { $Port = ($Port == 0)? $row['server_port'] : $Port; if($row['server_port'] != $Port) { break; } $Port++; } mysql_query("UPDATE xhost_servers SET server_port = '".$Port."' AND server_username = 'server".$ServerID."' AND server_password = '".rand(5000000, 900000000)."' WHERE server_id = '".$ServerID."'") or die(mysql_error()); } I am trying to retrieve an attribute from a node and I keep getting the error: Warning: main() [function.main]: Node no longer exists in /Users/dmonsewicz/Projects/noosemonsewicz/api_stuff/index.php on line 70 PHP Code Code: [Select] $xml = new SimpleXMLElement($result); $arr = $xml->tickets->attributes(); echo $arr['count']; XML Code: [Select] <tickets count="0" type="array"></tickets> Any ideas on what I may be doing wrong? Hello all. I'm pretty new to this, but I'm trying to build a script that will write random questions for a quiz app that I'm working on. The data is contained in two different tables. I'm trying to randomize the question order that is spit out, as well as randomize the answer order that is displayed. The output has to be in the specific JSON string that is denoted in the code. There are no errors when I go the url that I load the script, however, the string is not populated with any of the data from my tables (it is just an empty set of strings in the JSON format that the program requires. Could someone please take a look at this and tell me where I'm going wrong. I've checked that the query is pulling from the correct databases so I know that's not the problem. Thank you in advance. Code: [Select] <?php //Connect To Database $hostname=""; $username=""; $password=""; $dbname=""; $question_table="wp_mtouchquiz_question"; $answer_table="wp_mtouchquiz_answer"; $yourfield = "question"; $question = "question"; $answer = "answer"; $connection = mysql_connect($hostname, $username, $password); $lastQuestionID = -1; $str = ""; mysql_select_db($dbname, $connection); # Check If Record Exists $query = "SELECT * FROM $question_table q, $answer_table a WHERE q.ID = a.QUESTION_ID AND q.quiz_id = 1 ORDER BY question_id ASC, correct DESC"; $result = mysql_query($query); $questions = array(); $fields = array(); if($result) { while($row = mysql_fetch_array($result)) { if($lastQuestionID != $row["question_id"]) { $fields = array(); if($lastQuestionID != -1) { array_push($questions, $fields); } $fields = array(); $lastQuestionID = $row["question_id"]; $fields["question_id"] = $row["question_id"]; $fields["question"] = $row["question"]; } // correct if($row["correct"] == 1) { $fields["correct"] = $row["answer"]; } // incorrect if ($row["sort_order"] ==2) { $fields["incorrect0"] = $row["answer"]; } // incorrect if ($row["sort_order"] ==3) { $fields["incorrect1"] = $row["answer"]; } // incorrect if ($row["sort_order"] ==4) { $fields["incorrect2"] = $row["answer"]; } if ($row["sort_order"] ==5) { $fields["incorrect3"] = $row["answer"]; } } $str .= "{\"childItems\":["; $numQuestionsToUse = 172; //Set this larger than returned questions or less than row limit / 5 $randomQuestionKeys = array_rand($questions, $numQuestionsToUse); $numQuestions = count($randomQuestionKeys); for($i = 0; $i < $numQuestions ; $i++){ $pickedField = $questions[$randomQuestionKeys[$i]]; $str .= "{\"itemId\":\"question" . $pickedField["question_id"] . "\","; $str .= "\"itemType\":\"BT_questionItem\","; $str .= "\"questionText\":\"" . $pickedField["question"] . "\","; $str .= "\"correctAnswerText\":\"" . $pickedField["answer"] . "\","; $incorrectAnswers = array(); array_push($incorrectAnswers, $pickedField["incorrect0"]); array_push($incorrectAnswers, $pickedField["incorrect1"]); array_push($incorrectAnswers, $pickedField["incorrect2"]); array_push($incorrectAnswers, $pickedField["incorrect3"]); $incorrectAnsKey = array_rand($incorrectAnswers, 3); $str .= "\"incorrectText1\":\"" . $incorrectAnswers[$incorrectAnsKey[0]] . "\","; $str .= "\"incorrectText2\":\"" . $incorrectAnswers[$incorrectAnsKey[0]] . "\","; $str .= "\"incorrectText3\":\"" . $incorrectAnswers[$incorrectAnsKey[0]] . "\","; $str .= "\"imageURLSmallDevice\":\"http://www.myquizcoach.com/extras/images/clear_header.png\","; $str .= "\"imageURLLargeDevice\":\"http://www.myquizcoach.com/extras/images/clear_header.png\"},"; } // remove last comma $str = substr($str,'',-1); $str .= "] }"; echo $str; } ?> I'm writing a rather large script and it appears that I'm running into some require_once problems. So far I only have a few files wrote for my script.. ./includes/objects/database.class.php require_once("../../config.php"); ./test.php require_once("./config.php"); require_once("./includes/objects/database.class.php"); When I try running the test.php I get the following error: Code: [Select] Warning: require_once(../../config.inc.php) [function.require-once]: failed to open stream: No such file or directory in /includes/objects/database.class.php on line 27 Fatal error: require_once() [function.require]: Failed opening required '../../config.inc.php' (include_path='.:/opt/lampp/lib/php') in /includes/objects/database.class.php on line 27 However, when I run the database.class.php by itself it doesn't have any errors at all and it requires (sounds weird.. includes I guess?) the file just fine. I only get the above error from running test.php. I'm running on a local environment using XAMPP so there might be some php configuration option that I'm not aware of. I've tried doing some reading and I'm honestly not sure what could be the problem. Help? Hi im pritty new to PHP used to using ASP but found PHP to be more resourcful! Anyway, Im trying to work out how to get my script to define if a prduct fee is higher than an available account balance, but hitting brick walls! CODE BELOW: $Credits = 10; $Fee = 5; if ($Fee > $Credits){ //NEED MORE CREDITS }else{ //YOU CAN PURCHASE THIS ITEM } But returns that 10 is not greater than 5, i guess this is because it is only taking the first digit into consideration, even if it is 12 or 15 is still says its not higher than 5 ??? Ive been at it for hours searched google and come up with nothing... please help I may be acting thick and it may be really simple but im lost! Thanks in advance! It seems like every new language I learn, I get this exact same issue. I want to make a clickable link that will go to "viewpost?postid=" and then add the value of a variable. The variable is an array. Here's what I'm trying. I'm not really sure why it doesn't work: <?php $poststr = "<a href=\'viewpost.php?"+$postid[$num]+"\'>View This Post</a>"; echo $poststr; ?> $postid[$num] in this example should be an integer. But what it outputs is really weird. It's not "View This Post" as a link, which is what I want. It just outputs the value of the variable $postid[$num] with no link. Can someone tell me what my problem is? |