Clarkey
Members-
Posts
30 -
Joined
-
Last visited
Profile Information
-
Gender
Male
-
Location
Bedfordshire, UK
-
Age
20
Clarkey's Achievements
Newbie (1/5)
2
Reputation
-
Yeah, what he said! ^^
-
Make sure the code runs in the <head> section of your HTML. <?php if($something = "something") { echo "<title>my title</title>"; } elseif($something = "somethingelse") { echo "<title>my title 2</title>"; } else { echo "<title>my title 3</title>"; } ?>
-
In need of a miracle. Some emails still not being received.
Clarkey replied to njdubois's topic in PHP Coding Help
There's some great help in this thread but Fastsol, can you explain why a Linode or DigitalOcean VPS wouldn't be capable of this? -
Read this, it explains and shows you how it works: http://www.wikihow.com/Create-a-Secure-Session-Managment-System-in-PHP-and-MySQL
-
PDO is great because it add an abstraction to the database, regardless of the database server type. For instance, if you use mysqli functions throughout your program, and then somebody else deploys the program but they are using postgres database server, then they would have to change every single function that interacts with a database for it to work. But, with PDO, they can just change one variable, and ta daaa!
-
How does one become great at php and mysql?
Clarkey replied to lexijensjacejack's topic in Miscellaneous
You've just got to keep going at it.. If you see something you don't understand, research it until you can make sense of it. Think of difference PHP classes / functions that you can create, and then keep trying to improve that class / function until it's solid and super fast. Once I understood the basics of PHP I moved onto learning object orientated PHP and grasped the concept of that. I was then able to study the methods used in popular PHP software packages, such as MVC-frameworks and forums to learn more about them. Just keep coding! -
You'd need to do something like this... (this code is not tested) <?php function unread_emails ($username , $password) { $hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; /* try to connect */ $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error()); /* grab emails */ $emails = imap_search($inbox,'UNSEEN'); echo count($emails)." "; echo "<pre>".print_r($emails,true)."</pre>"; //die; /* if emails are returned, cycle through each... */ if($emails) { $i=0; /* begin output var */ $output = ''; /* put the newest emails on top */ rsort($emails); /* for every email... */ foreach($emails as $email_number) { $i++; /* get information specific to this email */ $overview = imap_fetch_overview($inbox,$email_number,0); $message = imap_fetchbody($inbox,$email_number,1); /* output the email header information */ $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">'; $output.= '<span class="subject">'.$overview[0]->subject.'</span> '; $output.= '<span class="from">'.$overview[0]->from.'</span>'; $output.= '<span class="date">on '.$overview[0]->date.'</span>'; $output.= '</div>'; /* output the email body */ $output.= '<div class="body">'.$message.'</div>'; //if{$i==10} break; /* store this email in a database */ try { $dbh = new PDO('mysql:host=localhost;dbname=mydatabase', $dbuser, $dbpass); $sql = "INSERT INTO mytable (email_id, email_date, email_from, email_subject, email_body) VALUES (:email_id, :email_date, :email_from, :email_subject, :email_body)"; $qry = $dbh->prepare($sql); $qry->execute(array( ':email_id' => $email_number, ':email_date' => $overview[0]->date, ':email_from' => $overview[0]->from, ':email_subject' => $overview[0]->subject, ':email_body' => $message )); } catch (PDOException $e) { echo "PDO Error!: " . $e->getMessage() . "<br/>"; } } echo $output; } /* close the connection */ imap_close($inbox); } unread_emails ('**********@gmail.com' , '*******' ); ?>
-
Ok cool. Mark this thread as answered if your issue is resolved
-
Advanced Member Shadow_Walker, You say you get the error message of... Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed This means that you are using mysql_* functions that are too old. You need to upgrade to mysqli or PDO. I find it weird that you say the record is deleted, even though you get this error message. I would also suggest in getting into the habbit of putting error checks in place, such as mysql_error() or an exception block when you are developing your scripts, as they are designed to give you insight on why your code hasn't worked. More often that not, you've simply missed a character or something silly like that. In your first post on this thread, the link to delete a record is Delete.php but in your last post, the URL shows Admin_delete.php. What have you changed? I think it's best if you repost your latest code here, with your latest findings and we can help you troubleshoot.
-
If you look at the code Psycho provided to you, notice how he / she used if(!mysql_num_rows($result)) { to see how many rows have been returned by the query. If you have 0 returned rows, there are no results. It's a simple IF statement
-
It may not be PHP timing out. The web server that is actually serving the request (probably Apache or NGiNX) may have a 2 minute timeout set.
-
Try adding the if statement around the add_action function. I have never used the genesis framework so this is just a pure stab in the dark. By the way, the syntax looks weird in your if statement!? if(is_page_template( ,page_blog.php, ) { add_action('genesis_before_content_sidebar_wrap', 'child_before_content_sidebar_wrap'); }
- 4 replies
-
- php function
- genesis
-
(and 2 more)
Tagged with:
-
Are you visitors authenticated by a login system? Do you have a session system setup? If so, you can just do a SQL query using a WHERE clause based on some identifier from your $_SESSION array, such as a username or id (depends on how you've set it up) and then get the SQL array and echo them out where they need to go.
-
Access denied for user ''@'localhost' to database 'FltLogbook'
Clarkey replied to HeedAV8's topic in PHP Coding Help
Hmm, I'm a little confused... Are you thinking that your visitors user / pass are passed to the mysql function? If so, not at all. You have a special SQL user/pass that your website uses for SQL functions. If you want a login system, then you have to create that, it's completely seperate. -
Access denied for user ''@'localhost' to database 'FltLogbook'
Clarkey replied to HeedAV8's topic in PHP Coding Help
Heed, What usually happens is that you will have a config.php file which contains variables such as <?php $dbhost = "localhost"; $dbuser = "dbusername"; $dbpass = "dbpassword"; $dbname = "mydatabase"; ?> Then, whenever you need to connect to the database in different files, you can use this include statment before your database connect function. <?php include('config.php'); ?> and then your variables will work in that file too. Or, have I completely missed the point here?