James_43 15 Junior Poster

Yes. And I just discovered that that is what was causing the error.

Because the record I created before I set the auto_increment had a primary key = 0, when I added the auto_increment it got confused since it doesn't accept keys less than 0.

So I changed the id that was causing the issue and works fine now :)

James_43 15 Junior Poster

Hi there,

I created a new table and forgot to set the primary key with an auto_increment.

I went back and use:
ALTER TABLE table ADD PRIMARY KEY AUTO_INCREMENT (column);

However, now whenever I try to insert a new row of data, I get the error message "Duplicate entry '0' for primary key'.

It's obviously still not using the auto increment! I've checked that describe table; shows it with the auto_incremement, and I've also tried re-setting the value of auto_increment, but no luck.

Can anyone help?

James_43 15 Junior Poster

Thanks both for your answers, I understand now :)

James_43 15 Junior Poster

Yeah I do.

The issue was I needed to store the data under a session array, not into the session itself. When I changed:

$_SESSION = $user;
to
$_SESSION['user'] = $user;

The problem resolved.

James_43 15 Junior Poster

Hey guys,

Using PHP I store a datetime in a mySQL table. I am trying to draw that out and reformat the time.

The datetime is contained within the array $user_data['6'] and the format in the mySQL table is set to datetime.

The error I'm getting is Call to a member function format() on a non-object

        $joindate = strtotime($user_data['6']);
        $joindate = $joindate->format('l F Y H:i:s');

Is there a way to get passed this?

James_43 15 Junior Poster

Hi all,

I am using the PHP Facebook SDK to login users. A login button validates the user and returns to a callback 'fb-callback.php'. On this page, I dump the returned data into a mySQL table, start a Session, and redirect to the homepage.

As a test, I stopped the redirect and dumped the session data, and everything looks okay. However, when I dump the session data on any other page, the session doesn't seem to have any data!

Am I supposed to pass it between pages? My understanding was that Session was superglobal, so wht is it not passing between my pages?

To load the session data, I simply use:

    //Load Session
    $user = $response->getGraphUser();
    $_SESSION = $user;

I also start a new session on each page.

Can someone help?

James_43 15 Junior Poster

Yeah, that solved everything. Silly mistake.

Thanks for your help :)

James_43 15 Junior Poster

Oh wait, I seem to have tried to combine mysqli and PDO. I think I copied some code from a past project, thinking it was in PDO.

That will be what's causing the problems, I'll recreate the connection with PDO and see what happens.

James_43 15 Junior Poster

Thanks for your quick reply!

I've update the code as per your recommendations, so it's now:

    $datetime = new DateTime();
    $datetime = $datetime->format('Y-m-d H:i:s');


    $query = 'UPDATE vd_users SET lastlogin = ? WHERE facebook_id = ?';
    $statement = $mySQL_con->prepare($query);

    try {
        $statement->execute(array($datetime, $_SESSION['id']));
        header('Location: #');
        }

    catch (PDOException $error) {
        echo 'Failed to update database' . $error->getMessage();
        }

Is using the array with execute() better than using bind_params()??

Also, here is the code I use to create the connection:

/Attempt Connection
$mySQL_con = new mysqli($mySQL_host, $mySQL_username, $mySQL_password, $mySQL_database);
//Set UTF8
if (!$mySQL_con->set_charset('utf8')) {
    echo ('<b>Error loading character set utf8<b><br>');// . $mySQL_con->error);
    }

//Check Connection
if ($mySQL_con->connect_error) {
    //Display Error Message
    die("<b>Connection to mySQL Failed:</b><br>Please contact your system administrator immediately.");
    }

But I am still getting the non-object error.

James_43 15 Junior Poster

Hi guys,

I can't get passed this error: Call to a member function bind_param() on a non-object.

I have spent hours looking for insights, and can see that my $statement returns FALSE, but have no idea why?

My understanding of PHP is limited, so it might help if I actually understood what an object was???

I have tried the query straight into mysql and it works fine, so really can't understand why this doesn't work! My code is:

    $datetime = new DateTime();
    $datetime = $datetime->format('Y-m-d H:i:s');

    $query = 'UPDATE vd_users set lastlogin WHERE facebook_id = '.$_SESSION['id'].' VALUES (?)';
    $statement = $mySQL_con->prepare($query);
    $statement->bind_param('s', $datetime);    

    try {
        $statement->execute();

        header('Location: #');
        }

    catch (mysqli_sql_exception $error) {
        die ('Failed to update database');
        }
}

Would really appreciate it if someone could help me out!

James_43 15 Junior Poster

I managed to sort this by using a keyboard reader code, that just told me on screen what button I was pressing. Turns out they were keyboard strokes, just not the one's I had thought.

And no, not a prank, just been creating a slide show programme and wanted to control it remotely... Good idea though.

James_43 15 Junior Poster

No, the problem is having a timer that writes to a global variable, and a different timer that reads that variable. Because they are in different windows, I didn't think I was able to have them share a timer??

I think I've created a workaround. Instead of setting the second time to 0.001 seconds later, I've simply set it to the same time as timer 1. Because the operation is so tiny, it seems to processes both at the same time. Not an ideal solution if that code gets bigger going forward though.

James_43 15 Junior Poster

Does anyone know if it's possible to intercept the button presses off a presentation remote, just like we are able to listen for keyboard strokes?

In this case, the buttons on the remote don't appear to be linked to a keyboard button.

James_43 15 Junior Poster

Hi there,

I have two WPF windows. The first (Window1) has a timer that moves an item down a list, then passes the new current selection to a global variable I defined in App.xaml.cs

Window 2 then has another timer that is set to .1 of a second after the timer in Window 1, and it uses this to grab the new current selection.

This works. Mostly. Because there is a delay between when Window 1 timer starts and when Window 2 timer starts, the two timers eventually go out of sync over a long period of time and bad things start happening with my code.

What I would like to do, is when I show Window 2, is to somehow 'reset' whatever value the Window 1 timer is at. This will not solve the problem, since the Window 1 timer is always smaller than the Window 2 timer, however, because the difference between them is so minute (0.001 seconds), the amount of time it would take for the timers to go too badly out of sync with each other would make it an acceptable solution.

The only issue is this strikes me as a really patchwork solution. But I can't see any other solution. If I were somehow able to create an event in App.xaml.cs that my two windows could use to see if the global variable changed, that would be ideal, but I don't think that's possible.

So does anyone know how I might reset the value of …

James_43 15 Junior Poster

Yeah I've made some progress on this now. DoubleAnimation is fading in the image, and I'm using a variable defined in app.xaml.cs to pass the image path between the MainForm and the FullscreenForm, with a timer to keep track of the variable changes pushed by MainForm as the ListBox moves down.

This may not be the best way to go about this, but it seems to work quite well at the moment.

James_43 15 Junior Poster

Sorry, just ignore me. The code does execute each time it's called, I just wasn't seeing the results. Excuse my new-ness to coding.

James_43 15 Junior Poster

Okay so I've done some more research and turns out I had the wrong idea. I now have:

`        public async Task<string> WaitAsynchronouslyAsync()
        {
            await Task.Delay(1000);
            return "Finished";
        }
`

and using it here:

`string result = await WaitAsynchronouslyAsync();

                Background.Source = new BitmapImage(new Uri(Convert.ToString(AllImages[App.inx + 1])));
                App.image1 = Convert.ToString(AllImages[App.inx]);
                App.image2 = Convert.ToString(AllImages[App.inx + 1]);`

The problem now is that this SEEMS to only be executing once. I.e., it works great the first time, but on consecutive tries it doesn't work and messes with my other code (I have a DoubleAnimation which doesn't work now except on the first time it's used)

James_43 15 Junior Poster

Right, that makes sense. I'm not entirely sure what threads are, and I couldn't find a succinct explanation online, but they seem to be about CPU load handling?

Also, from what I can tell, I haven't created any threads on my form... So why am I getting a thread-related error?!

James_43 15 Junior Poster

Could someone please explain to me the purpose or reasons for using Dispatcher.Invoke?

I am getting the error: *The calling thread cannot access this object because a different thread owns it. * and a quick Google search suggested that was due to not using Dispatcher.Invoke (they also said it was a common problem with newbies). This problem only started happening after I added the Task.Delay method, so it's obviously something to do with that?

The code that I am getting the error on is below:

 if(ImageList.SelectedIndex < (c-1))
            {
                    Task.Delay(1000).ContinueWith(_ =>
                    {
                        Background.Source = new BitmapImage(new Uri(Convert.ToString(AllImages[App.inx + 1])));
                        App.image1 = Convert.ToString(AllImages[App.inx]);
                        App.image2 = Convert.ToString(AllImages[App.inx + 1]);
                    }
                    );
            }
James_43 15 Junior Poster

What I mean is that I'm using the selected index of the ListBox to determine which is the next consecutive index of the AllImages List.

I've managed to sort it now, and it was my declaration of the variable. I'm not sure if what I've done is entirely correct, but I've moved the declaration to App.xaml.cs with the following code:

public partial class App : Application { public static int inx; }

And that works perfectly. Just not sure if it's good practise to declare that variable so globally.

James_43 15 Junior Poster

It just occured to me that I may be defining the variable inx incorrectly. Is this right?

 private void inx (object sender, RoutedEventArgs e)
        {
            int inx = 0;
        }
James_43 15 Junior Poster

Okay, I've changed that line to: int inx = ImageList.SelectedIndex;

I'm still getting the same error "cannot convert from 'method group' to 'int'.

Is there anything else I could try?

James_43 15 Junior Poster

Hi there, trying to do something I thought was pretty basic, but can't get around this error.

I have a ListBox, List (AllImages) full of image paths, and two image elements.

Image 1 displays the selected item, Image 2 displays selected item + 1

I have:
int inx = Convert.ToString(ImageList.SelectedIndex);

to get the current index selection, and then I'm passing that into the List (since the indexes will be the same) with:

Background.Source = new BitmapImage(new Uri((AllImages[inx])));

The erorr I get is: Argument 1: cannot convert from 'method group' to 'int' Image Viewer

Is someone able to help me? When I use numbers 0-9 instead of passing a variable, the output is the full file name of the image, so I can't understand why it won't work with an int variable.

James_43 15 Junior Poster

Yeah, that's what I'm trying so far. It's going pretty well, my next question is here though lol https://www.daniweb.com/software-development/csharp/threads/499269/slideshow

James_43 15 Junior Poster

Hi there, I've created a new C# WPF project. The first MainWindow displays a listbox of images within a folder and displays them inside a larger image object.

I am trying to get Window1 to open a fullscreen version of the selected image, that changes depending on what image is currently selected on MainWindow.

I'm very very new to this, but here is my code so far:

MainWindow.xaml

<Window x:Class="Image_Viewer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Image_Viewer"
        mc:Ignorable="d"
        Title="MainWindow">

        <Window.Resources>
        <DataTemplate x:Key="MyImageTemplate">
            <StackPanel>
                <Image Source="{Binding Image}" Width="100" Height="100"/>
                <TextBlock Text="{Binding Name}" Width="100"/>
            </StackPanel>
        </DataTemplate>
    </Window.Resources>

    <DockPanel>

        <Menu Height="22" Name="menu1" Width="Auto" Margin="10, 10, 5, 5" Background="Chocolate" DockPanel.Dock="Top">
            <MenuItem Header="_File">
                <MenuItem Header="_Exit" Click="Application_Exit"/>
                <Separator/>
                <MenuItem Header="_Fullscreen" Click="Fullscreen"/>
            </MenuItem>
        </Menu>

        <ListBox
            Name="ImageList"
            DockPanel.Dock="Left"
            ItemsSource="{Binding AllImages}"
            ItemTemplate="{StaticResource MyImageTemplate}"
            x:FieldModifier="public"/>

        <Image Source="{Binding ElementName=ImageList,Path=SelectedItem.Image}"/>

    </DockPanel>
</Window>

MainWindow.xaml.cs

public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;
        }

        //Menu Bar

        private void Application_Exit(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown();
        }

        private void Fullscreen(object sender, RoutedEventArgs e)
        {
            Window1 secondWindow = new Window1();
            secondWindow.Show();
        }

        //Images

         public class MyImage
        {
            private ImageSource _image;
            private string _name;

            public MyImage(ImageSource image, string name)
            {
                _image = image;
                _name = name;
            }

            public override string ToString()
            {
                return _name;
            }

            public ImageSource Image
            {
                get { return _image; }
            }

            public string Name
            {
                get { return _name; }
            }
        }

         public List<MyImage> AllImages
        {
            get
            {
                List<MyImage> result = new List<MyImage>();

                foreach (string filename in
                    System.IO.Directory.GetFiles(
                        Environment.GetFolderPath(Environment.SpecialFolder.MyPictures))) …
James_43 15 Junior Poster

Tocuh screen won't work in this case, since a clicker is more accessible, with no need to tap the screen to change slides.

I'd prefer to find a programming solution instead of a web development one, but you are right, it should be possible. But I feel it's neater as a programme.

James_43 15 Junior Poster

Hi all, I'm very new to software development. My main area is HTML/PHP/JavaScript, but have done a bit of C# before. I don't believe the idea I have is suited for a web development option, so am looking for ideas / a starting point for a solution to the below scenario.

Scenario:

  • Company A has a stand at a trade show and they want to make use of a digital solution to display their products. Most likely this will be a tv screen with a computer acting as the video output.

  • Company A would like images of their products to display on the screen.

  • But, when they get talking to a customer, they would like to walk them through a series of linear slides in combination with their sales pitch.

  • At this point, the loop slide show would stop and a new, linear slide show would begin. At the end of that linear show, the loop would begin again.

The Company A sales reps could ideally use a bluetooth clicker to signal the linear slideshow to begin, and to navigate through it.

I can't imagine creating a linear slideshow would be all that difficult. However, if this was a website I would use JavaScript to create some cool moving effects with the images... not sure what I would use as an alternative programming language.

Could anyone point me in the right direction / offer any advice how this might be achievable?

Many thanks in advance!

James_43 15 Junior Poster

Ah, such a basic mistake. Thanks for pointing that out, would have taken me hours on my own! :P

James_43 15 Junior Poster

Hi all, I'm quite a new developer, and I've spent a long time trying to figure out what is causing this error: "SQLSTATE[HY093]: Invalid parameter number: parameter was not defined"

As far as I can tell, all my parameters are defined?

My code is below:

$mySQL_query = "INSERT INTO vd_users (
                        username,
                        password,
                        salt,
                        pin,
                        pin_salt,
                        r_date)
                VALUES (
                        :username,
                        :password,
                        :salt,
                        :pin,
                        :pin_salt,
                        :r_date)";

$mySQL_query_parameters = array(
        ':username'         => $_POST['username'],
        ':password'         => $password,
        ':password_salt'    => $password_salt,
        ':pin'              => $pin,
        ':pin_salt'         => $pin_salt,
        ':r_date'           => $datetime
        );

try {
        $mySQL_statement = $mySQL_connection->prepare($mySQL_query);
        $mySQL_result = $mySQL_statement->execute($mySQL_query_parameters);
        }

catch(PDOException $mySQL_errors) {
    die($mySQL_errors->getMessage();
    }

Can anyone help me figure this out?

James_43 15 Junior Poster

Hi guys,

Weird (maybe silly) isse with a CSS fade property using the following classes:

/** CSS3 Animations **/

/* Key Frames
---------------------------------------------------- */
@-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@-o-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
/** ------------------------------------------------ */

.fadeIn {

    opacity:0;
        -webkit-animation:fadeIn ease-in 1;
        -moz-animation:fadeIn ease-in 1;
        -o-animation:fadeIn ease-in 1;
        animation:fadeIn ease-in 1;
        -webkit-animation-fill-mode:forwards;
        -moz-animation-fill-mode:forwards;
        -o-animation-fill-mode:forwards;
        animation-fill-mode:forwards;
}

.fadeIn-500ms {

        -webkit-animation-duration:500ms;
        -moz-animation-duration:500ms;
        -o-animation-duration:500ms;
        animation-duration:500ms;

}

.fadeIn-1s {

    -webkit-animation-duration:1s;
        -moz-animation-duration:1s;
        -o-animation-duration:1s;
        animation-duration:1s;

}

.fadeIn-1500ms {

        -webkit-animation-duration:150ms;
        -moz-animation-duration:150ms;
        -o-animation-duration:150ms;
        animation-duration:150ms;

}

.fadeIn-2s {

        -webkit-animation-duration:2s;
        -moz-animation-duration:2s;
        -o-animation-duration:2s;
        animation-duration:2s;

}

.fadeIn-2500ms {

        -webkit-animation-duration:250ms;
        -moz-animation-duration:250ms;
        -o-animation-duration:250ms;
        animation-duration:250ms;

}

.fadeIn-3s {

        -webkit-animation-duration:3s;
        -moz-animation-duration:3s;
        -o-animation-duration:3s;
        animation-duration:3s;

}

.fadeIn-delay-1s {

        -webkit-animation-delay:1s;
        -moz-animation-delay:1s;
        -o-animation-delay:1s;
        animation-delay:1s;
}

.fadeIn-delay-1500ms {

        -webkit-animation-delay:150ms;
        -moz-animation-delay:150ms;
        -o-animation-delay:150ms;
        animation-delay:150ms;
}

.fadeIn-delay-2s {

        -webkit-animation-delay:2s;
        -moz-animation-delay:2s;
        -o-animation-delay:2s;
        animation-delay:2s;
}

.fadeIn-delay-2500ms {

        -webkit-animation-delay:250ms;
        -moz-animation-delay:250ms;
        -o-animation-delay:250ms;
        animation-delay:250ms;
}

.fadeIn-delay-3s {

        -webkit-animation-delay:3s;
        -moz-animation-delay:3s;
        -o-animation-delay:3s;
        animation-delay:3s;
}

And those are used within my HTML as below:

<div id="img-menu" class="menu-practioner-container fadeIn fadeIn-1s" >
        <ul class="menu header-links">
            <li class="header-autism fadeIn fadeIn-1s fadeIn-delay-1500ms"><a data-toggle="modal" data-target="#whatwedo">What we do<span ><img src="http://englishcraftsman.strong-links.org/images/about.png" /></span></a></li>
            <li class="header-autism fadeIn fadeIn-1s fadeIn-delay-1500ms"><a data-toggle="modal" data-target="#email">Facebook<span><img src="http://englishcraftsman.strong-links.org/images/facebook.png" /></span></a></li>
            <li class="header-email-us fadeIn fadeIn-1s fadeIn-delay-1500ms"><a data-toggle="modal" data-target="#email">Free Quotation</a></li>
        </ul>
</div>

The problem is that my code is not recognising the values of split seconds, in this case, the 1500ms value. instead, …

James_43 15 Junior Poster

Cheers guys. I was looking at this fairly weirdly, but have manage to sort just by using the form info :)

James_43 15 Junior Poster

Hi Guys,

As part of an online store, I have a dropdown box where the user selects a size. If the user selects size L then the 'add to cart' button needs to link to a page different than if the user selected size M.

I figured out that I can only grab the selected value for PHP to process if it was submitted, i.e., through a form. Then I could do something like this:

if($_POST['dropdown'] == 'M') {
  $product = 'link';
} else if {
  //do something else
}

But I am not sure if this is possible using a button... I'm still a beginner here, but any thoughts?

James_43 15 Junior Poster

Okay - false alarm! I fixed everything myself.

Simply need to pass the results of the PHP function to a variable:

$pageURL = curPageURL();
James_43 15 Junior Poster

Ah, sorry to keep coming back here, but I've made more progress and it has ended in distaster!

See for yourself, Strong-Links.org - all the links are active. Here is the code for the HTML header:

<nav id="nav-wrap">
                    <ul class="nav" id="nav">
                        <li class="nav-parent"><a

            <?php

                if ($pageURL = "http://strong-links.org/index.php")
                    {
                        echo 'class="active"'; }
                    else {
                        echo ' '; }

            ?>
            href="index.php">Strong Links</a>

                        </li>
                        <li class="nav-parent"><a

            <?php

                if ($pageURL = "http://strong-links.org/about.php")
                    {
                        echo 'class="active"'; }
                    else {
                        echo ' '; }

            ?>

            href="about.html">About Us</a>

                        </li>
                        <li class="nav-parent"><a href="#">Projects</a>
                <ul>
                    <li><a href="synergy.html">Project Synergy</a></li>
                    <li><a href="iOS.html">Strong Links iOS</a></li>
                    </ul>

                        </li>
                        <li class="nav-parent"><a

            <?php

                if ($pageURL = "http://strong-links.org/volunteer.php")
                    {
                        echo 'class="active"'; }
                    else {
                        echo ' '; }

            ?>

            href="volunteer.html">Volunteer</a>

                        </li>
                        <li><a

            <?php

                if ($pageURL = "http://strong-links.org/contact.php")
                    {
                        echo 'class="active"'; }
                    else {
                        echo ' '; }

            ?>

            href="contact.html">Contact</a></li>
                        <li class="last donate"><a

            <?php

                if ($pageURL = "http://strong-links.org/donate.php")
                    {
                        echo 'class="active"'; }
                    else {
                        echo ' '; }

            ?>

             href="donate.html">Donate</a></li>
                    </ul>                
                </nav>
James_43 15 Junior Poster

So far, this is one link on my navigation bar:

<li class="nav-parent"><a "class="active" href="index.html">Strong Links</a>

This is the active one at the homepage.

I then made some PHP code to return the name of the current page:

<?php
function curPageURL() {
    $pageURL = 'http';
    $pageURL .= "://Strong-Links.org";
    $pageURL .=$_SERVER["SERVE_NAME"].$_SERVER["REQUEST_URI"];

    return $pageURL;
}
?>

and used that with the following code:

<?php
                curPageURL();
                if $pageURL = "http://test.strong-links.org/index2.php"
                    {echo "class="active"";}
                    else {echo "";} ?> href="index.html">Strong Links</a>

</li>

...But this doesn't seem to do anything :/

James_43 15 Junior Poster

Hi there,

My PHP is appalling/non-existant. I have a HTML website with a PHP header that I've 'included' on all the pages. The problem is that this header colours red whichever page we are currently on, defined under the CSS as being 'active'.

Therefore, from what I see, I need a way in my header.php file to be able to see what webpage is currently open on the site, and use that answer to set active on or off.

e.g.,

IF current webpage = about.php THEN set about.php to active
else
IF current webpage = home.php THEN set home.php to active
...etc, etc.

Is there a relatively simple way to accomplish this?

James_43 15 Junior Poster

Hey guys,

So so sorry for the delay in response - been out of service for the last two weeks.

madCoder your suggestion worked :) I renamed it to .php and the header popualted fine! Thanks so much!

James_43 15 Junior Poster

Hi there,

I have a webpage in HTML, strong-links.org, and am tired of having to make changes to every single page when I update the header or footer, and someone suggested I can use PHP to reference the template within the HTML pages.

As a test, I have test.strong-links.org/index2.html live with the following code:

<html>    

    <head>

            <title>Strong Links</title>

    </head>

    <body>

        <?php include ('header.php'); ?>

    </body>

</html>

And header.php in the same location with the following code:

`

<div id="navigation">

    <ul>

        <li><a href="">Home</a></li>

        <li><a href="">Test1</a></li>

        <li><a href="">About</a></li>

        <li><a href="">Contact</a></li>

    </ul>

</div>

`
I am using Apache with PHP5.

Can anyone tell me why this is not working?

James_43 15 Junior Poster

Hi all,

I am trying to populate text on my website from data stored in a MySQL database.

I have this script before the <head> of my HTML to establish the connection:

<?php
        $username = "USERNAME";
        $password = "PASSWORD";
        $hostname = "127.0.0.1:3306";

    //connection to the database
        $dbhandle = mysql_connect($hostname, $username, $password)
            or die("Unable to connect to MySQL");
        echo "";

    //select database
        $selected = mysql_select_db("Strong_Links",$dbhandle)
            or die("could not select database");

    ?>

I have loaded that script in isolation with an echo success message, and know it works correctly.

Then, in the body of my HTML I use this script:

<?php

        $result = mysql_query("SELECT content FROM web WHERE id = 'news1'", $dbhandle);
            if (!$result) {
                    die("query failed");
                    }
            echo "<p>$result</p>";



?>

However, on the page, I get one line saying "$result" then a line break, and then another line with ""; ?>"

Does anybody know what I am doing wrong? I have checked my query on the host machine in mySQL and it works fine.

James_43 15 Junior Poster

Thanks everyone. That's quite helpful. For the meantime I'm now using a free template to manage this, but will try as Kyle suggested.

Thanks!

James_43 15 Junior Poster

Okay so I've done some more research, and what I am trying to do is send mail through an external SMTP (which in this case is Gmail).

My understanding is that this is impossible for PHP, unless you have a localised email server, which I think will be too complicated.

Is there any other way? I really just want a contact form on our website.

Kyle Wiering commented: Good information. That does change the context of the original question. +2
James_43 15 Junior Poster

Thanks, I am using Debian. I am not getting any error messages, in fact it says sent successfully.

Where would I specify the outgoing SMTP server?

James_43 15 Junior Poster

Hi everyone,

I am still quite new to HTML and PHP. I have a form in HTML pointing to a PHP script that sends an email. But it doesn't work - please tell me where I am going wrong!

The HTML is:

 <div class="main-content three-fourths">
                    <h1>Get in touch</h1>
                    <p class="lead">We'd love to hear from you.</p>                       

                    <!-- Start Form -->
                    <form id="contactform" action="php/processForm.php" method="post">
                        <table class="tableless">
                            <tr><td><input type="text" id="name" name="name" placeholder="What's your name" /></td></tr>
                            <tr><td><input type="email" id="email" name="email" placeholder="Email goes here" /></td></tr>
                            <tr><td><textarea id="message" name="message" rows="5" cols="20" placeholder="Whats this about?"></textarea></td></tr>

                            <tr><td>
                            <input name="button" class="btn" type="submit" value="Send Message" id="send" /><br/></td></tr>
                        </table>
                    </form>
                    <div id="response"></div>

And the PHP script:

<?php

// Clean up the input values
foreach($_POST as $key => $value) {
    if(ini_get('magic_quotes_gpc'))
        $_POST[$key] = stripslashes($_POST[$key]);

    $_POST[$key] = htmlspecialchars(strip_tags($_POST[$key]));
}

// Assign the input values to variables for easy reference
$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];

// Test input values for errors
$errors = array();
if(strlen($name) < 2) {
    if(!$name) {
        $errors[] = "You must enter a name.";
    } else {
        $errors[] = "Name must be at least 2 characters.";
    }
}
if(!$email) {
    $errors[] = "You must enter an email.";
} else if(!validEmail($email)) {
    $errors[] = "You must enter a valid email.";
}
if(strlen($message) < 10) {
    if(!$message) {
        $errors[] = "You must enter a message.";
    } else {
        $errors[] = "Message must be at least 10 characters.";
    }
}

if($errors) {
    // Output errors and die with a failure message
    $errortext = "";
    foreach($errors as $error) …
James_43 15 Junior Poster

Hi everyone,

Just after some general advice. I have developed a website that contains several news widgets that will eventually need updating. I am not too fussed about keeping a record of past news events, but that could be nice.

Basically my question is, what is the best way to content manage this? Because the writing of the news stories and website administration will be done by someone with little coding skills, I don't want them to be able to edit the HTML files even on a test platform.

I was thinking I could create a database and the news feeds just draw on that?

Cheers!

James_43 15 Junior Poster

Awesome - thanks, that worked great! :)

James_43 15 Junior Poster

My bad - another typo. The CSS is:

.picture-center
    {
        width: 100%;
        height: auto;
    }

So, the = bits were a mistake. And still no success. Does it matter that the article is already within a DIV frame?

James_43 15 Junior Poster

Ah - sorry, ignore the picture-center / center-picture confusion. That was just a typo, all are the same in the real code.

James_43 15 Junior Poster

Hi there,

I have the following code to define the first article on the website I'm developing Strong-Links.org

                            <article id="me" class="panel">
                                <img src="/images/Strong-Links.png">
                                <a href="#work" class="jumplink pic">
                                    <span class="arrow icon fa-chevron-right"><span>See my work</span></span>
                                    <img src="images/me.jpg" alt="" />
                                </a>
                            </article>

This basically just places two images on the page, with me.jpg aligned to the left, and an arrow icon overlaying it.

However, when I view this page from the mobile, Strong-Links.png spans over the screen. I need to make it width=100%.

In the CSS mobile styles, I have defined the below:

.picture-center
    {
    width=100%;
    height=100%;
    }

The same, but blank, is in the desktop CSS styles.

Under the HTML file, I now have the following:

                        <article id="me" class="panel">
                                <div id="center-picture">
                                <img src="/images/Strong-Links.png">
                                </div>
                                <a href="#work" class="jumplink pic">
                                    <span class="arrow icon fa-chevron-right"><span>See my work</span></span>
                                    <img src="images/me.jpg" alt="" />
                                </a>
                            </article>

However, this does not solve the problem. The image still overlaps the edges on a mobile device. Some please tell me what I am doing wrong!