Jump to content

Zerpex

Members
  • Posts

    40
  • Joined

  • Last visited

Everything posted by Zerpex

  1. Hi, I'm trying to make a header("Location: "); where I want, the url I'm currently on, without any ?id=1 etc, so I get /category/editCategory/ instead of /category/editCategory/?id=1 How can I do that, when I do $_SERVER, sometimes I see one called $_SERVER['REQUEST_URL'] (yep, URL, not URI) - which does exactly what I want, but it's only sometimes I have it :S Is there a nice way of doing it? Best regards, Lucas R.
  2. In my head if(empty($brandid) && empty($_FILES['image']) && empty($_POST['productDesc'])) should be true, if just one of them is empty (which the image and textarea) is at the moment, but it still returns false, so it proceed to the actual imageupload :/ it should do the error
  3. Update, I figured out the image thing! I was using $_POST instead of $_FILES! But still having the other problem with the textarea
  4. Hia, I'm having a form, containing an image upload, a textarea and some other fields. I have a fileupload, where I check if the upload thingy is empty, with if(empty($_POST['image'])) { echo "Error"; } else { //Do the imageUpload here } using the empty, isn't working for some reason, it proceed to the else anyway. Also, I have a textarea with name="productDesc", when I do: <?php var_dump($_POST); ?> It doesn't return the textarea, and I can't see why it doesn't. Also the textarea proceed to the 'else' in the if else in the following code: http://codepad.org/wMd6SnoK Having a lot of questions these days Thank you guys!
  5. Hi, I'm having an image upload function I did create for few weeks ago - it has an variable called $newname, which contains the path and file. I'm then using the imageupload() function in another function called EditFrontPage(), which is used to 'update' some content. If I update the image, it runs the imageupload function, which is great, it resize and optimize the image, and it moves it to the folder I specified. What I then want, is within' my EditFrontPage() function, is to echo out the $newname variable from the imageUpload function. is there a way to do this? in a smart way? If my code is needed, you can take a look at it here: http://codepad.org/poKNSU5H Thank you a lot guys!
  6. Hi again again, I'm making a search, where I use BETWEEN, if I have et $maxPrice is 2147483647 and $minPrice is 0 - (result from var_dump()), when I then use it in PDO, it's like it get another 'maxPrice' because it only show results under "200000" in price, but if I define, a static value of 2.000.000 it gets all the results as it should, but not when doing it with params in PDO :/ I also do a var_dump() of the maxprice, after the PDO, and the value is still the same as above (the 2147483647), and I've been spending loong time now, trying to find out why! Maybe someone here can spot the error! http://codepad.org/VIsk0UI8 Thank you a lot!
  7. Yep thorpe, It was just my copy/pasting, with code, I know that I had value for all my comparsions! Thank you anyway guys!
  8. Hi, I'm a little confused about the ternary operator, and how I should use it in following example. I have a list of, form radio's, where I want to check, if the $_GET['type'] etc is set to 'typeAll' the radio with the value 'typeAll' should be checked, else it shouldn't be checked. This is what I have currently: <ul> <li><strong>Vælg type</strong></li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="type" value="typeAll" />Alle Typer</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="type" value="typePerson" />Personbiler</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="type" value="typeVare" />Varebiler</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="type" value="typeMotor" />Motorcykler</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="type" value="typeTrailer" />Trailer</li> </ul> <ul> <li><strong>Vælg mærke</strong></li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> checked type="radio" name="brand" value="brandAll" />Alle mærker</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="brand" value="brandSuzuki" />Suzuki</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="brand" value="brandYamaha" />Yamaha</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="brand" value="brandVW" />VW</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="brand" value="brandBMW" />BMW</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="brand" value="brandPeugoet" />Peugoet</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="brand" value="brandMercedes" />Mercedes</li> </ul> <ul> <li><strong>Vælg pris</strong></li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> checked type="radio" name="price" value="priceAll" />Alle priser</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="price" value="price0-25" />0-25.000 DKK</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="price" value="price25-50" />25.000-50.000 DKK</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="price" value="price50-100" />50.000-100.000 DKK</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="price" value="price100-200" />100.000-200.000 DKK</li> <li><input <?=($_GET['type'] == 'value' ? 'checked' : '');?> type="radio" name="price" value="price200p" />over 200.000 DKK</li> </ul> <ul> I can manually write in the value in the ternary thingy, because I'm going to connect the inputs to a DB very soon! Best regards, Lucas R.
  9. Hia Muddy, the problem is, I need to be able to search, etc if I have a text input thingy, it should be able to search in columns, like name, price, brand, description, km, usage etc. But I will try find a solution! Thank you alot!
  10. Hi guys! I'm trying out fulltext search in MySQL, when I do my query like this: ALTER TABLE `products` ADD FULLTEXT(`name`, `breadcrumb`, `description`, `brand`, `price`, `year`, `km`, `usage`, `type`); I get an error, that it can't add the FULLTEXT to price like this: Column 'price' cannot be part of FULLTEXT index Is it because I've set it to float, that I can't do it? Best regards, Lucas R.
  11. ^^^ That will search the include_path first, then will look in the folder where the main requested file is (index.php), then in the current working directory. It will only check the inc folder if the include_path is not set. If you have more than one db.php file present and the first one found is not setting the $db variable, you can get the symptom you have reported. Edit: I would recommend echoing something unique in the 'correct' db.php file so that you know if it is the one that is actually being included. You saved my day! There was a file called db.php somewhere on the server, which did ruin it totally! I renamed my db.php to db_connect.php Thank you soooo much!
  12. Will see If $thisistherightdbvar works, I'm at work in 7 mins Thank you!
  13. When doing includes I do like on index.php: <?php include_once('inc/functions.php'); ?> If the file structure is like this: index.php inc/functions.php inc/db.php And in functions.php I include like: <?php include_once('db.php'); //functions go after this line ?>
  14. If I use urls in my includes, I should get an error, because it would not be able to find the file. I will link the subset of my code in 1-1.5 hour, I'm on the train to work atm. Anyway, what I first did, was to take the phpinfo from the dev server where it ain't working and the my localhost and prod server, to compare. The big difference is windows on dev server and *nix on the 2 others, the include_path for the windows server also seems weird to me, and then that Virtual Directory Support is enabled on the windows server too. Again, posting the code soon!
  15. I've learned, that breaking down the problem, to only those specific places is better, when I take same folder structure, but only have that 1 function called in Index which is Line 13 in the functions.php, I still get the problem. So at this point, no sidebar, or other functions is included except the getMenuItems
  16. I can say so much, if I have index.php, where I have the functions.php included using require_once('inc/functions.php'); etc, and then, right after the include call the function, that is giving the error - and nothing else, so it's only the call to the function I haven't pasted here
  17. I had pasted the code to pastebin earlier today, just forgot to put it here http://pastebin.com/htg4XWek this is the functions.php file <?php $db_username = 'user'; $db_password = 'pass'; $db = new PDO('mysql:host=127.0.0.1;dbname=lucas;charset=UTF8', $db_username, $db_password); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); ?>
  18. Hi again guys, I'm home from work. About the includes, they're included, because if I set another path, I get an error about failed stream, file not found or something like that.
  19. Hmm, I don't changed the code at all, my db gets defined in inc/db.php, the db.php is included, in the functions.php file, in same folder, using require_once, the functions.php file, is required_once in the header.php, which is in the web-root, the header.php is require_once in the index.php I will give you more info, as soon as I get home!
  20. Hi again everyone! I'm sitting here, developing the same site - on my localhost the site is working great! Then when I upload it, to another testserver (production for developers), I get following: Notice: Undefined variable: db in C:\xampp\htdocs\lucas\sidebar.php on line 3 Fatal error: Call to a member function prepare() on a non-object in C:\xampp\htdocs\lucas\inc\functions.php on line 13 I'm wondering why I get it, because if I do a try / catch on the db connection, and do a select * on the content table, it returns results, the paths should be almost the same.. On localhost I run: localhost/lucas/, on the prod-server I run liveip/lucas/ Can any spot the problem? I'm not a big xampp dude myself, I've attached an dump of my PHP info also, just rename the .php to .html Thank you a lot! Lucas R / Zerpex 17762_.php
  21. Hia! I solved the problem another way actually! I used the <base> attribute in html and it worked as it should!
  22. Hello everyone, I can't connect to IRC at the moment :/ Anyways, I'm creating a site, where I use 'pretty' urls, I'm rewriting etc contact.php to contact/ At the moment I'm on localhost/website/ and everything is working great! but as soon as I go to localhost/website/contact/ all the styles, and images, and JS is missing :/ This is how my RewriteEngine is at the moment: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ $1.php [L,QSA]
  23. Okay, so at the moment, I've tried out this code: <?php error_reporting(-1); mysql_connect('localhost', 'user', 'pass') or die(mysql_error()); mysql_select_db('wafcalculator') or die(mysql_error()); $query = "SELECT title, brand, points, brands.id FROM titles INNER JOIN categories ON titles.categoryid = categories.categoryid INNER JOIN brands ON brands.categoryid = categories.categoryid"; $result = mysql_query($query); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<h2>{$row['title']}</h2>"; foreach ($row['id'] as $int) { echo '<label class="checkbox"><input type="checkbox" name="totals['.$int.'][]" value="'.$row['points'].'"> '.$row['brand'].'</label>'; $int++; } //echo "{$row['brand']} "; //echo "{$row['points']} "; //echo "{$row['id']} "; //echo '<br />'; } ?> Only problem is that I'm getting an "invalid argument" on the foreach :S
×
×
  • 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.