Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

About mikesta707

  • Birthday 03/13/1990

Contact Methods

  • AIM
    mgarrido2

Profile Information

  • Gender
    Male
  • Location
    New York

mikesta707's Achievements

Member

Member (2/5)

2

Reputation

1

Community Answers

  1. Also, this isn't a free code forum. its a php help forum. If you need help with some code you are writing, then this place is perfect for you. However, if you want someone to give you code, there are plenty of forums for hiring freelance developers out there. I think there is even a subforum for that here.
  2. benanamen is right, but if you want us to help debug your php page, we kinda need to see the code. Otherwise there is no way for us to really help;
  3. You have to index that $phpObj variable like an array, not an object. IE do $phpObj['key'] not $phpObj->key
  4. Not sure exactly what your asking. If its for a sql query to search based on name and town it would be like SELECT Name, Town, Category FROM customer1 WHERE Name="something" OR Town="something" where something is your search term.
  5. try doing a vardump or print_r to see what exactly you are getting back. Also make sure to turn error reporting on to make sure you aren't getting any errors
  6. Seems like that function is scraping a page from freetvproject.so and returning an array with all the embed video html from that page, as well as other information. pretty sure the key part is this part: if ($embed){ $ret[$codes] = array(); $ret[$codes]['embed'] = $embed; $ret[$codes]['link'] = $link; $ret[$codes]['language'] = "ENG"; $codes++; } this kind of shows you the general format of the returned array. Hope this helps.
  7. the findOrFail method in laravel returns a model, not a string. You can't use str_replace on a model, that doesn't really make sense. You would want to do a str_replace on the name attribute of the game model IE $game = Game::findOrFail($id); $name = $game->name; $newname = str_replace("fword", "f***", $name); $game->name = $newname; $game->save(); without any context though, I'm not entirely sure this is what you want.
  8. Glad to hear it. You can make your topic as solved if your problem is resolved.
  9. Pretty sure it has to do with the following: if($_SESSION['userperson']==''){ header("Location:affiliate-login.php"); }else{ include("config-db.php"); $sql=$conn->prepare("SELECT * FROM affiliates WHERE id=?"); $sql->execute(array($_SESSION['userperson'])); while($r=$sql->fetch()){ ?> <?php $title = "Affiliate Profile - IT Done Right"; $pgDesc="IT Done Right are an Laptop repair company based in Pitsea covering Basildon, Laindon and more..."; $pgKeywords="laptop repair Pitsea, laptop repair Basildon, laptop repairs Pitsea, laptop repairs Basildon"; include ( 'includes/header.php' ); ?> <!--CONTENT--> <div id="column-whole"> <br /> <?php echo "<div class='home-content'>"; echo "<center><h2 class='welcome'>Hello, ".$r['username']."</h2>"; echo "<br><br>"; echo "<div style='float: left;'><a href='logout.php'>Log Out</a></div></center>"; echo "</div>"; echo "<br><br>"; } } ?> Instead of using $_SESSION['userperson'] shouldn't you be using $_GET['id']? I don't see anywhere in your code where you've even defined $_SESSION['userperson']; so your query should probably be like: //you should actually be checking if $_GET is empty instead of if its equal to the empty string. Also adding check for if its set if(empty($_GET['id']) || !isset($_GET['id']){ header("Location:affiliate-login.php"); }else{ include("config-db.php"); $sql=$conn->prepare("SELECT * FROM affiliates WHERE id=?"); //here you should be using $_GET['id'] rather than that session variable //also note security concerns detailed below $sql->execute(array($_GET['id'])); while($r=$sql->fetch()){ ?> ... Please note that you should sanitize you variables to make sure your code isn't vulnerable to any injections. Security concerns is out of the scope of this thread though, so I'll let you do some research on protecting your code from SQL injections and other security concerns on your own (or make a new thread about it if you want) Edit: As Barand said, there is no need for a while loop. I wasn't going to mention that as I figured it was best to focus on 1 problem at a time, but yeah you should fix that as well.
  10. Ah I see, so the ID isn't a page id, but rather an ID for the user. I wasn't aware of that. The reason that your ID is empty is most likely because your form's action attribute doesn't specify the ID. So naturally $_GET['id'] would be unset. What you probably need to do is grab the ID from the database once you verify that the username and password are indeed correct. IE instead of doing this: $id = $_GET['id']; //check data $sql = "SELECT * FROM affiliates WHERE username='$username' AND password ='$password' AND id = '$id'"; $result = $conn->query($sql); if ($result->num_rows > 0){ while($row = $result->fetch_assoc()) { $username = $row["username"]; //Store the name in the session $_SESSION['username'] = $username; header("location:affiliate-profile.php?id=$id"); } } you should do something like //$id = $_GET['id']; Can't do this, because you don't pass the ID through GET. You can't really, as you don't know the ID when the user logs in. //check data //Cant check the ID here either, as you don't know it yet $sql = "SELECT * FROM affiliates WHERE username='$username' AND password ='$password'"; $result = $conn->query($sql); if ($result->num_rows > 0){ while($row = $result->fetch_assoc()) { $username = $row["username"]; //Store the name in the session $_SESSION['username'] = $username; //You should be getting the ID HERE, as this is where you know who the User is. $id = $row['id']; header("location:affiliate-profile.php?id=$id"); } } This code is untested but from what I can tell, this is roughly what you want. Hope this helps
  11. Well, that error probably means that $_GET['id'] doesn't exist (assuming the line $id = $_GET['id']; is line 43). What does the URL for this page look like? Is it something like www.whatever.com/index.php?id=1 or something? Plus that doesn't really even make sense. You are trying to grab the id of the current page, and trying to redirect to that same id. Shouldn't you be redirecting to a different page? If you know the exact page you want to redirect to, and it will never change, why not just put the actual id of the page you want to redirect to, instead of using a variable. IE something like: header("location:affiliate-profile.php?id=11"); You are also probably getting wrong username/password because of your SQL statement here: $sql = "SELECT * FROM affiliates WHERE username='$username' AND password ='$password' AND id = '$id'"; You are basically saying where the username and password are correct, AND where the id is equal to the page id. This doesn't really make any sense, why would the user's row id be the same as the page id? I would just take that part out IE: $sql = "SELECT * FROM affiliates WHERE username='$username' AND password ='$password'"; Where is the $_GET['id'] even coming from. Do you store your page IDs in your database? How exactly do you handle your page includes/redirects? I don't see anywhere on that page where you even use the $_GET['id'] variable correctly to include a different page.
  12. Benanamen is right on the money, a lot of this code should be rewritten/updated to be more compliant with the current standards. You also have a lot of code that is basically doing the same exact thing in different places (different if statement blocks it seems) so you may be served by turning some of that code into functions, or better yet making some classes to handle some of this stuff. If you ever need to update how users are inserted, with this code it would be a nightmare because you have the insert statements for a user seemingly copy pasted at like 3 different places. I would also separate the code out a bit more, it seems you kind of through together all of the processing for a user into 1 file (like the code for registering a user, and checking if the user exists and stuff) As far as your error goes, its hard to tell since there is so much going on in this code, and not much else provided information wise, but my gut feeling is it has to do with your country list variable. What does that variable look like. Based on the context, it seems to be a list of different values. Can you post an example of what that data would look like (perhaps echo out the variable and put a die statement, and then copy paste what it outputs here.)
  13. Edit: Nevermind, you figured it out. However, its not redirecting to the right page probably because of this: header("location:affiliate-profile.php?id=?"); Why do you have a question mark there? Should that question mark instead be id=11?
  14. Another possible solution would be to, instead of storing the entire HTML line of code, you could just store the URL. IE instead of what you wrote, you would do: $sql = "INSERT INTO artist_table (pageLink) VALUES ('http://www.kennethkl...xanderoneal.php')"; Edit: Hmm, there seems to be some glitch that removes the rest of the text from a post after the first code bbcode block. Anyways: This has several advantages. For example, you could use this pageLink to build the HTML in PHP, which would allow you to customize the HTML more easily. You could add CSS classes, or change the link text much more easily than if you stored the raw HTML. For example: //get the row data however, assume it is stored in an associative array called $row $pageLink = $row['pageLink']; $artistName = $row['name'];//use the artist name for the link text, or use whatever else you want $link_html = "<a href='$pageLink' class='whatever classes you want'>$artistName</a>"; //now you can do whatever you want with the link html, for example simply echo it echo $link_html You could even add a column to your table so that the user can specify what the link text is (instead of using the artist name), and you could also add other attributes, like javascript events (onClick, onMouseOver, etc.)
  15. Not sure exactly why you were getting that error. I did the following and it finally worked: class adder: result = 0 def __init__(self, number1, number2): #self.result = int( number1 ) + int( number2 ) self.number1 = number1 self.number2 = number2 def giveResult(self): #return str(self.result) return str(self.number1 + self.number2) endIt = False while ( endIt == False ): print ("Please input two intergers you wish to add: ") number1 = input( "Enter the first number: " ) number2 = input( "Enter the second number: " ) print (number1) print (number2) try: thistime=adder(int(number1),int(number2)) except NameError as e: print ("Some error", e) print ("Sorry, one of your values was not a valid integer.") continue print ("Your result is: " + thistime.giveResult()) goagain = input( "Do you want to eXit or go again? ('X' to eXit, anything else to continue): " ) if ( goagain == "x" or goagain == "X" ): endIt = True Edit: weird, all the other text I wrote seems to have disappeared. The gist was I used these lines to help narrow down the issue: except NameError as e: print ("Some error", e) print ("Sorry, one of your values was not a valid integer.") continue doing Except NameError as e helped since I could print e and see why exactly you were getting the NameError exception. I also had to use input rather than raw_input since I am probably using a different version of Python than you are (I am using 3.4.2, you are probably using an older version) These lines also weren't indented right print ("Sorry, one of your values was not a valid integer.") continue If you weren't getting the exception, those two lines would ALWAYS run, resulting in you never getting the actual result of the two numbers. I also had to convert your result into a string in your giveResult method like so: return str(self.number1 + self.number2) Hope this helps
×
×
  • 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.