-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
By the way, what is the XML you're reading from?
-
If the XPath method (like SimpleXMLElement::xpath or DOMXPath::query) doesn't issue warnings in case of a syntax error, you can just run it and see if it works. Doesn't even have to match anything. Otherwise... probably need regular expressions, but one that would validate an XPath query would be insane. If you can restrict the query to a limited set of features then that'd help.
-
dot-all . doesn't normally match newlines. Use the /s flag to make it do so. Also use an ungreedy .*? inside your expression or else it might not match the way you want it to. preg_match_all('#(.*?)#s', $file_string, $titles);
-
Try with the loop for the photos inside the $preownedinfo loop, and then with it looping over $preownedinfo->AdditionalPhoto: <?php $preowned = simplexml_load_file('file.xml'); foreach ($preowned as $preownedinfo) { $price = '$' . money_format($preownedinfo->Price, 2, '.', ','); $photosHTML = ''; foreach ($preownedinfo->AdditionalPhoto as $addphoto) { $photosHTML .= "<li>$addphoto</li>"; } echo...
-
A browser plugin? Please. Is there something wrong with adjusting your HTML and CSS until it fits the labels correctly?
-
foreach ($AdditionalPhoto as $addphoto); echo "<li>$addphoto</li>"; endforeach;Wrong syntax. Either use normal {}s foreach ($AdditionalPhoto as $addphoto) { echo "<li>$addphoto</li>"; }or the alternative syntax which uses a colon (not a semicolon) foreach ($AdditionalPhoto as $addphoto): echo "<li>$addphoto</li>"; endforeach;However given that you use the alternative syntax correctly earlier I'm going to guess the semicolon is a typo.
-
Assuming you want to loop through the players and find matching injuries, you don't have to create one big array - you just need them in the right structure. Create a new injuries array that uses the player ID as the array key. array( 10009 => array(status, id, details), 10012 => array(status, id, details), ... )Note that if you output this new array you'll see that the array keys will be numbers and not strings - if #0251 had an injury it would be under the 251 array key. However PHP will handle the conversion for you so you don't need to worry about it. If it's possible to have multiple injuries on a player then you'll actually need a 2-D array array( 10009 => array( array(status, id, details), array(status, id, details), ... ), ... )(since you can't use an array key twice), which implies more complicated logic than simply $id=>$data such as if (isset(new injuries array[player])) { new injuries array[player][] = data } else { new injuries array[player] = array(data) }
-
Saying that doesn't tell us anything. You have to actually explain how it's not working. What is it doing? What did you expect it to do? What have you tried to do to fix it?
-
Just have to pay attention to little things. The error told you where the error was so your first step should be to look at the line very carefully and see if there aren't any little mistakes like that.
-
mysqli_connect mysqli_connect_errno mysqli_connect_error mysql_query mysqli_query mysqli_fetch_array mysqli_close
-
Temporarily use $requests = mysql_query("SELECT * FROM users, friendrequests WHERE touser='$username' AND fromuser=username ORDER BY requestid ASC") or die(mysql_error());and find out why your query failed. (Which is what happened.) Also, 1. The mysql extension and mysql_* functions are dead. Switch to mysqli or PDO. 2. Use a real JOIN instead of the comma. SELECT fields FROM users JOIN friendrequests ON whatever conditions to join them together WHERE the rest of your conditions... ORDER BY requestid ASC Good. It's telling you about all the things going wrong.
-
Two seconds: If you're still unsure what I'm getting at, try writing out a list of the functions you're using in this file. Carefully.
-
You're not adding yet another table. You're creating a new table for all the users and getting rid of the four you have now.
-
Use the query SHOW TABLES FROM databaseand grab the values from the first (and only) column.
-
Trying to use a get next date function and can't get 8/31/2013
requinix replied to njdubois's topic in Javascript Help
d.setDate(d.getDate() + 1) -
How do you access to a variable in a class from another class?
requinix replied to JongMin's topic in PHP Coding Help
Forget "design patterns" for a second, okay? That's just a fancy term for a group of more fancy terms for how you architect your code. What values? Do they change? Where do their values come from? Where do you need to use them? How are they used? -
It'll check any hostname you provide via the form, not just the "internal" database.
-
AppDownload needs to be only a URL. No quotes, no target=_blank. Then echo "Download";
-
Firebug isn't technically for PHP but for other things that are important in web development so yes, if you use Firefox then it's a good idea.
-
No, it's proper JSON. json_decode(), loop over "report", and each item's [0] is the ID. Try writing code for that.
-
Either you have the wrong class name, your autoloader isn't working, or your autoloader isn't finding the right file. Given how little you've posted, I don't know which of those it is. Have you tried... say... debugging? Your autoloader would be the first place to start.
-
Copy and paste the PHP for expire_date not working,
requinix replied to eug2's topic in PHP Coding Help
You can't simply copy and paste stuff from place, put it somewhere else, and expect it to work. On that note you can't simply modify PHP code without knowing any PHP and expect that to work either. Forget the code you have now. What is the code for the rest of the file and what are you trying to change about it? -
That's only a part of what you would need, and even then I think what it's getting at isn't a good idea. Move the files someplace not web accessible, then make a PHP script which (1) validates that the user is allowed to download the file (which is given in the URL, like the query string) and (2) dumps out the contents of that file if so. The "dumps out the contents" part looks like // assuming you have $file = the path to the file to download header("Content-Type: application/pdf"); // for PDF files, something else for other files header("Content-Length: " . filesize($file)); header("Content-Disposition: attachment; filename=" . basename($file)); readfile($file); exit;As for the "something else", it varies based on the type of file: PDFs = application/pdf MP3s = audio/mp3 JPGs = image/jpeg For images in general you can use getimagesize() and the "mime" it returns. // grab the file $extension if (in_array($extension, array("jpg", "jpeg", "gif", "png"))) { $info = getimagesize($file); $type = $info["mime"]; } else if ($extension == "pdf") { $type = "application/pdf"; } // etcThat all will take care of the sharing problem because only people logged in and able to get the file can get it. You don't need one-time URLs. If you really do want one-time URLs (IMO not worth the effort) then you'd also 1. Create a database table that tracks random IDs, the files they're associated with, and whether it's been used or not 2. Insert records when you present a download link 3. Your download script takes one of those random IDs instead of the file, looks up the relevant information, decides whether to allow the download or not, and continues appropriately Optionally include an expiration time on those random IDs.
-
Access denied for user 'ODBC'@'localhost' (using password: NO)
requinix replied to savala's topic in PHP Coding Help
Why the heck do you close the connection right after opening it?