Jump to content

justlukeyou

Members
  • Posts

    957
  • Joined

  • Last visited

Posts posted by justlukeyou

  1. Hi,

     

    I have started a Google+ page for my site but I just cant find out how to change the name of the page. For Facebook this is simple but I just cant find it one Google+

     

    Does anyone know how to do this please?

     

    Irony is I have tried Googling it any nothing useful came up.

  2. Also, I was declaring my ID number like this. Is this considered PDO? Is there anyway I can determine if something is MySQL and something is PDO?


    $query = "SELECT * FROM users WHERE id = " . intval($_SESSION['userID']) . " LIMIT 1";
    Now it seems I have to declare the variable before I use it in the query, is that right?
  3. Thanks Mad Programmer,

     

    You have the ability to explain things in a way many other people dont have.

     

    I looked up $query-execute(); but I dont understand how it should be used. I have run the query now all I am trying to do is to echo.

     

    http://php.net/manual/en/pdo.query.php

    		<?php
    		$id = 441;
    		
    	$query = $db->prepare('SELECT * FROM users WHERE id = :id');
    $query->bindParam(':id', $id);	
    $query->execute();
    {
    echo $id;
    echo $firstname;
    echo $row['firstname'];
    }
                    ?>
    
  4. Hi,

     

    I tried this which echoes the id (which I am declaring) but it does not echo the first name. Can anyone advise why this is please?

     

    I can do this in MySQL.

    			
    		<?php
    		$id = 441;
    		
    	$query = $db->prepare('SELECT * FROM users WHERE id = :id');
    $query->bindParam(':id', $id);	
    
    echo $id;
    echo $firstname;
    echo $row['firstname'];
                    ?>		
    
  5. Hi,

     

    When someone submits there 3 skills can I insert them into both skill1, skill2, skill3 and skill?

     

    So the 3 skills enter 'skill' and skill1, skill2, skill3.

     

     

    I have also been advised it can be done like this...

     

    $skills = array('skill1' => 'skill value 1', 'skill2' => 'skill value 2', 'skill3' => 'skill value 3');
    echo "skills.php?skill=" . base64_encode($skills);
    $skillsEncoded = $_GET['skill'];
    $skills = base64_decode($skillsEncoded);
  6. Thanks,

     

    The problem is I dont understand a single word of the PHP site. Every time I read it I get more confused.

     

    What is it that the prepare does.

     

    For example how do I a perform where clause if I cant use a variable?

     

    How would I say echo "username where userid = $id"

  7. Thanks,

     

    Im really pleased I have a test that now works. Is it possible to convert MySQL to PDO by replacing one phrase for another with something like word?

     

    For example could I just do find...

     

    $query = mysql_query

     

    and replace with...

     

    $result = $db->query

  8. Okay,

     

    So I got this working but will MySQL one day all be depracted and any site made from MySQL fail to work?

     

    Is this the PDO I should be using...

    <?php
    $result = $db->query('SELECT eventname, eventlocation, eventcountry, eventid, logo, company, id, supplierdetails1, eventid FROM users
    JOIN eventjobs ON eventjobs.organiserid = users.id
    ORDER BY eventid DESC
    LIMIT 8 ');
    foreach($result as $row) {
    
    ?>
    
  9. Aha,

     

    I got this to work with a connection. Now I just need to build the whole query I was originally using.

    <?php
    $result = $db->query('SELECT firstname FROM users');
    foreach($result as $row) {
    echo $row['firstname'].'<br />'; // Output all usernames from the database.
    }
    ?>
    
  10. Hi,

     

    After almost completing my site I am now trying to update it into PDO. I thought I would start with a query. However when I Google stuff like "

     

     

    <?php
    $query = mysql_query("SELECT eventname, firstname, eventdetails, eventlocation, eventcountry, eventid, eventstart, eventend, logo, company, id, supplierdetails1, eventid
    FROM users
    JOIN eventjobs ON eventjobs.organiserid = users.id
    ORDER BY eventid DESC
    LIMIT 8 ");
    while($row = mysql_fetch_array($query)) {
    ?>

     

    I found this but it doesn't explain what $db is. Is the connection code? If so I cant even connect to my database using PDO.

     

    $result = $db->query('SELECT username FROM users');
    foreach($result as $row) {
    echo $row['username'].'<br />'; // Output all usernames from the database.
    }
  11. Hi,

     

    I have code which uploads an image however I am stuck on how to restrict the height of an uploaded image.

     

    I can displays images once they are uploaded but if someone uploads a very tall images then it ruins the whole design of the site.

     

    I have gone through these sites but I am now more confused. Can anyone advise the best route to take to restrict an image upload?

     

    http://stackoverflow.com/questions/4612289/resize-image-on-upload-php

    http://www.9lessons.info/2009/03/upload-and-resize-image-with-php.html

    http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

    if ($_FILES['uploadLogo']['tmp_name'] != "") {
    // Run error handling on the file
    // Set Max file size limit to somewhere around 2mb
    $maxfilesize = 3145728; //size in bytes
    // Check file size, if too large exit and tell them why
    if($_FILES['uploadLogo']['size'] > $maxfilesize ) { 
        echo "<br /><br />Your logo image was too large. Must be 3Mb or less, please<br /><br />
            <a href=\"gallery_upload.php\">click here</a> to try again";
            unlink($_FILES['uploadLogo']['tmp_name']); 
            exit();
    	// Check file extension to see if it is .jpg, if not exit and tell them why
    } else if (!preg_match("/\.(gif|png|jpg|jpeg)$/i", $_FILES['uploadLogo']['name'] ) ) {
            echo "<br /><br />Your image was not .jpg, please<br />
            <a href=\"gallery_upload.php\">click here</a> to try again";
            unlink($_FILES['uploadLogo']['tmp_name']);
            exit();
            // If no errors on the file process it and upload to server 
    } else { 
            // Set the direntory for where to upload it, use the member id to hit their folder
            // Upload the file
    	    /*if(isset($_GET['id'])){
    		if (!is_dir('memberFiles/'.$id.'/images/')) { //if memberFiles folder does not exist
     			mkdir('memberFiles/'.$id.'/images/'); //make the folder 
    		}*/
    		if (!is_dir('images/')) { //if memberFiles folder does not exist
     			mkdir('images/'); //make the folder 
    		}
    	        $target_path = 'images/'; //set targetpath
    }
    		//adjust target path to create new file name which include $id and current date and original filename
    		$ref = "-". gmdate('jmyhis') ."-". basename( $_FILES['uploadLogo']['name']);
    		$target_path .= $ref;
    		$filename = basename($_FILES['uploadLogo']['name']); 
    		$date =	gmdate('j-m-y h:i:s');
    		$filename;
    		
    if(move_uploaded_file($_FILES['uploadLogo']['tmp_name'], $target_path)) {
    		mysql_query("UPDATE users SET logo='$ref' WHERE id='$myID'");
            echo "Your image ".$filename." has been uploaded";
    } else {
        	echo "There was an error uploading the logo file, please try again!";
    }
    }
    
  12. Hi,

     

    I have these links:

     

    website.com/query.php?skill=graphic-design

     

    and

     

    website.com/query.php?skill=web-design

     

    But 'Graphic Design' is part of skill1 column and 'Web Design' is part of skill2 column.

     

     

    I am trying to get the link to query multiple columns.

  13. Hi,

     

    I am trying to complete a multi-dimensional array however when I use the following link:

     

    website.php?skill=print-design

     

    It echoes the following:

     

    skills.php?skill=

     

     

    The plan is to query skill1, skill2 and skill3 by querying skill only. Does anyone have any suggestions on how I can clear it.

    		<?php
    if (isset($_GET['skills']))
    $skills = array('skill1' => 'skill value 1', 'skill2' => 'skill value 2', 'skill3' => 'skill value 3');
    echo "skills.php?skill=" . base64_encode($skills);
    $skillsEncoded = $_GET['skill'];
    $skills = base64_decode($skillsEncoded);
    $sql = "SELECT * FROM users WHERE skill1 = '$skills'";
    $res = mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_assoc($res); 
    $num_rows = mysql_num_rows($res); 
    ?>
    
    
    <?php echo ($row['skill1']); ?>
    
  14. Thanks, but the && command doesn't seem to work.

     

    I set up a test but the following set of code doesn't echo anything but without the && command it does work.

     

    <?PHP
    $query = mysql_query("SELECT skill1, skill2, skill3
    FROM users ");
    while($row = mysql_fetch_array($query)) {
    if(!empty($row['skill3link']) && !empty($row['skill3'])) {
    
    echo $row['skill3'] ;
    }
    }
    
    ?>
    This works...
    <?PHP
    $query = mysql_query("SELECT skill1, skill2, skill3
    FROM users ");
    while($row = mysql_fetch_array($query)) {
    if(!empty($row['skill3'])) {
    
    echo $row['skill3'] ;
    }
    }
    
    ?>
    
  15. Hi,

     

    The plan is that it echoes the skill3link into a link around skill3. However it only echoes skill3 and not skill3link.

     

    I need something like this but cant get the right code.

    <?php if (!empty($row['skill3link'])) , (!empty($row['skill3'])) : ?>
    
    <?php endif; ?>
    <?php if (!empty($row['skill3link'])) : ?>
    <?php endif; ?>
    <?php if (!empty($row['skill3'])) : ?>
    <div class="eventskillscell">
    <a href="/siteinfo/eventskillsquery.php?skill3=<?php echo $row['skill3link'] ; ?>"  class='dealpagelink' >
    <?php echo $row['skill3'] ; ?>
    
  16. Hi,

     

    I am trying to merge the empty code for 'skill3link' and 'skill3' but whatever I try doesn't seem to work. The code will only display the last empty row. In this case 'skill3'.

     

    Can anyone advise an alternative please or how to merge the two codes together.

    <?php endif; ?>
    <?php if (!empty($row['skill3link'])) : ?>
    <?php endif; ?>
    <?php if (!empty($row['skill3'])) : ?>
    <div class="eventskillscell">
    <a href="/siteinfo/eventskillsquery.php?skill3=<?php echo $row['skill3link'] ; ?>"  class='dealpagelink' >
    <?php echo $row['skill3'] ; ?>
    </a>
    </div>
    <?php endif; ?>
    
    <?php
    }
    ?>
    
×
×
  • 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.