Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. post your recordExists() function. is it the same as the one I gave you? If you you can't use a string as the last parameter, as I have said. recordExists('firstname','firstname','users0001','metaldetect01') that /\/\ needs to look like recordExists('firstname','firstname','users0001',$someVar)
  2. if you want to affect multiple attributes I would suggest you preform the if statement before the output of the HTML, and store the attributes in variables. like if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') { $class = "alumni_tab_1_index"; $mouseOver="whatever'; $mouseOut = "whatever } else { $class = "default value"; etc. etc. } and in your html <div class="<?php echo $class; ?>" onMouseOver="this.className='<?php echo $mouseOver; ?>'" onMouseOut="this.className='a<?php echo $mouseOut; ?>'">alumni</div>
  3. first of all, when doing if statements, you signify an or clause by || not the world or if(recordExists('firstname','firstname','users0001','metaldetect01') || recordExists('lastname','lastname','users0001','metaldetect01') || recordExists('email','email','users0001','metaldetect01')){ and again, remember, you can't pass that string into the last parameter of that function like that. it has to be a variables. Im suprised you aren't getting boatloads of parse errors recordExists('firstname','firstname','users0001',$firstnameArray) calls to the function have to look like that. and your else if is kind of pointless, and is also incorrect. Again, you can't use the word or in if statements, and you haev to use the NOT boolean operator next to a function. just take out that entire clause and change it to just else.
  4. i dont quite understand, you want those to be tab1 when the same if statement above runs true. just put the ifstatement there <div class="<?php if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') {echo 'alumni_tab_1_index';} else { echo "default echo"; } ?>" onMouseOver="this.className='<? if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') {echo 'tab1';} else { echo "default echo"; ?> '" onMouseOut="this.className='<? if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') {echo 'tab1';} else { echo "default echo"; ?>'">alumni</div>
  5. are you sure you have the PHP mysql package installed on your server?
  6. haha When i wrote if(this) i meant your original of statement, not to actually wrap what you had with if(this) <div class="<?php if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') {echo 'alumni_tab_1_index';} else { echo "default echo"; } ?>" onMouseOver="this.className='alumni_tab_1_on_index'" onMouseOut="this.className='alumni_tab_1_index'">alumni</div>
  7. http://www.w3schools.com/PHP/php_arrays.asp
  8. hmmm. OK so let me see if I have this straight. You want this function to send allow the data sending if there is only 1 firstnam, lastname or email in the database. if there is more or zero you don't want it to send? Thats easy enough, just a slight change in the 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."'") or die(mysql_error()); if(mysql_num_rows($result) == 1) {//if we found exactly 1 record return true; }//end if row return false; } If you want it to return an array of the data back though, that will be a little harder. There are two options, you can, instead of sending boolean values back, send back a string that you test, or, which I think is the better way, pass an array by reference. the by reference way note you must pass a variable into the last parameter. function recordExists($id,$idval,$table,$array) {//check for id=idval in table and return TRUE or FALSE $array = null;//reset its value, and make it an array $array = array(); $result = mysql_query("SELECT * FROM ".$table." WHERE ".$id."='".$idval."'") or die(mysql_error()); if(mysql_num_rows($result) > 0) {//if we do have more than 0 results, aka they exist on the table if (mysql_num_rows != 1){//if there is more than 1 row, we want to create an array while($row = mysql_fetch_assoc($result)){ $array[] = $row;//this will push every row into the array, } } return true; } else { return false; } Now when you were to call that function you would do it like if(recordExists('firstname','firstname','users0001',$failedArray)){ and you could use $failedArray as if it was any other array. If that if statement were to run true you could use that array in the if statement, ala if(recordExists('firstname','firstname','users0001',$arr)){ echo "user: ".$firstname." already exists!"; if ($arr != null){//it will only not be null if there were more than 1 entry echo "The Array of the data: <br />"; print_r($arr); } }else{ $sql="INSERT INTO $tbl (firstName, lastName, email) VALUES ('".$_POST['firstname']."','".$_POST['lastname']."','".$_POST['email']."')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } } I didn't test this though, and there may be some syntactical/logical errors so let me know if it doesn't work
  9. this: $cars=ferrari enzo[1]; $cars=mini cooper[2]; is wrong, arrays don't work that way. look up a tutorial on PHP arrays. Honestly I would suggest you look up tutorials on a lot of things before you try to tackle this project, because based on the code you posted you don't even understand basic syntax rules
  10. if (this){ //original stuff } else { echo "default echo"; }
  11. wait you want your recordExists function to return multiple firstnames and stuff?
  12. ........ I'm sorry but you are completely incapable of explaining what you want. and no, you wouldn't need to do that
  13. in which part of that part. in the if part, or the else part? just make a function to return how many entries there are
  14. welll of course that doesn't echo anything. you have to enclose strings with quotes. echo "second"; is it still not echoing anything?
  15. Sorry I don't have MySQL set up on my localhost, im at my job and they use Oracle here. But what part of the code are you trying to see where there are multiple entries?
  16. you are already writing class, so no need to write it twice echo 'class="alumni_tab_1_index"' should be echo 'alumni_tab_1_index';
  17. ..... i understand the fact that you have multiple cars in your garage. I also understand you only want certain ones to be able to race. why can only certain cars race...
  18. firstly, the Request URI var of the server array returns the local path, not the full path. if (stripos($_SERVER['REQUEST_URI'],'/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') !== false) but why are you using stripos... you should be just comparing them because it seems like you only want to do this when this exact URL is gone to... if ($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2'){ which is what i posted before...
  19. that is all wrong... well not all wrong, but judging by what you wrote, this does not do nearly what you think it will. First from the first code "SELECT * FROM garage WHERE owner='$username' and damage='0' and car='ferrari enzo','ford mustang" this query is completely invalid. idk what you are trying to do with "car='ferrari enzo','ford mustang", but if you want to make it so it will pull out everything where the car is either an enzo or a stang, you have to do something like "SELECT * FROM garage WHERE owner='$username' and damage='0' and (car='ferrari enzo', OR car='ford mustang')" this script is just atrocious... <?php $cars=('ferrari enzo') $cars=('ford msutang') <select name="choose" id="choose" onChange="MM_jumpMenu('this',this,0)"> <option selected>Choose car</option> <?php $get=mysql_query("SELECT * FROM garage WHERE owner='$username' and damage='0' and car='$cars'"); while($it=mysql_fetch_object($get)){ echo "<option value=?car=$it->id>$it->car, $it->damage%</option>"; } ?> you can;t really do anything like you just did. You can't just type HTML inside of PHP tags without echoing them. You need semi colons at the end of stuff. and the following lines $cars=('ferrari enzo')//need semi colons $cars=('ford msutang')//semi colons are useless because it only stores one of the values (in this case, it stores ford mustang) it seems like you want to store them as an array. you do that by doing the following $cars = array('enzo', 'stang'); But you can't use an array inside a query like you seem to want to do. you would have to do something like mysql_query("SELECT * FROM garage WHERE owner='$username' and damage='0' and (car='".$cars[0]."', OR car='".$cars[1]."')"); but thats pretty much the same as the example I gave you above. and this still doesn't answer my question as to what constitutes a car as race able... Can only Enzo's and Mustang's race?
  20. $strWithSpace = "adhfaji dafhadkfh 899afd9afyh"; $newString = str_replace(" ", '', $strWithSpace); echo $newString;
  21. hmmm thats weird.. Try talking to the admins that run your server or something. Maybe you were blacklisted from every mail site ever, though I don't see that as being probable... Try sending a simple plain text email. or delete some of the headers. I'm pretty much at a loss at this point.
  22. What criteria makes a car able to race? PHP doesn't just a function that can tell if you can race a car.. you have to come up with the rules yourself. Is there a column in your database that tells if the car can race? a column that tells which types of races it can participate in. You are going to have to provide more information than "I want to show cars that can race"... That means absolutely nothing to me..
  23. oh... where do you want to call this class. whereever you want to call it, echo that in the HTML. its not that hard.. like <div class="<?php if (stripos($_SERVER['REQUEST_URI'],'id=1') !== false) {echo 'class="alumni_tab_1_on_index"';} ?>">
  24. The MYSQL link resource is the second, optional parameter when you do a mysql query. IE $go = mysql_query($query, $link); //the $link variable in your function it would be the last parameter you pass in. Mysql is looking for a link resource (that would be the $con variable that is used a lot of your specific script) but you supply it with a string. Either pass the $con variable, or remove the parameter, and don't pass the $con variable at all (You don't actually need to, since the query will take the current link resource and use that if none is provided.
  25. well if the mail function didn't run false, than it is indeed sending the mail. Perhaps check your spam folder, or double check the send to address to make sure everything's value is as expected However, I do not see anywhere in that code where you set the $email variable
×
×
  • 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.