Jump to content

EricOnAdventure

Members
  • Posts

    80
  • Joined

  • Last visited

Posts posted by EricOnAdventure

  1. Thanks Quick Old Car, but I still have a small problem. I took what you gave me, tested it on the array and it worked perfectly. Then I tried to apply everything to my database and that is where I am getting an issue.

     

    The only problem seems to be "Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\efun\unisearch\test.php on line 53"

     

    How am I doing it wrong?

     

    Thanks!

    <?php
    session_start(); 
    include("config.php");
    function showColor($number){
    	if($number == 1) {
    		$color = "red";
    		$word = "Low";
    	}
    		if($number == 2) {
    		$color = "green";
    		$word = "Midium";
    	}
    		if($number == 3) {
    		$color = "blue";
    		$word = "High";
    	}
    			if($number == 4) {
    		$color = "orange";
    		$word = "Very High";
    	}
    		if($number == 5) {
    		$color = "violet";
    		$word = "Extreamly High!";
    	}
    	return "<p style='color:$color';>$word</p>";
    }
    
    
    	$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE id>0 LIMIT 10";
    	
    $sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
    if (mysql_num_rows($sql_result)>0) {
    	while ($row = mysql_fetch_assoc($sql_result)) {
    		
    	$Scholerships=$row["Scholerships"];
    	
    	
    
    
    ?>
    
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Show color</title>
    </head>
    
    <body>
    	<td width="191" bgcolor="#CCCCCC"><strong>Scholerships color</strong></td>
    		<td width="191" bgcolor="#CCCCCC"><strong>Scholerships no color</strong></td>
    <div>
    <td><?php foreach($Scholerships as $thecolor)
    	{echo showColor($thecolor);}?></td>
    	<td><?php echo $row["Scholerships"]; ?></td>
    </div>
    
    </body>
    
    </html>
    <?php
    }}else
    {echo 'fail';} 
    ?>
    
  2. Well my SQL is outputting a list for me, lets say they are colors. If I want "red" to be output as not only the word red, but also the color red, how should I do that. I tried with Str replace, but and changing the mySQL, in both cases I just got <font color="red">This is some text!</font> - the html didn't show but became like text. Any Idea?

  3. I am using PHP to generate and echo a list form mySQl database. If I get the result "red", I would like to turn it red. Would I just be able to use str replace to replace the text with HTML coding?
     Or is there a better way?

  4. MaC_Gyver

    Great info, the Mysqli report mode helps but I still ran into an issue.  My new problem is this:

     

    Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'Unknown column 'STUDENTEMAIL' in 'field list'' in C:\xampp\htdocs\efun\signupv.php:80 Stack trace: #0 C:\xampp\htdocs\efun\signupv.php(80): mysqli_query(Object(mysqli), 'SELECT STUDENTE...') #1 {main} thrown in C:\xampp\htdocs\efun\signupv.php on line 80

     

    The problem is in the line

    $sql="SELECT STUDENTEMAIL FROM mylogin WHERE STUDENTEMAIL='$STUDENTEMAIL'";

    I'm not sure if I am doing this right, or why else the error might exist.

    As for your questions,

    1. Before you sent me the error reporting code I only knew it was failing because of the echo fail at the bottom.

    2. error reporting is on for PHP, by default.
     

  5. So - after 48 hours transpire, who is going to see this new page you send with the form data and where is it going to show up?

    Well the form is in a member section so only the member.

     

    When you save the data to the database, also include a column set to the current time. Then when you display data, only display data that was added <= NOW() - 48 hours

    I tried this idea but I ran into a wall, any ideas?

     

     

    <?php
    
    $submittime = 1;
    
    $displaytime = $submittime + 172800; // 2 days
    if 	(time() >=	$displaytime) {echo 'yes'}
    
    echo $submittime;
    echo $displaytime;
    echo time();
    
    ?>
    
  6. Hey Ginerjm,

    To be more exact my code takes the form data and uses another rather large auto-writing script to write a document. The output file, is html formatted text that is about 500 words long. So the columns are set to 5000 characters just to be safe. While I can have this text display perfectly well on another page instantly, my goal is to have it displayed in 48 hours...because I would rather not have the person who filled out the form know the letter was automatically generated.

  7. I have some rather complex forms that output into a mySQL database. Right now all of the results are placed in the database along with html formatting. Yes that means the columns are huge but I can't find a better way to do it right now without spending a few days writing code. I want the results to show up on another page 48 hours after they are created. Any idea how I might do this?

     

     

     

     

  8. Ok, I did as you said and learned my_sqli, and changed my code, lots of hard work and I still ran into a problem. The $query fails...any idea?

    <?php
    	
    
    $code =filter_var($_POST['code'], FILTER_SANITIZE_SPECIAL_CHARS);
    session_start(); 
    
    if( $code!=$_SESSION['code'] )
    {
    		$_SESSION['signup'] = "Your Captcha wasn't correct. ";
    		header("location: signup.php");	
    }
    ////////////
    require_once 'dbstart.php';
    ////////////
    if (isset($_POST['GIVENNAME'])){
        if (empty($_POST['GIVENNAME'])
    	|| empty($_POST['FAMILYNAME'])
    	|| empty($_POST['STUDENTTITLE'])
    	|| empty($_POST['STUDENTEMAIL'])
    	|| empty($_POST['PAYMENT'])
    	|| empty($_POST['DEGREETYPE'])
    	|| empty($_POST['USERNAME'])
    	|| empty($_POST['PASSWORD'])){
            
    
    		$_SESSION['signup'] = "Mandatory field(s) are missing, Please fill it again";
    
    		header("location: signup.php");
        
    }
    ////////////////
    		$GIVENNAME = $_POST["GIVENNAME"];
    		$FAMILYNAME = $_POST["FAMILYNAME"];
    		$STUDENTTITLE = $_POST["STUDENTTITLE"];
    		$STUDENTEMAIL = $_POST["STUDENTEMAIL"];
    		$PAYMENT = $_POST["PAYMENT"];
    		$USERNAME = $_POST["USERNAME"];
    		$PASSWORD = $_POST["PASSWORD"];
    		$DEGREETYPE = $_POST["DEGREETYPE"];
    		$STUDENTWECHAT = $_POST["STUDENTWECHAT"];
    		
    		$GIVENNAME = mysqli_real_escape_string($db, $GIVENNAME);
    		$FAMILYNAME = mysqli_real_escape_string($db, $FAMILYNAME);
    		$STUDENTTITLE = mysqli_real_escape_string($db, $STUDENTTITLE);
    		$STUDENTEMAIL = mysqli_real_escape_string($db, $STUDENTEMAIL);
    		$PAYMENT = mysqli_real_escape_string($db, $PAYMENT);
    		$USERNAME = mysqli_real_escape_string($db, $USERNAME);
    		$PASSWORD = mysqli_real_escape_string($db, $PASSWORD);
    		$PASSWORD = md5($PASSWORD);
    		$DEGREETYPE = mysqli_real_escape_string($db, $DEGREETYPE);
    		$STUDENTWECHAT = mysqli_real_escape_string($db, $STUDENTWECHAT);
    
    		/////email check
    		$sql="SELECT STUDENTEMAIL FROM mylogin WHERE STUDENTEMAIL='$STUDENTEMAIL'";
    		$result=mysqli_query($db,$sql);
    		$row=mysqli_fetch_array($result,MYSQLI_ASSOC);
    		if(mysqli_num_rows($result) == 1)
    		{
    		$_SESSION['signup'] = "Email already in use, try again. ";
    		header("location: signup.php");
    		}
    		///////usercheck
    		$sql2="SELECT USERNAME FROM mylogin WHERE USERNAME='$USERNAME'";
    		$result2=mysqli_query($db,$sql2);
    		$row2=mysqli_fetch_array($result2,MYSQLI_ASSOC);
    		if(mysqli_num_rows($result2) == 1)
    		{
    		$_SESSION['signup'] = "Username already in use, try again. ";
    		header("location: signup.php");
    		}	
    		else
    		{
    			$query = mysqli_query($db, "INSERT INTO mylogin 
    (GIVENNAME, FAMILYNAME, STUDENTTITLE, STUDENTEMAIL, STUDENTWECHAT, PAYMENT, USERNAME, PASSWORD)
    VALUES 
    ('$GIVENNAME', '$FAMILYNAME','$STUDENTTITLE','$STUDENTEMAIL','$STUDENTWECHAT','$PAYMENT','$USERNAME','$PASSWORD')
    ");
    
    			if($query)
    			{
    				        $_SESSION['post']['PAYMENT'] = $PAYMENT;
    						header("location: payment.php"); 
    			}
    			else 
    			{
    			$_SESSION['signup'] = "Something failed, please try again. ";
    			//header("location: signup.php"); 
    			echo 'failed';
    			}	
    		}
    	}
    
    ?>
    
    
    	
    
    	
    
  9. This is my login page, and as you can see I am trying to make sure people are logged in, and have paid. but I am getting nothing from my mysql_fetch_array lines related to payment and givenname. Any advice?

    <?php
        
    $studentname =filter_var($_POST['Username'], FILTER_SANITIZE_SPECIAL_CHARS);
    $psw =filter_var($_POST['Password'], FILTER_SANITIZE_SPECIAL_CHARS);
    session_start();
    require_once 'dbstart.php';
    require_once 'functionhome.php';
    
    $link  =  mysql_connect ( $servername ,  $username ,  $password )
        or die( 'Could not connect: '  .  mysql_error ());
    
     mysql_select_db ( $dbname ) or die( 'Could not select database' );
    
    
     $query  =  "SELECT * FROM $mylogin where
     studentname='$studentname'
     and psw='$psw'
      " ;
     $result  =  mysql_query ( $query ) or die( 'Query failed: '  .  mysql_error ());
    
     if ( $line  =  mysql_fetch_array ( $result ,  MYSQL_ASSOC )) {
      $res=true;
     
      if (!isset(mysql_fetch_array($result, MYSQL_ASSOC)['payment'])){
              $_SESSION['login'] = "Payment has not yet been confirmed. If you have paid and you are still getting this message please wait 24 hours. If you are still getting this message please <a href='contact.html'>Contact Us</a>. ";
            header("location: login.php");
      }
     
       
    $GIVENNAME = mysql_fetch_array($result, MYSQL_ASSOC)['givenname'];
     
     
    $_SESSION['post']['GIVENNAME'] = capitalize($GIVENNAME);
              //header("location: members.php");
            echo $GIVENNAME;
            echo $_SESSION['post']['GIVENNAME'];
    echo "<pre>". print_r(mysql_fetch_array). "</pre>";
     
     
     
     }else {
        $res=false;
            
            $_SESSION['login'] = "Error, Username or Password incorrect, try again. ";
            header("location: login.php");
    }
    
     mysql_free_result ( $result );
    
     mysql_close ( $link );    
     
     
    
  10. I am trying to use PHP to insert $variables into SQL with INSERT INTO.

    I am pretty sure I am doing it wrong, after all, even this little sample I created is failing, any ideas?

     

     

    DATABASE: (which worked without a hitch)

    CREATE TABLE `inputtest` (
    `id` int(4) NOT NULL auto_increment,
    `GIVENNAME` varchar(50) NOT NULL default '', 
    `FAMILYNAME` varchar(50) NOT NULL default '', 
    `StudentTitle` varchar(50) NOT NULL default '', 
    `EMAIL` varchar(50) NOT NULL default '', 
    `PHONE` varchar(50) NOT NULL default '', 
    PRIMARY KEY (`id`)
    ) 
    

    The first page that is loaded is a default page which sets all $variables to '', that way I don't end up with 300 if statements.

    $GIVENNAME = '';
    $FAMILYNAME = '';
    $StudentTitle = '';
    $EMAIL = '';
    $PHONE = '';
    

    Then comes the page that takes the Session posts, if set, and turns them into $variables

    Finally I input the $variables with the following:

    mysql_connect("localhost", "root", "")or die("cannot connect");
    mysql_select_db("ericgonzp")or die("cannot select DB");
    
    	
    $query = 	"INSERT INTO ericgonzp.inputtest(
    GIVENNAME,FAMILYNAME,StudentTitle,EMAIL,PHONE,
    )VALUES(
    '$GIVENNAME','$FAMILYNAME','$StudentTitle','$EMAIL','$PHONE',
    )"; 
                               
    
    					   
    $result=mysql_query($query);
    
    echo $result;
    
    
    if($result){
    }
    
    else {
    echo "DATABASE ERROR";
    }
    ?>
    
    <?php
    // close connection
    mysql_close();
    ?>
    
    
    

    The page displays DATABASE ERROR....

  11. I am creating an automatic English Resume writing program for non-Native English speakers and all has went well so far, but some people simply don't understand that the resume should be reverse chronological so i need to sort the jobs by year.

     

    Each job looks something like this

     

    $JOBDISPLAY10a= "<div><div class='colleft'>". $Jobtitle10a.", ". $Company10a.", ". $Jobcountry10a.
    "</div><div class='colright'>". $JOBSTART10a." - ".$JOBFINISH10a."</div></div>".
    $jobdutyfull10a. "<br>";

     

    I then

    echo $JOBDISPLAY10a

    echo $JOBDISPLAY11a

    ect.

    I know that this is pretty good foundation to sort the jobs but I am unsure of how to sort the echo $JOBDISPLAYX variables by the $JOBFINISHX variables, especially since $JOBFINISHX could = Present. What makes this even tougher is that multiple jobs may be listed as "present" Meaning that I would have to order them, and only them, with $JOBSTARTX.

    I've tried various approaches but I cannot get it to function in a reverse chronological sense with Present at the top. Any ideas?

    Thanks

    -Eric

  12. Hey all, I can't figure this out,
    using HTML how can I have a single line display strings that are left and right aligned...here is an output example:
    ----------------------------------------------
    |Hello                                        world|

    ----------------------------------------------
     

    Thanks

  13. Thanks for all your help Psycho, but it still doesn't "require" the year if "no" is selected. Any more ideas or advice you can give on how to solve this? I am pretty new to jquery so i have no idea. I can do validation on the next page with PhP, but if I could get it to be done on this page that would be a lot better.

    Thanks

  14. Option 2 was a great idea and the best based on how the form is generated, however now the pictures do not start at the top of the button but in the center. I've tried a few ways to get them to stay at the top but none have worked. Any advice?

  15. I have buttons and inside of those buttons are pictures and text. The pictures are all the same size, no problem with that, but as the text isn't the same size, nothing I do, seems to get the buttons to become the same size OR start on the same line ((I.E. I can set their size to 300px tall, and after that they are all the same size but they don't start on the same line. You can view the page here http://efunstudies.com/nvc/
    just enter nonsense until you get to the fourth page. Of you can check out the code(view source) here

    
    
    <!DOCTYPE HTML>
    <html>
        <head>
    			<meta charset=utf-8>
            <title>NVC Letter Templet</title>
            <link rel="stylesheet" href="style.css" />
        </head>
        <body>
    
            <div class="container">
                <div class="main">
                    <h2>Use NVC to express your needs.</h2><hr/>
                    <span id="error">
    			<!----Initializing Session for errors--->
                                        </span>
                    <form action="NVC_page_5.php" method="post">
    
               		
    					Here is your
    					letter to vbcvbcvb 
    					
    					so far:<br><br>
    					
    					Dear vbcvbcvb,<br><br>
    					
    					Today I noticed that you... 
    					and this made me feel
    					
    					alive.<br><br>		<hr width='130%'>
    					
    					
    					
    					
    					
    					
    					To Finish this letter we need to examin your needs. Choose from one of the needs below or create your own.<br><br>
    <button type="submit" name="needvar" value="community, friends and a sense of belonging"  class = "needvar"><img src="pics/community, friends and a sense of belonging.jpg" width="150" height="150" alt="community, friends and a sense of belonging" />I need community, friends and a sense of belonging</button>
    
    <button type="submit" name="needvar" value="to play and have fun"  class = "needvar"><img src="pics/to play and have fun.jpg" width="150" height="150" alt="to play and have fun" />I need to play and have fun</button>
    
    <button type="submit" name="needvar" value="rest and relaxation"  class = "needvar"><img src="pics/rest and relaxation.jpg" width="150" height="150" alt="rest and relaxation" />I need rest and relaxation</button>
    
    <button type="submit" name="needvar" value="to be heard and understood"  class = "needvar"><img src="pics/to be heard and understood.jpg" width="150" height="150" alt="to be heard and understood" />I need to be heard and understood</button>
    
    <button type="submit" name="needvar" value="to understand others and empathize with them"  class = "needvar"><img src="pics/to understand others and empathize with them.jpg" width="150" height="150" alt="to understand others and empathize with them" />I need to understand others and empathize with them</button>
    
    <button type="submit" name="needvar" value="to understand and self-empathize with myself"  class = "needvar"><img src="pics/to understand and self-empathize with myself.jpg" width="150" height="150" alt="to understand and self-empathize with myself" />I need to understand and self-empathize with myself</button>
    
    <button type="submit" name="needvar" value="to demonstrate my capability, my competence and my skills"  class = "needvar"><img src="pics/to demonstrate my capability, my competence and my skills.jpg" width="150" height="150" alt="to demonstrate my capability, my competence and my skills" />I need to demonstrate my capability, my competence and my skills</button>
    
    <button type="submit" name="needvar" value="a chance to learn, explore and discover new and wonderful things"  class = "needvar"><img src="pics/a chance to learn, explore and discover new and wonderful things.jpg" width="150" height="150" alt="a chance to learn, explore and discover new and wonderful things" />I need a chance to learn, explore and discover new and wonderful things</button>
    
    <button type="submit" name="needvar" value="to have the freedom and autonomy to choose"  class = "needvar"><img src="pics/to have the freedom and autonomy to choose.jpg" width="150" height="150" alt="to have the freedom and autonomy to choose" />I need to have the freedom and autonomy to choose</button>
    
    <button type="submit" name="needvar" value="to express myself and my creativity"  class = "needvar"><img src="pics/to express myself and my creativity.jpg" width="150" height="150" alt="to express myself and my creativity" />I need to express myself and my creativity</button>
    
    <button type="submit" name="needvar" value="to feel safe and trust in others"  class = "needvar"><img src="pics/to feel safe and trust in others.jpg" width="150" height="150" alt="to feel safe and trust in others" />I need to feel safe and trust in others</button>
    
    <button type="submit" name="needvar" value="to give and share"  class = "needvar"><img src="pics/to give and share.jpg" width="150" height="150" alt="to give and share" />I need to give and share</button>
    
    <button type="submit" name="needvar" value="to provide help and support"  class = "needvar"><img src="pics/to provide help and support.jpg" width="150" height="150" alt="to provide help and support" />I need to provide help and support</button>
    
    <button type="submit" name="needvar" value="to be respected, and to feel that I am mattered and considered"  class = "needvar"><img src="pics/to be respected, and to feel that I am mattered and considered.jpg" width="150" height="150" alt="to be respected, and to feel that I am mattered and considered" />I need to be respected, and to feel that I am mattered and considered</button>
    
                    </form>
                    <form action="NVC_Other_need.php" method="post">
    						<button type="submit" name="needvar" value="Other - Write your own" class = "needvar" >
    						 <img src="pics/Other - Write your own.jpg" width="150" height="150" alt="Other - Write your own" />
    						 Other - Write your own
    						 </button>
    
    					
                    </form>
                </div>
    
            </div>
        </body>
    </html>
    
  16. Hey All,

    I'm Eric a novice programmer, an International Aid Worker and Educator, currently based in Yunnan China, and an avid world traveler who has done quite a few travel videos with different travel channels (here is one that I did

     

    ).

     

    Thanks to your Admin Zane, who has been helping via Facebook for several months,  I am not half bad at PHP,programmer. Sadly I am still terrible at everything else. Anyway I am learning.

    For the past several months I have been working on software to help students from around the world enroll in Western Universities. Part of my plan is to offer the final version of the software for free to intelligent students (from mostly lower developed countries but also the poor in higher developed countries) in order to help them choose, and enroll in university programs that meet their needs, and which are affordable or free. I've helped about 200 so far(mostly without the software), but it has been a lot of work, too much for one person, which is why I have been coding the software. Some of these guys have been near Einsteins - geniuses let down by their own countries poor education systems or in a few cases let down by the constant civil war that has and will continue to rage on, and on and on (50+ years no in Eastern Burma).

    I'll be incorporating this project into a Charitable Non-Profit Organization, and if anyone is interested i would love to have a few a skilled programmers who can volunteer their time to help me on some projects. I still have quite a few things to accomplish before the software can be released to the masses.
     

  17. Thanks Zane, but let me re-express what i am looking for, maybe you can help me with that.

    As is, it is required, which is perfect if on JOBPRESENT1a you choose no.
    But if you choose yes on JOBPRESENT1a, then JOBFINISH1a is still required, even though it is hidden. I could just remove required from JOBFINISH1a , except that I want JOBFINISH1a to be required if the response to JOBPRESENT1a is no.
    Does that make my problem more clear?

     

  18. I am using Jquery to  show or hide my "JOBFINISH1a" form question based on the answer to a the "JOBPRESENT1a" question. I want to require JOBFINISH1a ONLY if the answer to JOBPRESENT1a is "no".

     

    So hidden and not required or shown and required. Any ideas? I'm pretty new to jquery so I can't figure this out on my own.

      	<script>
            $(document).ready(function (){
                $("#JOBPRESENT1a").change(function() {
                    if ($(this).val() == "No") {
                        $("#jobfinish").show();
                    }else{
                        $("#jobfinish").hide();
                    } 
                });
            });
        </script>
    
    <label id='tooltip1'> Are you currently working with this company?<span></span><a>帮助<span>INFO</span></a></label><br /><br>    
            <select id='JOBPRESENT1a' name='JOBPRESENT1a'  required><br>
            <option value='Yes'>Yes</option>
            <option value='No'>No</option><label>
            </select><br>
    
            
            <p id="jobfinish" style="display:none;">        
            <label id='tooltip1'> Which year did you finish working with this company?<span></span><a>帮助<span>INFO</span></a></label><br /><br>    
            <select id='JOBFINISH1a' name='JOBFINISH1a'  required><br>
            <option value=''>Which Year</option>
            <option value='2020'>2020</option>
            <option value='2019'>2019</option>
            <option value='2018'>2018</option>
            <option value='2017'>2017</option>
            <option value='2016'>2016</option>
            <option value='2015'>2015</option>
            <option value='2014'>2014</option>
            <option value='2013'>2013</option>
            <option value='2012'>2012</option>
            <option value='2011'>2011</option>
            <option value='2010'>2010</option>
            <option value='2009'>2009</option>
            <option value='2008'>2008</option>
            <option value='2007'>2007</option>
            <option value='2006'>2006</option>
            <option value='2005'>2005</option>
            <option value='2004'>2004</option>
            <option value='2003'>2003</option>
            <option value='2002'>2002</option>
            <option value='2001'>2001</option>
            <option value='2000'>2000</option>    
            </select><br>
            </p>
            <br>
    
×
×
  • 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.