simplypixie 123 Posting Pro in Training

A quick and dirty solution to show you how it can be done:

<?php
$sql = mysql_query("SELECT access_id FROM user WHERE id='".$userid."' LIMIT 1");
$result = mysql_fetch_array($sql);
$id = $result['access_id'];

$query = mysql_query("SELECT * FROM access");
?>
<select name='access'>
  <?php
    while ($accessrow = mysql_fetch_array($query)) {
  ?>
<option value="<?php echo $accessrow['id']; ?>" <?php if ($id == $accessrow['id']) { echo 'selected'; } ?> ><?php echo $accessrow['access']; ?></option>
<?php } ?>
manc1976 commented: Was the soulution I was looking for +0
simplypixie 123 Posting Pro in Training

I think (from memory of the problem) all content below the unclosed image tag (which then affected the closing a tag) would become a link until a new link (a tag) was declared and as you have links right at the top of your posts but not in your pages that is probable why (hope this makes sense).

By the way, I have been developing websites for over 10 years and I have often been staring and staring at code trying to find where the problem is and not been able to see something so simple, as in this case, until I asked for help. Sometimes you can look too much :-)

simplypixie 123 Posting Pro in Training

I am reading a good book at the moment from Sitepoint PHP Master which is all about OOP (I love the Sitepoint books and their website).

simplypixie 123 Posting Pro in Training

If each of your right and left floats have set widths, then add the appropriate margins to the center div (i.e. if both floats are 200px wide then set the left and right margins on your center div to 200px each)

simplypixie 123 Posting Pro in Training

Your image tag isn't closed so will cause errors:

<a href="http://twitter.com/thirdspaceme" title="Check Out YOURthirdspace Twitter"><img src="http://i.imgur.com/qi1OJ.png" alt="YOURthirdspace" </a>

Should be:

<a href="http://twitter.com/thirdspaceme" title="Check Out YOURthirdspace Twitter"><img src="http://i.imgur.com/qi1OJ.png" alt="YOURthirdspace" /></a>
simplypixie 123 Posting Pro in Training

Try these changes:

body	{
  padding:0;
  margin:0;
	}
#content	{
	width:500px;
        height:600px;
        margin: 0 auto;
	color:red;
        background:#e3eeff;
	padding:10px;
        border:1px solid green;
	}
simplypixie 123 Posting Pro in Training

You could try http://www.learnable.com - they do online courses including in asp.net. Just search at the site.

simplypixie 123 Posting Pro in Training

Are your $_GET variables being populated?

Have you tested the query in PHPMyAdmin with actual values to make sure it is working?

Your filename=$f has no quotes around the $f.

simplypixie 123 Posting Pro in Training

Try putting your visited css above your hover css in your style sheet

simplypixie 123 Posting Pro in Training

I presume you have run your query in the database to make sure you have no errors?

Also check in the PHP that you are getting 4 rows returned and echo out the actual filenames

$total_rows=0;
$queryi = "SELECT filename FROM images WHERE productid = '" . $row['productid'] . "' LIMIT 0,4";
		$resulti = mysql_query($queryi) or die( "An error has occured: " .mysql_error (). ":" .mysql_errno ());
$total_rows=mysql_num_rows($resulti);
echo $total_rows;
while ($tweener=mysql_fetch_array($result)) 
{
echo $tweener['filename'].'<br`>';		
if ($tweener['filename'] != "") 
		{
			// Resize thumbs ready for display
			$imagesizer = getimagesize($root . 'admin/uploads/' . $tweener['filename']); 
			$imgrs = imageResize($imagesizer[0], $imagesizer[1], 300);
			$image = '<img src="' . $root . 'admin/uploads/' . $tweener['filename'] . '" alt="' . $row['productid'] . '" ' . $imgrs . ' />';
 
		}
		else
		{
			$image = '<img src="' . $root . 'assets/no-image-large.jpg" alt="No Image Available" />';
		}
}

Sorry, I missed that you had solved before writing this :-)

simplypixie 123 Posting Pro in Training

OK, I am literally just looking at things by a process of elimination at the moment - are all your filenames different? I am wondering if you are using your productid as your image filename which would then only return the last record / image??

simplypixie 123 Posting Pro in Training

well the code I assume is working no parse errors as such however it will not display any of the 4 images in the database?? I assume I wouls still use the $image mark to define where I want them to be displayed??

Yes you need to echo the $image where you want it in the page. Another thought - have you checked your source code to make sure your page is even getting to where it should display the images without any errors?

simplypixie 123 Posting Pro in Training

Is the link to where the images are stored definitely correct, including your $root variable?

simplypixie 123 Posting Pro in Training

Sorry I can't quite work out what you are trying to do here - if it is a javascript issue then you may need to repost in that forum.

simplypixie 123 Posting Pro in Training

Try this

// Get an image 
		$queryi = "SELECT filename FROM images WHERE productid = '" . $row['productid'] . "' LIMIT 0,4";
		$resulti = mysql_query($queryi) or die( "An error has occured: " .mysql_error (). ":" .mysql_errno ());
		
		while ($tweener=mysql_fetch_array($result)) 
{
		if ($tweener['filename'] != "") 
		{
			// Resize thumbs ready for display
			$imagesizer = getimagesize($root . 'admin/uploads/' . $tweener['filename']); 
			$imgrs = imageResize($imagesizer[0], $imagesizer[1], 300);
			$image = '<img src="' . $root . 'admin/uploads/' . $tweener['filename'] . '" alt="' . $row['productid'] . '" ' . $imgrs . ' />';
			
		}
		else
		{
			$image = '<img src="' . $root . 'assets/no-image-large.jpg" alt="No Image Available" />';
		}
}
simplypixie 123 Posting Pro in Training
SELECT * FROM blogs WHERE username='".$_SESSION['MM_Username']."'

Use this code to only select the blogs written by the logged in user

simplypixie 123 Posting Pro in Training

You don't need to use salt so I would remove all references to it and stick with just MD5 and see if that resolves your problems

simplypixie 123 Posting Pro in Training

It appears to me that on some of your login functions you are using md5($password).$salt to check the password but you are not applying the $salt to the query that changes the password so they will be different.

simplypixie 123 Posting Pro in Training

I have tweaked your code to wrap everything as I suggested - if you could try it please

<?php
    include '../dbfunctions.php';
    $link = dbConnect();
    //session_start();
    $stid = $_GET['staffref'];
    echo $stid;
     
     
    $staffs = dbGetRows("staff", "id = '".$stid."'");
    $staff = mysql_fetch_array($staffs, MYSQL_ASSOC);
     
    echo $staff['username'];
    echo $staff['password'];
     
    if (isset($_POST['Submit']))
    {
     
	    $username = mysql_real_escape_string($_POST['username']);
	    $oldpassword = mysql_real_escape_string($_POST['oldpassword']);
	    $newpassword = mysql_real_escape_string($_POST['newpassword']);
	    $confirmnewpassword = mysql_real_escape_string($_POST['confirmnewpassword']);
	     
	    // var_dump($_POST);
	     
	     
	    if($newpassword == "" )
	    {
	    	echo "New password cannot be blank!";
	    }
	    // Check if New password is confirmed
	    elseif ($newpassword != $confirmnewpassword)
	    {
	    	echo 'The "New Password" and "Confirm New Password" fields do not match, please re-enter!';
	    }
	    else
	    {
	     
		    // query username old password is not correct
		    $query = "SELECT username FROM staff WHERE username = '".$username."' LIMIT 1" or die(mysql_error());
		     
		    $result = mysql_query($query);
		    $row=mysql_fetch_array($result);
		     
		    // Check if Old username old password is not correct
		    if(!$row)
		    {
		     
		    	echo "Aw shucks! Seems like you don't exist! Please recheck your username/password dude";
		    //mysql_create_db("abcde");
		    }
		    else
		    {
		    // If everything is ok, modify the record
		   
				$query = "UPDATE staff SET password = '".md5($newpassword)."' WHERE username = '".$username."'";
		     
			    $result = mysql_query($query) or die('Error : ' . mysql_error());
			    if( $result )
			    {
			    	echo "All done!";
			    }
	     	}
	     }
	 }
	 else 
	 {
	 ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Password Administration</title>
    <link href="../bb.css" rel="stylesheet" type="text/css">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
     
    <body bgcolor="#FFF4DC">
    <table width="60%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
    <td width="32"><img src="../images/admin_03.gif"></td>
    <td width="0*" bgcolor="#FFFFFF" background="../images/admin_04.gif" style="background-repeat: repeat-x;">&nbsp;</td>
    <td width="35"><img src="../images/admin_07.gif" width="32" height="33"></td>
    </tr>
    <tr>
    <td bgcolor="#FFFFFF" background="../images/admin_15.gif" style="background-repeat: repeat-y;"></td> …
simplypixie 123 Posting Pro in Training

Can you post your new code so I can check agin please.

Including your login.

simplypixie 123 Posting Pro in Training

Break everything down, so try selecting with the username only and then the password only to see which one is causing the error. I am presuming you have used MD5 on your posted old password already?

Also add OR die(mysql_error()) to the end of your query to check the syntax is correct.

And add LIMIT 1 within your query at the end in case there are 2 usernames the same.

"SELECT username FROM staff WHERE username = '".mysql_real_escape_string($username)."' LIMIT 1" or die(mysql_error());
simplypixie 123 Posting Pro in Training

You need to wrap your whole code in your if (isset($_POST)) { atatement and then use and else { around your html and form

<?php 
include './dbfunctions.php';
$link = dbConnect();
session_start();
$stid = $_GET['staffref']; 
echo $stid; 


$staffs = dbGetRows("staff", "id = '".$stid."'");
$staff = mysql_fetch_array($staffs, MYSQL_ASSOC);

echo $staff['username'];
echo $staff['password'];

if (isset($_POST['Submit'])) 
  {
.
.
.
.
}
else {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Password Administration</title>
<link href="../bb.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
 
<body bgcolor="#FFF4DC">
.
.
.
.
</body>
</html>
<?php } ?>
simplypixie 123 Posting Pro in Training

For some reason the previous poster wants you to create a database if a username doesn't exist - my previous code would have worked fine for you, did you try it?

simplypixie 123 Posting Pro in Training

I have already answered this for you in another thread you started

simplypixie 123 Posting Pro in Training

You column references in your queries and your result rows don't match the database structure you are showing.

According to your table structure, it should be

$query = mysql_query("SELECT * FROM teamdb where sport='Basketball'");
	while($row = mysql_fetch_array($query))
	{
	echo '<option value='.$row['tid'].'>'.$row['tname'].'</option>';
	}

and

$query = mysql_query("SELECT * FROM athletedb where tid='10000'");
	while($row = mysql_fetch_array($query))
	{
	echo '<option value='.$row['aid'].'>'.$row['aname'].'</option>';
	}

You don't actually say if you are having a problem displaying your dat and if so what the problem is so further information would be useful and also your javascript for your onclick event.

simplypixie 123 Posting Pro in Training

No your var_dump won't show the hashed password as it hasn't been hashed at that point, you are just displaying the $_POST data. Try this (you aren't actually getting the data from the db correctly:

if(isset($_POST['Submit'])){
$query = mysql_query("SELECT username FROM staff WHERE username = '".$username."'");

//echo $username;
		$result = mysql_fetch_array($query);

	    if($result) {
	        // Check if Username exists
	        if($result['username'] != $username){ 
			echo "Aw shucks! Seems like you don't exist! Please recheck your username dude";
	       }  
	        //Check if New password if blank
	        elseif($newpassword == "" ) {
			echo "New password cannot be blank!";
			}
	                 
	        // Check if New password is confirmed
	        elseif ($newpassword != $confirmpassword) {  
			echo 'The "New Password" and "Confirm New Password" fields do not match, please re-enter!'; 
			}
			else {
	        // If everything is ok,  modify the record
			$query = "UPDATE staff SET password = '".md5(mysql_real_escape_string($newpassword)."' WHERE username = '".mysql_real_escape_string($username)."'";
			}
			$result =  mysql_query($query) or die('Error : ' . mysql_error());
			if( $result ) {
			  echo "All done!";
			}
   }
}
simplypixie 123 Posting Pro in Training

It appears to me that you are not actually connecting to your database - you have a function to connect and you load that function into a variable but that is all. Take you database connection out of the function (i.e. to just let it happen when you load the page) and see if that helps (on your connection.php page first).

If that does resolve your problem and you want to keep the connection in a function you need to put your $linkid variable in your query to connect to the database and run your select query (I don't use this method so can't tell you how to format it).

simplypixie 123 Posting Pro in Training

If you want to use design view to revise the page then yes you also need the related css and image files on your local machine within the site as they are on the remote server.

simplypixie 123 Posting Pro in Training

All you are doing here is removing the error message, you are not solving the error itself.

To me it appears that you are trying to user database_name.table_name to connect to your database and insert your data all within your insert query which I have never seen before in all my years of programming.

1st make your connection to the database and then run your query, therefore changing c944978_member_database.users to just users.

simplypixie 123 Posting Pro in Training

All you are doing here is removing the error message, you are not solving the error itself.

To me it appears that you are trying to user database_name.table_name to connect to your database and insert your data all within your insert query which I have never seen before in all my years of programming.

1st make your connection to the database and then run your query, therefore changing c944978_member_database.users to just users.

simplypixie 123 Posting Pro in Training

I can't actually see what might be wrong apart from you have a form around your php and query for some reason which isn't required. Try removing the form tags on the 2nd page.

simplypixie 123 Posting Pro in Training

Maybe you need to look at copyright laws first

simplypixie 123 Posting Pro in Training

As far as I know you can't combine INSERT and UPDATE queries.

simplypixie 123 Posting Pro in Training

Personally I would use two tables if you want to be able to easily search. So have your main jobs table and then a second that stores all locations per job (just store job_id and location_id and ensure you can store the job_id multiple times) then you can search this table based on location and grab all the job adverts specific to the location from the main jobs table.

If you store all the locations in one column in your jobs table you will have to serialize the data and then it becomes difficult to search using a query, you would have to grab all data first, unserialize it and then see if the location is in the data.

simplypixie 123 Posting Pro in Training

Personally I would use two tables if you want to be able to easily search. So have your main jobs table and then a second that stores all locations per job (just store job_id and location_id and ensure you can store the job_id multiple times) then you can search this table based on location and grab all the job adverts specific to the location from the main jobs table.

If you store all the locations in one column in your jobs table you will have to serialize the data and then it becomes difficult to search using a query, you would have to grab all data first, unserialize it and then see if the location is in the data.

simplypixie 123 Posting Pro in Training

It is good to use existing class attributes to help you learn but only if you take the time to understand them and what they are doing so that in future you can create your own.

simplypixie 123 Posting Pro in Training

There is also nothing to submit the form, you need a Subit button

diafol commented: doh! +14
simplypixie 123 Posting Pro in Training

Have you checked that you are actually receiving the data in the 2nd page, either by looking at the url or by var_dump($_GET)?

simplypixie 123 Posting Pro in Training

Sorry, I put the wrong URL in - it should have been teamtreehouse.com and they offer tutorials in all aspects of website design and development, plus exercises to 'earn badges' so they do provide what you are asking for.

simplypixie 123 Posting Pro in Training

You can't use * in a delete query and you haven't closed your speech marks after $_GET or closed the speech marks for the query, change it to

$output = mysql_query("DELETE FROM produk WHERE id='".$_GET['id']."'") or die(mysql_error());
simplypixie 123 Posting Pro in Training

You need to var_dump($_POST), not $query and the reason that is showing as soon as the page loads is because it is not contained within you if statement to check if the form has been submitted and will obviously be empty at that point.

You also have to curly brackets around you else statement.

simplypixie 123 Posting Pro in Training

You need to add md5() around all your references to the password that you want to look up in the database, i.e.

$newpassword = md5(mysql_real_escape_string($_POST['newpassword']));
simplypixie 123 Posting Pro in Training

Use <iframe>Content Here</iframe>

simplypixie 123 Posting Pro in Training
rotten69 commented: Please understand the Question before you reply. Thank you. +0
simplypixie 123 Posting Pro in Training

You are not declaring your $searchtype and $searchterm variables anywhere in the first page that I can see and you are not sending the data through in your URL properly and finally you need to use $_GET, not $_POST to grab variables and values from a URL.

echo '<table><a href="results.php?searchtype='. $row[0].'&searchterm='. $row[1].'">'. $row[1].'</a>' . '<br />';

I don't know which result is for each of the variables so adjust accordingly.

Then on your results page:

$searchtype=$_GET['searchtype'];
$searchterm=trim($_GET['searchterm']);
simplypixie 123 Posting Pro in Training

Use foreach on the 2nd array and then compare the results in the foreach against the first array using in_array

simplypixie 123 Posting Pro in Training

You are saying if the $_POST doesn't equal delete, then delete and you have also attached your delete query to a variable which I am not sure works in itself but definitely won't do anything the way you have it as the query isn't being exectued. Change it to:

elseif($_POST['mode'] == 'delete'){
	$output = "DELETE * FROM produk WHERE id=".$_POST['id'];
        mysql_query($output) or die (mysql_error());
	//$confirmation = $output ? "Data has been deleted" : "Fail to delete data"; 	
	}

Also var_dump($_POST) to make sure your mode has a value and that it is correct. I see you have used !$_POST == 'edit' which will also need changing.

simplypixie 123 Posting Pro in Training

I was just going to say - I have run and tweaked your query and got it to work. It didn't like the as FeeID and as XLABEL so I changed those to all lower case and got the result as expected (using CURDATE()).

So the code (which is a bit more simple than what you have finished with) is:

SELECT count(TaskID) as taskid, date_format(TaskDueDate, '%d.%m.%Y') as xlabel FROM tasks WHERE TaskDueDate = CURDATE() AND Completed = 'No'
simplypixie 123 Posting Pro in Training

Have you tried running the query in PHPMyAdmin (obviously putting in some data in place of the variables) and see what happens? It should give you an error message if it is your query that isn't working.

simplypixie 123 Posting Pro in Training

Oh yes, I had missed that - you can't use an alias like you are. Just change the where clause to use your correct column

WHERE TaskDueDate = date('Y-m-d')