-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
[SOLVED] shouldnt the echo produce the results
mikesta707 replied to bigbenbuilders's topic in PHP Coding Help
well... just remove the backslashes and its fine... <?php if (stripos($_SERVER['REQUEST_URI'],'id=1') !== false) {echo 'class="alumni_tab_1_on_index"';} ?> just tested on my server. went to: http://localhost/text.php?id=1&poop=3 and it echoed what it was supposed to. IDK why you had those backslashes in there -
whats happening when you run this? does the error message pop up? btw this line "X-Priority: 1 (Higuest)\n"; what I'd assume is the word highest is spelled wrong. IDK if that would screw things up but you probably want to have that spelled right
-
I dont think so without changing the code of the actual page if you are simply posting a form to their page. Maybe with cURL but I honestly know nothing about cURL so I could be making things up
-
Need help with checking value in database..
mikesta707 replied to DarkShadowWing's topic in PHP Coding Help
im not going to count the lines... which line is line 40? I'm going to take a guess and say its this one? if (!mysql_query($sql,$con)) Since you only create the query if the if statement here if(recordExists('firstname','lastname','users0001','metaldetect01') or die(mysql_error())){ runs false, at least half the time this script runs you $sql string isn't being create. you are going to have to check if the the $sql exists, then try to run the query, or just have the sql created everytime. Or you can just put that check inside the else statement, ala else{ $sql="INSERT INTO $tbl (firstName, lastName, email) VALUES ('".$_POST['firstname']."','".$_POST['lastname']."','".$_POST['email']."')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } } but you are going to have to change it because that logic currently is all wrong also if(recordExists('firstname','lastname','users0001','metaldetect01') or die(mysql_error())){ is wrong. you can't, and shouldn't stick an or die() clause an if statement like that (well you can, but you shouldn't. You should put it where the mysql query is taking place, which is inside the function) oh and in your function function recordExists($id,$idval,$table,$db) {//check for id=idval in table and return TRUE or FALSE $result = mysql_query("SELECT * FROM ".$table." WHERE ".$id."='".$idval."'", $db) or die(mysql_error()); if($row = mysql_fetch_array($result)) {//if we did return a record return true; }//end if row return false; } you may want to use mysql_affected_rows instead of fetching an array. You may run into unexpected problems if(mysql_affected_rows($result) > 0) {//if we did return a record return true; -
[SOLVED] shouldnt the echo produce the results
mikesta707 replied to bigbenbuilders's topic in PHP Coding Help
I'm not entirely sure what you are saying, but I'm assuming you want to echo something if your URL is something. why dont you do if ($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category§ionid=1&id=1&Itemid=2') { echo '"selected"'; } ?? -
Need help with checking value in database..
mikesta707 replied to DarkShadowWing's topic in PHP Coding Help
a bunch of things. firstly this query is invalid $sql="INSERT INTO $tbl (firstName, lastName, email) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[email]')"; } should be $sql="INSERT INTO $tbl (firstName, lastName, email) VALUES ('".$_POST['firstname']."','".$_POST['lastname']."','".$_POST['email']."')"; } secondly, this if(mysql_query(recordExists('firstname','firstname',$tbl,$dbname), $con)){ makes no sense. the recordExists function already does a mysql query, and will return true or false. You want to just do if(recordExists('firstname','firstname',$tbl,$dbname)){ oh and instead of returning 0 or 1 in your function, return true of false -
your code works on my test server (Well excluding name2 but in your string its "name 2" gotta delete the space)
-
If you have ever used to Facebook API, you would be able to see why you would never want to use anything but a class for that (at least the PHP API) If you want to see OOP in action, make a facebook APP. You won't really be doing OOP, but you will be using a class, and once you start using a class you begin to see why in certain instances classes are better, and why, if the folks at Facebook had took a procedural, rather an an OO approach, the API would not have been nearly as powerful, and wouldn't be nearly as easy to add functionality to it BTW you can include class files. In fact, including files doesn't really have anything to do with OOP or Procedural programming, its just using a group of functions/variables from a different file. In the case of OOP however, those functions/variables are all wrapped inside a class. When you want to make changes to a site, or add functionality, usually it is much easier with classes. For example, say I have a class I use in a bunch of different scripts. For example, I built a class that outputs data from a query, and it allows you to filter through the data, sort it, etc. If I used a procedural approach, not only would I be repeating a crap load of different code on every page, but if I wanted to add certain functionality to every page, I would have to edit every page seperately. With an OOP approach, I could just edit my class, and now every page has that functionality. Now say I wanted certain pages to have said functionality, but other pages have a slightly different functionality. Again, with an OOP approach, this would be alot easier.
-
well for one I couldn't register... It refused to let me. So you should probably fix that
-
I think these are the wrong forums. there are ones for testing your scripts somewhere so... inb4 moved. but sure ill help you out
-
just set a specific width for the element that has the text. it should word wrap then. if you need further help, consult this tutorial: http://www.w3schools.com/css/
-
If its an integer column (which it better be if you are doing math on it) then you cannot encase the value with single quotes if ($moneybutton) { $newamount = $money + (rand(2,10)); mysql_query("UPDATE Login SET money = $newamount WHERE username LIKE '$username'"); }
-
did you try doing a print_r on the cookie array?
-
Oh ok, well I don't really use cookies ever, but I've always seen them done that way. Upon looking at the PHP.net page for cookies, yes you do need to surround them with quotes. Perhaps you cookie creation page isn't actually creating any cookies, or creating them in a way you don't expect, and thats what is causing them to not delete. http://us.php.net/setcookie try echoing all your cookies via print_r($_COOKIE);
-
[SOLVED] Problem extracting data from Database
mikesta707 replied to The.Pr0fess0r's topic in PHP Coding Help
you must enclose strings with single quotes $query = "SELECT * FROM hunt_info WHERE huntStatus = $key AND username = '$username' ORDER BY date_of_hunt DESC"; -
when you create a cookie, i believe the cookie's name has to be enclosed in quotes setcookie("pid", $totalPid, time()+3600*24);
-
change password for profile page. working but not? help please
mikesta707 replied to blesseld's topic in PHP Coding Help
looks fine to me.. does it work? -
yeah do what ignace said. much better solution.
-
There is probably an easier way to do this, but the way I would do it if I was confronted with this problem would be too loop through the results, and assign keep pushing the data from each individual row into an array for the full column. so for example $SQL = "SELECT col1, col2, col3, col4 FROM table WHERE Criteria"; $execute = mysql_query($SQL); $col1 = array(); $col2 = array(); //etc/ while($row = mysql_fetch_assoc($execute)){ $col1[] = $row['col1']; $col2{} = $row['col2']; //etc. } //now I iterate through each individual array echo "<h2>COL 1 Jobs</h2>"; foreach($col1 as $jobs){ echo $jobs."<br />"; } //etc.
-
Oh... well of course its blank you don't output anything in your second script (which i assume is a.php) if you want to see some output output something. like echo a finished message at the end or something
-
so there is a blank page? try clicking view source to make sure there isn't an error being posted there
-
there is probably an API call to do exactly what you want, as opposed to using cURL, but since I have never used the twitter API, I can only offer you a link to their wiki http://apiwiki.twitter.com/Tutorials hope that helps
-
its "good practice" to always sanitize things, but I admit I get lazy and don't bother sanitizing things that are hardcoded in.
-
you are going to have to use relative file paths, as more than likely your allow_url_fopen setting is set to off (this setting tells whether or not full URLS are allows) This is set to off by default because of a security risk. You can read more about it here: http://www.learnphponline.com/errors/url-file-access-is-disabled-in-the-server-configuration Depending on where the file that includes you other file is, you should be able to just put the relative path. IE include("myfolder/to/my/file.ext")