MasterACE14
-
Posts
2,687 -
Joined
-
Last visited
Posts posted by MasterACE14
-
-
I do not recommend you learn from w3schools. http://w3fools.com/
There is plenty of other decent resources out there, including those found on this very website.
-
C++ substr
in Other
never mind, I figured it out.
#include <iostream> #include <string> using namespace std; int main() { string text = "I do like the seaside"; cout << "Original: " << text << endl; cout << "Last character: " << text.at( text.size() - 1 ) << endl; cout << "Last 3 characters: " << text.substr( text.size() - 3 ) << endl; system("pause"); return 0; }
-
C++ substr
in Other
sorry, posted in wrong sub-forum.
-
C++ substr
in Other
I'm having trouble finding the last 3 characters of a string.
I have the following:
string something; char result; string last3; something = "12345"; result = something.length()-3; last3 = something.substr(result, 0); cout << last3 << endl;
I want it to output '345', but I'm getting '2'.
Any help is appreciated, thanks.
Regards,
Ace
-
welcome aboard!
-
Australia doesn't make the list? We invented the boomerang! makes hunting so much easier while riding our kangaroos.
-
date("M j, y, g:i a", $row['timestamp']);
-
ah true.
-
if(strpos($file, '#3#')){ echo "No results found"; }else{ echo "results has been found"; }
-
a better way would be
<?php include("config.php"); $content = $_POST['content']; $link = $_POST['link']; $title = $_POST['title']; $pass = $_POST['password']; $qry = "UPDATE sites SET content = '$content', link = '$link' WHERE title='$title' and password='$pass'"; mysql_query($qry) or die (mysql_error()); echo "Site Updated"; mysql_close($con); ?>
with correct validation and filtering on those POST's of course.
-
you could append time() to it, that's the easiest solution I can think of in the moment.
Or the other way of going about this would be to check the file names of what you're uploading against what already exists, if it already exists regenerate a new random number to append to it and run the check again, keep looping until the file name isn't taken.
-
I agree with litebearer's suggestion, your system does need to be slightly reworked.
<?php include("config.php"); mysql_query("UPDATE sites SET content = '$_POST[content]' WHERE title = '$_POST[title]' AND password = '$_POST[password]'"); mysql_query("UPDATE sites SET link = '$_POST[link]' WHERE title = '$_POST[title]' AND password = '$_POST[password]'"); echo "Site Updated"; mysql_close($con); ?>
that's not a very good way to get the job done.
-
<?php // it's best practice not to use short tags $qry = mysql_query( "SELECT * FROM tb_event ORDER BY `f_date` DESC LIMIT 1") or die(mysql_error()); // order by `f_date` or `id` in descending order, limit to 1 result while($res = mysql_fetch_array($qry)) { if ($res[f_status] == "Published") { // changed '=' to '==', so it compares rather than assigns echo ' <img src="images/uploads/'.$res[f_image].'" border="0" /> '; } else { echo ' ABCDE '; } } ?>
-
$q = mysql_query("SELECT `title` FROM `sites` WHERE `title`='".$_POST['title']."'");
sorry typo, should of been `sites` not `site`
-
<?php include("config.php"); $q = mysql_query("SELECT `title` FROM `site` WHERE `title`='".$_POST['title']."'"); if(mysql_num_rows($q) == 0) { $sql="INSERT INTO sites (title, content, link, password) VALUES ('$_POST[title]','$_POST[content]','$_POST[link]','$_POST[password]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Site has been registered. Please check the homepage."; } else { echo "A site with that title already exists."; } mysql_close($con) ?>
You need some validation and filtering, this is very insecure.
-
just run a query to select titles where they match the user entered title, check the number of rows, if it's zero, then run the insert query otherwise display a 'title taken' message.
-
is that extra 's' a typo, or the actual column name?
$row['Passsword001']
-
suppressing warnings/notices with '@' isn't doing you any favours.
-
And even dial-up ...for being dial-up was slower, and rarely kept you connected. I think I can still hear those annoying screeches and beeps to this day.
Good times
-
if($code == '')
or...
if(empty($code))
-
$code = highlight_string($rows['code'], true);
-
I think you're after highlight_string()
-
not to mention the people lagging behind on PHP 4.
-
I am intending to build my own email service
who has the time? lol
Making my debut... :)
in Introductions
Posted
You'll have a blast here.