PHP - Noobie Question But Help Please
I have a script that uploads pictures to a folder. I used mkdir to create this folder and sub folders.
Do I need to chmod folders and files, do i need to do this to my other html, php and image files. I am completetly confused who is the owners group etc thanks Similar TutorialsWhy oh why does this not work?
<?php
if (preg_match("[0-9]", "2")) { Hi all i bet this is going to be obvious, but I ran out of ideas. I have the following script but it's not inserting. I gave the user database specific insert update and select rights but something is not working. maybe someone could help me out. $dbc = mysqli_connect('localhost','slave','password','mydatabase') or die ('error connecting to mysql server'); //display stuff $query = "SELECT * FROM mydatabase"; $result = mysqli_query($dbc, $query); while($row = mysqli_fetch_array($result)) { echo 'id: '.$row['ID']. ' and firstname is: '.$row['firstname']. ' and lastname is: '.$row['lastname'].'<br />'; } //insert stuff $query = "INSERT INTO `mydatabase`.`users` (`firstname`, `lastname`) VALUES ('john', 'doe')"; $result = mysqli_query($dbc, $query); mysqli_close($dbc); -edit ok i think i fixed it, i tried the root user and it worked. gave the slave user more rights. apperently besides database specific i ahve to give the slave user global insert update and select rights too. Can someone confirm that? Hi, I'm a learning PHP developer, and I'm trying to work out how to connect and use an API provided by my goverment to the public. I have no idea how to set it up and test it, and I'm having a really hard time finding any help online.
The documentation mentions using a "simple" cURL request but I have no idea how that works either, and I would like ideally to be able to pull the data and turn into an SQL database where I know how things work a little bit better within PHP.
Many thankss when in a form, I wish to build a conditional that if the response to a radio button is a value of 2 (female), it will display an input requesting for users maiden name. If not 2 goes to the next input statement. Here is code I was experimenting with: <html> <body> <form action="" name="test" method='POST'> <input type="radio" id="sex" value=1 checked><label>Male</label> <input type="radio" id="sex" value=2><label>Femaleale</label> <?php $result = "value"; if ($result == 2) echo "<input type='int' id='gradYear' size='3' required>"; else echo "Not a female!" ?> <input type="submit" value="GO"> </form> </body> </html> The code passes debug, however, Not a Female is displayed. My question is - Can I do this and if so, what value do I test against id='sex' or value. I tried each one but gave the same results. I realize that $_POST[sex] would be used after the submit button is clicked. But this has me stumped. Thanks for the assis in advance. Major breakthrough. utf8_encode() allows me to view utf-8 characters in the browser. Therefore, my source data file must be ISO-8859-1 encoded text, right? Am I understanding this correctly?
<?php //mb_internal_encoding("UTF-8"); header('Content-type: text/html; charset=utf-8'); $file = fopen('some_csv_file_created_by_excel.csv', "r"); ob_start(); while (($spec = fgetcsv($file, 100000, ",")) !== FALSE){ echo($spec[0].' '.utf8_encode($spec[0]).'<br>'); } $string=ob_get_clean(); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>utf</title> </head> <body> <p><?php echo($string);?></p> </body> </html> Edited by NotionCommotion, 11 January 2015 - 08:22 PM. I am trying something simple, creating some horses and making them race using OOP, creating them is easy, how can i find out which one "won" based on the highest total. Here is what i got so far Code: [Select] <?php class Horse { public $strength; public $speed; public $agility; public function create($name,$age,$odds){ $this->name=$name; $this->odds=$odds; $this->strength=(rand(50,200) * $this->odds - $this->age); $this->speed=(rand(100,400) * $this->odds - $this->age); $this->agility=(rand(150,250) * $this->odds - $this->age); $all=array(0=>"$this->strength",1=>"$this->speed",2=>"$this->agility"); echo "<b>$this->name</b> has a strength of <b>$this->strength</b>, a speed of <b>$this->speed</b> and agility at <b>$this->agility</b>. --- <b>".array_sum($all)."</b><br>"; } } $mix=rand(2,6); $a=new Horse; $a->create("Dave", 2, $mix); $a->create("Dude", 3, $mix); $a->create("Evan", 3, $mix); $a->create("Jill", 15, $mix); $a->create("Flex", 10, $mix); ?> I cant figure out a way to find out who had the highest total, i would love to know what i am doing wrong. hi, im trying to say if field ARTIST = Eminem then do the following. here is my current code Code: [Select] $hmm = simplexml_load_file('http://localhost/1.0/?method=player.getPlayQueue'); foreach($hmm->tracks->track as $tracks) { $artist = $tracks->artist; $title = $tracks->title; $album = $tracks->album; $index = $tracks->index; $id = $tracks->id; //If we submitted the form if('.$artist.'="eminem") { echo '<table border="0" width="70%" align="center">'; echo '<tr>'; i just need to know how to do the if(***) part. thanks. i am trying to understand, how a site like ebay can display content and be case insensitive? for example: The original url: http://www.ebay.co.uk/itm/Toshiba-Satellite-C50-AMD-E-Series-1-4GHz-Dual-Core-15-6-Inch-500GB-2GB-Laptop/151458954958the above works fine and go to the intended page. user editing the browser url into lowercase : http://www.ebay.co.uk/itm/toshiba-satellite-c50-amd-e-series-1-4ghz-dual-core-15-6-inch-500gb-2GB-laptop/151458954958random uppercase and lowercase. http://www.ebay.co.uk/itm/toshiba-sateLLite-c50-aMd-e-sERIes-1-4ghz-dual-core-15-6-inch-500gb-2GB-laptop/151458954958both the urls above also work fine and go to the intended page. How can such a thing can work? it is supposed to throw an error such as page not found and the like? any thoughts welcome. Sorry for the really, really basic CSS question. (I'm asking this in the PHP forum, because so far, you've all been nice to me and haven't made fun of some of my really dumb questions.)
I am trying to make it so that it will load if the site if the site is online(EG. $siteonline = 1), and so on. I can't seem to think of how I could do this so it will work from the very top of the page's html, to the very bottom. Like the following code is meant to list all of the stuff in that database. <?php $list_q = mysql_query("SELECT * FROM settings") or die (mysql_error()); while($list_f = mysql_fetch_assoc($list_q)) { } ?> I have my page laid out like this.. <?php include "includes/connect.php"; include "includes/config.php"; ?> <?php $list_q = mysql_query("SELECT * FROM settings") or die (mysql_error()); while($list_f = mysql_fetch_assoc($list_q)) { ?> Html content etc.. <?php } include 'includes/footer.php'; ?> But if I do it that way, It only displays what is in footer.php. I have been away from PHP for a long time and I was looking over my old scripts. I did PHP OOP at one time and I used a paticular method to connect all my methods up and load them. I have been looking at other peoples code and when I look at my code it does not even feel like OOP, I want to know how to you link all the methods (or is it called functions?) in a class up and return them? I use to do this: Code: [Select] <?php class quickFUNC { function note_pad() { // code for notepad } function quickAdminFunc() { // code for admin func $this->note_pad(); } } $quickFUNC = new quickFUNC; if(isset($_GET['id'])) { $act = $_GET['id']; } else { $act = NULL; } switch ($act) { case 1: //some random code to launch case 1 break; default: $quickFUNC ->quickAdminFunc(); ?> This was my code back in the days, as you can see the notepad was called in the admin function then made the admin function default in the case switch. I looked at all my script and the all are layed out like this :S.. Can I get some help please, thank you. hi php people, I am wondering will if the code below will work when I call $C->getafoo() will I get foo; I keep getting an error at this point return $this->A->a(); saying the method is not there Code: [Select] class A{ public function a(){ return "foo"; } } class B { public $A; function __construct($A) { $this->A = $A; } public function geta(){ return $this->A->a(); } } class C extends B{ public function getafoo(){ return geta(); } } $C = new C(new A()); echo $C->getafoo(); Hi to all people, I just want to know if there a php script I can use using DRM. The scenario, once the user download the song from a website, he/she can't forward into other using bluetooth or file transfer. It is possible to do that scenario? Thanks in advance I am trying to make my database search only search where private = '$priiv'(Usually 0,1, or 2) but it does not work Code: [Select] $query_search = "SELECT * FROM users WHERE username LIKE '%$idea%' OR fname LIKE '%$idea%' OR lname LIKE '%$idea%' OR tags LIKE '%$idea%' AND private = '$priiv'"; What am i doing wrong? Hello, i am currently working on a project and i have been on google and nothing has helped i am trying to detect characters in the URL so for example XSS if someone typed in the URL:
home.php?=<script>document.cookie();</script> OR home.php?=<?php echo file_get_contents("document.txt", "a");How would i be able to make a kind of firewall to detect this? and if it does then redirect to another page. Thanks. Just get started with OO in PHP. If I create an object while on one page and then call another page, can I still access that first object, or is it destroyed when the second page is called? For example, if I have on page1.php: Code: [Select] $obj = new $MyObject(); and then call page2.php, is it possible to still access $obj while on that page? I'm trying to secure my login system as much as possible from SQL injections and other attacks. I know that by using mysql_real_escape_string() you can prevent that and I'm using that on for example the username input, but I would like to know if you hash the password before you send it to the database with MD5, do you still need to use mysql_real_escape_string()? A very quick and simple example: Code: [Select] <?php $un = $_POST['username']; $pass = $_POST['password']; $pass = md5($pass); mysql_query("SELECT * FROM users WHERE password='$pass' AND username='$un'"); ?> If someone wrote a possible SQL query in the password input, wouldn't that be rendered useless as the md5 will hash it before sending it and therefor "hide" it? Or is there any other reason you wouldn't want people to use sertain characters/symbols in their passwords? Hi, I am looking into a way of adding addons to a class I made.. I thought something like this would work, but not sure how to implement it: Code: [Select] <?php class foo { function foobar($text) { $text = $text . 'b'; return $text; } } class bar extends foo { function foobar($text) { $text = $text . 'c'; return $text; } } $var = new bar(); $var->foobar('a'); // this would then return abc ?> Now i want to be able to call up foo, and it calls the foobar of foo, and the foobar of bar. is that possible? hosh In php, which function is best used to act something like the sql "LIKE" command? and how would that function be used like? Code: [Select] <?php if ($News_1_Status=="Y") echo <div class="newstitle" align="left"><?php echo $News_1_Date;?> <a href="<?php echo $News_1_URL;?>"><?php echo $News_1_Name;?></a></div><br>; else echo "Have a nice day!"; ?> how do i get the above script working any clue? |