why do you do this?
$explodedPath = explode("C:/xampp/htdocs/avatars" , $_SESSION['pic_location']);
echo '<img src="http://[localhost]'.$explodedPath[1].'" />';
why do you do this?
$explodedPath = explode("C:/xampp/htdocs/avatars" , $_SESSION['pic_location']);
echo '<img src="http://[localhost]'.$explodedPath[1].'" />';
so what so far is not working?
This is a matter of personal preference on whether to store the full file path in the db or to just store the file name. I generally like to only store the file name because if I later decide that I want the folder to be located somewhere else I wont have to go back in and fix all the links in the db. Furthermore, If I access the image from different pages in different locations in my file structure I dont have to try and correct the path to make it correctly relative to the document. If this were my script I would use this for the storage;
This is the good way! Don't store full path. You can store folder path to images in config file and retrieve it from there (A technique common in frameworks but will do great help here too)
for PHP I suggest W3Schools. I also love Videos from Youtube user PHPAcademy plus my favorite PHP 101
As for JavaScript I think w3Schools is enough! For JQuery just start with their home page. Also Check JQuery From Novice to Ninja from site point.
Python have tons of free books out there: Thinking Python, Dive into Python, A Byte of Python et al. Also the official Pytutorial is wonderful!
@ChaosKnight11:
Careful! Iirc the LGPL allows you to freely link to Qt dynamically.
So you have to either use the DLL(or *nix equivalent)-version of Qt or deliver your object files, so the user could link your program with another Version of Qt.
That is why I gave wxOption. Free to link shared static modify sources....full freedom!
If you need a "Don't worry licence" go for wxWidgets!
I am completely stuck on this assignment I'm not sure what I should be getting. Can anybody take a look at my code and please help me. I need to complete this assignment asap. thanks
Direction: Design, implement, and test a class that represents a phone number. The number should be represented by a country code, an area code, a number, and a type. The first three values can be integers. The type member is an enumeration of HOME, OFFICE, FAX, CELL, and PAGER. The class should provide a default constructor that sets all of the values to zero and type to HOME. A constructor that enables all of the values to be set should be provided as well. You should also provide a constructor that takes just the number and type as arguments, and sets the country and area codes to those of your location. The class will have observers that enable each data member to be retrieved, and transformers that allow each data member to be changed. An additional observer should be provided that compares two phone numbers for equality.
post your codes here!
AFAICS, all these should be class attributes and only you need getters and setters. Call those setter for attributes in question on constructor.
So how exactly would I write a dll and implementation file for the three blocks of code in my first post in this thread?
For exporting classes, it is better to create and destroy objects in DLL itself to avoid compiler crash (if main app is compiled differently from DLL(s)). So export method for creating object and destroying objects in DLL as C-style.
something like:
class Library{
//all methods goes here
}
extern "C"{
Library* createObject(){
return new Library();
}
destroyObject(Library* lib){
delete lib;
lib=NULL;
}
}
Check MSDN entry on making DLLs
I am a newbie with php and was hoping someone can help me out. I am creating my first dynamic site in php and have gotten stuck. I have one page with 100's of links. I need all these links to load the same page but I need the server to load it so that it is a different URL.
Example:
link - clicks through to index1.php?123
link - clicks through to index1.php?456
link - clicks through to index1.php?789Thanks
Mh! and what have you done so far?
don't forget to mark it solved!
Hi Ev, good answer - I saw a few things about carrying over a session var with just id and then getting the whole caboodle again. I was just thinking about having to include a shed full of classes for what would be a trivial update. My fault, I need to seriously get my head out of my derriere and start thinking OOP instead of procedural.
As for persisting with persistence, I think I can safely let that idea slip now. Still, I feel like I'm looking up at Everest from sea level.
Thanks for the links.
Glad that I was of help,
enjoy!
The best way would be wrapping these into class and do it in two line:
$liker = new LikerClass(true);//true for like(default) and false for dislike
$liker->action();//do like/unlike
$liker->getLikes();
$liker->getDislikes();
I have made small demo for you. Play around it to fit your needs.
Schema:
CREATE TABLE `likesys` (
`id` INT NOT NULL AUTO_INCREMENT,
`liked` INT(1) NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE = MyISAM;
PHP file
<html>
<head>
</head>
<body>
<?php
ini_set("display_errors", 1);//error mgt
try{
$db = new PDO("mysql:host=localhost;dbname=test", "test_user", "__put_password_here__");
}catch(PDOException $e){
echo $e->getMessage();
}
$stmt=$db->prepare("INSERT INTO likesys(liked) VALUES(:like)");
$stmt2=$db->prepare("SELECT SUM(liked) AS likes FROM likesys WHERE liked=:like");
$display=false;
if(isset($_POST["like"])){
$stmt->execute(array(":like"=>"1"));
$display=true;
}
if(isset($_POST["dislike"])){
$stmt->execute(array(":like"=>"-1"));
$display=true;
}
$stmt->closeCursor();
//if($display){
$stmt2->execute(array(":like"=>"1"));
$res = $stmt2->fetch(PDO::FETCH_ASSOC);
echo "<p>Likes: ". $res['likes']."</p>";
$stmt2->execute(array(":like"=>"-1"));
$res = $stmt2->fetch(PDO::FETCH_ASSOC);
echo "<p>Dislikes: ". abs($res['likes'])."</p>";
// }
$db=null;
?>
<form action=<?php echo $_SERVER["PHP_SELF"];?> method="POST" >
<input name="like" type="submit" value="Like" />
<input name="dislike" type="submit" value="Dislike" />
</form>
</body>
</html>
or maybe its sort of an browser addon?
Try another browser or use same browser with all addons disabled
Hi all,
Trying to get my head around OOP at long last. Finally got to the beggar on my to-do list.
Welcome to the world of beasts ;)
Just a quick question:
I was looking for a way to persist the object across pages, but on further research, I got the idea that this is a bad idea and that objects should be created anew on every page. Does this also apply to Ajax calls (I assume it does)? Seems like a lot of work for a straightforward part-of-page-update. I haven't got a specific use in mind, still at the concept stage.
Why would you want to persists objects across the page? Since technically AJAX call is just like other calls with no reloading of page then things goes just like the non Ajax page. I think that should be avoided and alternative is given below. If you persist on testing the concept, check serialize/unserialize and this one
Just thinking of all the include files req'd by a simple php script on a round trip from the client. Any thoughts on this? I'm noob^infinity on OOP.
I think the best way would be storing in session key (like ID) to a table containing info necessary to create an object. Then query the info and create an object that will persist per each page.
I just tried google and here is an interesting thread
>sha2
I've never seen this hash, isn't it sha256?
My mistake, SHA2 is family not specific hasing algo. It should be sha256 or sha512
Hi ardav, thank you for the reply,...yes,you are right i went back to the function and i used the wrong table Thank you for helping me ardav, but after fixing there is another error
it says...Fatal error: Call to undefined function sha2() in C:\wamp\www\edit\edit.php on line 27
it's in my while loop,the $conf where should i put this
$conf = sha2("mysaltyhash" . $row['idno'] . "anothersaltyhash");
Thanks in advance...
There is no such function in PHP
$input = "mysaltyhash" . $row['idno'] . "anothersaltyhash";
$conf = hash('sha2', $input)
Thank you very much for your quick reply.
You are welcome and you can close the thread if it is solved!
<<Back|Track5 ruleeeez
BT5 as other BTs is mostly for PenTesters and Sec. persons
Oh yes, you need to have a valid SSL cerificate which means money!
To get an Idea, if you have FF6, checking at url box while visiting SSL sites will give you name of company that provided cerificate
So yes, you need to "donate" some $$$
just to add on what Ardav have sone, ask password and verify the user is authentic before any update/delete of data!
we doing it for you? How much bucks do you have for that? ;)
AFAIK, bare C++ wont do it!
Find specific library like OpenCV or the such. Wxwidgets have image manipulation functionality. But for small task it is an overkill. Or may be compile wxBase only library
You should just check if the file has the sizes you want, and if not, then the user should change the values on his own computer
This is perfect solution. That should be "policy". User should not upload files greater than you want them to :)
Mark it solved then :)
scrolling down you will find exact tutorial for rating system
http://phpacademy.org/videos/index.php?all
I opened the update manager to see whether there is an option for upgrading my system or not. There is an option for updating apps, not the system. So, this means that I'd have to upgrade manually(downloading the version I want and then installing it and so on..).
follow instructions in
http://www.ubuntu.com/download/ubuntu/upgrade
I've got ubuntu and win7
try Ubuntu classic and see if it runs well. May be your graphics cards cannot run unity. If that is the case, there is unity 2D
Just an update on my system at the moment, it does not take me to the desktop enviroment. But, I can access the ubuntu BIOS screen. OK, what happens when I start my laptop now is that it loads till the boot-loader screen then I choose ubuntu to run then the screen looks unpleasing. It seems to be messing around with my graphics card which apparently is not loading properly.
What can I do to solve this? Before this happens, I played around with boot loader manager ( changing background images and things)
What Os and desktop enviroment do you have?
Anyway, to install Gnome 3 via a ppa, this is what I used when I was trying it on Ubuntu 11.04: (official Gnome 3 ppa)
sudo add-apt-repository ppa:gnome3-team/gnome3
sudo apt-get update
sudo apt-get dist upgrade -f
sudo apt-get install gnome-shell
From a fresh install of Ubuntu, I'd recommend sorting out your connection problems, then use the update manager to get any important system updates before attempting to install Gnome3 from the ppa!
If you have natty and you execute the code in red, it will upgrade to Oneiric alpha. It almost did with my Installation and It is hard to revert!
Yea. It's working. But the same problem happen.
The code is working if i connect to my localhost server. However, once i changed to another server, it's now working. Instead of giving me an excel file, it displays all the result on the html page.
Did you change the file path too? I have not looked at the module though!
I got no param was present...
tried my suggestion?
O.k remove the apostrophe enclosing the "0", if the field is not char, varchar, text, etc.
mysql_query(" UPDATE table_name SET code_used= 0 WHERE param_code ='$submit' ", $con) or die (mysql_error());
In My Installation it makes no difference whether I use 0 or '0' in my TINYINT(1)
if(empty($_GET))
echo "<h2>The request is invalid</h2>";
else
$coupon_code = ($_GET[coupon]);
This will not check if specific field is empty. Since $_GET will always have submit button value so it will pass. Do something like this
if(empty($_GET['couponcode']))
echo "<h2>The request is invalid</h2>";
else
$coupon_code = ($_GET['couponcode']);
<input type="text" name="couponcode" disabled value="<? print_r ($coupon_code); ?>">
print_r is for arrays
http://www.daniweb.com/web-development/php/threads/372581/1603471#post1603471
But you did change some code removing htmspecialchar et al
I cannot see anything wrong with your code. please post two files contents (full) one with form and insert.php
This is shown on the webpage:
That means the only thing in POST is that one. Post your form code!
Is not printing it. Maybe i am doing it wrong:
if(isset($_POST['usecode'])) { $submit = $_POST['couponcode']; $sql = " UPDATE coupons SET coupon_used= '0' WHERE coupon_code = '$submit' "; print $submit; }
do this
print_r($_POST);
echo "<br />";
if(isset($_POST['usecode']))
{
$submit = $_POST['couponcode'];
$sql = " UPDATE coupons SET coupon_used= '0' WHERE coupon_code = '$submit' ";
echo $submit;
die()
}
well, the code as i posted it works if i change this line:
to
$sql = " UPDATE coupons SET coupon_used= '0' WHERE coupon_code = 'abc2qsaa' ";
where abc2qsaa is one of the codes in my database.
I have made the changes you suggested as well, but the database still doesn't get updated.
this information is useful. Now, print the value of $submit and hence whole $sql and post result
Hey, i updated the script. Still no changes to the database. I think there is something i am missing
What do you currently have?
I'm not that experienced in PHP to be perfectly honest, I know how to do quite a bit, but a lot of it I'm still learning. Maybe I'm going a bit out of my depth with this :/
If so then for now just use PHP include and put sections in php files
For the project I'm working on, it has to have a changeable template system, so the users can make their own HTML templates to work with the system. However, I have no clue how to even go about doing this. Any help would be appreciated, thanks.
I'm interested to see any other solution apart from templates and PHP include
I am using session variables, it is working on local but I run on server, it is not running. I am using Jquery
Where are you running PHP and How? WAMP? LAMP? MAMP?
Check JS libraries. They simplify AJAX calls to single or two functions.
there is JQuery, Scriptaculous, moo tools et al!
Please write shorthand with direct question!
<?php session_start(); if(!isset($_SESSION["username"])) { header('Location: login.php'); exit; } ?>
I have this code on the page I want to be password protected. Everything is working perfectly fine on Firefox, but in Internet Explorer it doesn't load the content of the page once the login information has been verified. Any suggestions? It can't really be my coding since it works fine with Firefox...
Thanks !!
1. Receive data from login form and clean them
2. Check if username is in DB and password hashes match
3. If it is top-secret, match other fingerprints
4. if matches, log them. If not redirect them
5. Protect page in case one uses direct url on browser!
I'm working on this project where they can search a list of names and they can put in a death year that automatically searches for + and - 5 years.
mysql_connect ("localhost", "root","root") or die (mysql_error()); mysql_select_db ("FHSNL"); $surname = $_POST['surname']; $given = $_POST['given']; $maiden = $_POST['maiden']; $deathbefore = $_POST['death'] - 5; $deathafter = $_POST['death'] + 5; $age = $_POST['age']; $birth = $_POST['birth']; $birthplace = $_POST['birthplace']; $deathplace = $_POST['deathplace']; $erected = $_POST['erected']; $region = $_POST['region']; if(isset($_POST['submit'])){ $sql = mysql_query("SELECT * FROM `HEADSTONES` WHERE `SURNAME` LIKE '%$surname%' AND `GIVEN` LIKE '%$given%' AND `MAIDEN` LIKE '%$maiden%' AND `AGE` LIKE '%$age%' AND `D_OF_BIRTH` LIKE '%$birth%' AND `PLACE_OF_DEATH` LIKE '%$deathplace%' AND `ERECTED_BY` LIKE '%$erected%' AND `PLACE_OF_BIRTH` LIKE '%$birthplace%' AND `Expr3` LIKE '%$region%' AND `YEAR_OF_DEATH` BETWEEN '$deathbefore' AND '$deathafter'");
I know the problem is that deathbefore and deathafter automatically go to -5 or +5 if no one enters a search term no results show but how do i fix this so all the results show if no search term is entered in that input box? Its probably a simple solution but my brain is fried right now.
Thanks for the help.
Put schema here so that it is easy to answer!