Jump to content

paul2463

Members
  • Posts

    955
  • Joined

  • Last visited

    Never

Posts posted by paul2463

  1. I am making an assumption that you are using $_GET incorrectly and have adjusted and commented this part of your code

     

    $user=($_SESSION['username']);
    $tbl_name="user";
    $sql="SELECT * FROM $tbl_name WHERE uname = '$user' " or die(mysql_error());
    $f_name=$_GET['f_name'];
    

     

    Instead try this if my comments make sense to what you want

     

    $user=($_SESSION['username']); //create the user variable
    $tbl_name="user"; //create the table variable
    $sql="SELECT * FROM $tbl_name WHERE uname = '$user' "; //create the query
    $result = mysql_query($sql) or die ("error in the query" . mysql_error()); //execute the query
    $row = mysql_fetch_assoc($result); //return the row information in an array
    $f_name = $row['f_name']; //pull the forename from that array
    
    //if I am correct in my assumption then the following line does not do what you want it to
    //$f_name=$_GET['f_name']; 
    
    

  2. change this bit

    # GRAB THE VARIABLES FROM THE FORM
    $Lastname = $_POST['Lastname'];
    $Firstname = $_POST['Firstname'];
    
    //this should select based on form selections
    $query = "SELECT * FROM phoneList
                  WHERE Lastname=\"{$_POST['Lastname']}\" AND Firstname=\"{$_POST['Firstname']}\" ";
    $result = mysql_query($query)
         or die ("Couldnt execute 2nd query");
       
    //put info on new lines
      echo "<table cellspacing='15'>";
      echo "<tr><td colspan='3'></td></tr>";
      while($row = mysql_fetch_assoc($result))
      {
         extract($row);
    
         echo "<tr>\n
                <td>$Firstname</td>\n
                <td>$Lastname</td>\n
             <tr>
                <td>$Email</td>\n
             <tr>
                <td>$Phone</td>\n
               </tr>\n";
         echo "<tr><td colspan='3'></td></tr>\n";
      }
      echo "</table>\n";
    

     

    to this

     

    <?php
    # GRAB THE VARIABLES FROM THE FORM
    $Lastname = $_POST['Lastname'];
    $Firstname = $_POST['Firstname'];
    
    //this should select based on form selections 
    //You already had the variables above so need to reuse the $_POST variables in the query
    $query = "SELECT * FROM phoneList
                  WHERE Lastname='$Lastname' AND Firstname='$Firstname'";
    $result = mysql_query($query) or die ("Couldnt execute 2nd query");
    $numrows = mysql_num_rows($result); //count the number of rows returned
    if($numrows < 1 ) //if none!!!
    {
    echo ("There were no rows returned from the database");
    }
    else //otherwise draw the table
    {
    //put info on new lines
    echo "<table cellspacing='15'>";
    echo "<tr><td colspan='3'></td></tr>";
    while($row = mysql_fetch_assoc($result))
    {
    	extract($row);
    	echo "
    	<tr>\n
    		<td>$Firstname</td>\n
    		<td>$Lastname</td>\n
    	<tr>
    		<td>$Email</td>\n
    	<tr>
    		<td>$Phone</td>\n
    	</tr>\n";
    echo "<tr><td colspan='3'></td></tr>\n";
    }
    echo "</table>\n";
    }
    ?>
    

  3. yes indeed, however, IMHO, after the mail server has accepted the mail for delivery then the other problems are outside the coders control. so a quick and simple check to see whether the mail has been handed over successfully to the mail server is to check for a TRUE return statement from the function.

  4. try this

     

    $result = mysql_query("SELECT * FROM '$bookseriesfordisplay' WHERE book_title = '$booktitlefordisplay'");
    

     

    it is saying that in the table there is no book_title called 'dragonswan', i have placed single ticks around the php variables because they have to have that for the query to work and you didnt have any around the FROM variable

  5. here might be the problem, you are missing the single ticks from the php variable $productId

     

    try this

     

    if ($totalRows_ss == 0) {
          // put the product in cart table
          $sql2 = "INSERT INTO cart (product_id, quantity, session_id, date)
                  VALUES ('$productId', 1, '$sid', NOW())";
    	$insert = mysql_query($sql2, $JaceyConn) or die(mysql_error());
         
       } else {
          // update product quantity in cart table
          $sql3 = "UPDATE cart 
                  SET quantity = quantity + 1
                  WHERE session_id = '$sid' AND product_id = '$productId'"; 
    
        $update = mysql_query($sql3, $JaceyConn) or die(mysql_error()); 
       }    
    

  6. always always always put the

     

    or die ("Error in query " . mysql_error());
    

     

    on the end of your query execution call, it points the way to so many silly little faults like this one (silly little faults incorporate spelling errors, wrong punctuation and the like)

  7. do not try the '@' because all that does is allows the program to run with the error, it is a command that says 'ignore error' it does not fix them

     

    your query is wrong, you didnt put the 'or die' command on it, if you had it would have told you you had an error in your query

     

    try this

     

    $q_pagination = "SELECT * FROM `fcp_products` LIMIT '$num', '$max'"; 
    

     

    you must use single quotes around php variables in the query syntax

     

    sorry just spotted the error in my own co=de for the error

     

    $r_pagination = mysql_query($q_pagination) or die ("Error in query" . mysql_error());
    

  8. you could do it in php

     

    $total = 0;
    $query = "SELECT amount FROM tblinquiries WHERE inq_date = '22/04/2008'";
    $result = mysql_query($query) or die ("Error in query " . mysql_error());
    while ($row = mysql_fetch_assoc($result)
    {
    $total = $total + $row['amount'];
    }
    echo $total;
    

     

  9. you were missing a closing brace on one of you if / else statement, if you organised your code a wee bit better with proper indentations and opening a closing braces on the same tab then you would spot the ones that were missing, just a minor observation

     

    <?php
    require_once "../tracking/db_connx.php";
    session_start();
    if (isset ($_POST['submit']))
    {
    if (preg_match('/[!@#$%^&*()-+=`~<>,.?}{|]/', $_POST['username']))
    {
    echo "Illegal Characters In Username";
    }
    else
    {
    	if (preg_match('/[!@#$%^&*()-+=`~<>,.?}{|]/', $_POST['passwd']))
    	{
    	echo "Illegal Characters In Password";
    	}
    	else
    	{
    	$username = $_POST['username'];
    	$password = $_POST['passwd'];
    	$sql = "SELECT * FROM webusers WHERE username='$username' AND passwd='$passwd'";
    		if ($r = mysql_query ($sql)) 
    		{
    		$row = mysql_fetch_array ($r);
    		$num = mysql_num_rows ($r);
    			if ($num > 0)
    			{
    			@$_SESSION['username'] = $row['username'];
    			@$_SESSION['fname'] = $row['fname'];
    			@$_SESSION['lname'] = $row['lname'];
    			@$_SESSION['email'] = $row['email'];
    			@$_SESSION['accesslvl'] = $row['accesslvl'];
    			@$_SESSION['logged_in'] = TRUE;
    			$cookiename = 'ceiscorp.com';
    			$cookievalue=rand(100000,999999);
    			$_SESSION['cookieverify'] = $cookievalue;
    			setcookie($cookiename,$cookievalue,time()+3600,"/");
    			$today=date('r');
    			mysql_query("UPDATE webusers SET logged_in = '$today' WHERE username = '$username'") or die (mysql_error());
    				if($_SESSION['accesslvl'] = 'admin')
    				{
    				header("Location:../indexadmin.php");
    				exit;
    				}
    				else if($_SESSION['accesslvl'] = 'ceis')
    				{
    				header("Location:../indexceis.php");
    				exit;
    				}
    				else if($_SESSION['accesslvl'] = 'cust')
    				{
    				header("Location:../indexcust.php");
    				exit;
    				}
    			}
    			else
    			{
    			@$_SESSION['problem'] ="Username or Password are Incorrect Please Try again";
    			header ('Location: ../indexlog.php');
    			exit;
    			}
    		}
    	}
    }
    }
    ?>
    

  10. one thing I have had small problems with using functions that return true or false is the leaking of information, you final statement in the function says return true so it will, most of the time try this

    function validateForm(form)
    {
      var fe = form.elements;
      var answer = true;
      //validate horse
        if (!requiredCheck(fe['dbhorsename'], 'Horse Name')) answer = false;
      //validate dob
        if (!requiredCheck(fe['dbDOB'], 'Date of Birth')) answer =  false;
        if (!validDob(fe['dbDOB'], 'Date of Birth')) answer =  false;
      // ueln
        if (!requiredCheck(fe['dbUELN'], 'UELN')) answer =  false;
        if (!validPhone(fe['dbUELN'], 'UELN')) answer = false;
    
      return answer;
    }
    

     

    so it sets up a variable with the value of "true" and changes it if there are any problems and then returns that variable instead of the global true or false

  11. I have just tried out your code with a few minor changes to the input values so I can test it

    $test = 1;
    if ($test==0){
    echo "<input type=checkbox disabled name=ticked[] value='$counter'>";}
    else {
    echo "<input type=checkbox name=ticked[] value='$counter'>";
    }
    

     

    and if i change the value of $test it works just fine so I dont know why it wont work for you unless the values it checks against are awry somewhere along the line

  12. Hi Tom

     

    if you are using variable names inside a query they must be inside single quotes such as

     

    // all numbers pulled out of my hair and have no bearing on your code
    $variable = 12;
    //this wont work - no single quotes
    $query = "UPDATE tablename SET columnName = columnName = $variable";
    // this will work - single quotes included
    $query = "UPDATE tablename SET columnName = columnName = '$variable'";
    

     

    hope that helps

  13. in my opinion just leave it, the reason you normalise tables is to save duplication of information and therefore disk space

     

    queries run very fast and the fact that you pull information from all five tables in one query should not make you think of duplicating information, there comes a time when you want to remove all the duplicate information and finding it may be difficult

     

    as I said in my humble, lack of proper, experience :)

  14. if you can echo them inside the while loop then you should be able to store them in an array

    $postArray = array();
    while (there are still things to do)
    {
    $postArray[] = variable;
    }
    print_r($postArray); // will print out all members of the new array
    

×
×
  • 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.