Web Dev Questions That Don't Need Their Own Thread v4
5,001 replies, posted
[QUOTE=grunewald;44424716]and here is my PHP
[php]
<?php
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO articles (Num, Name, Content) VALUES ('$_POST[Num]','$_POST[Name]','$_POST[Content]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
?>
[/php][/QUOTE]
[I]hehehehe, I saw that.[/I]
The problem is that MySQL is inserting, literally, $_POST[Num] (which should be ['Num'] by the way).
If you want to risk a SQL injection (and fix that), you should close the printed part with the same ' or '" that you started it with.
Example,
VALUES ('".$_POST['Num']."',
->VALUES ('Post_num_which_could_be_a_hack_attempt', '.....
[QUOTE=grunewald;44424716]i am trying to save a MEDIUMTEXT in MySQL database, it IS connected.
when i view my database the MEDIUMTEXT somehow din't pass..
here is my html..
[html]
<form action="insert.php" method="post">
Num: <input type="text" name="Num">
Name: <input type="text" name="Name">
Content: <TEXTAREA name="Content" ROWS=4 COLS=40></TEXTAREA>
<input type="submit">
</form>
[/html]
and here is my PHP
[php]
<?php
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO articles (Num, Name, Content) VALUES ('$_POST[Num]','$_POST[Name]','$_POST[Content]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
?>
[/php][/QUOTE]
To solve your problem, when you reference values in an array by name, you need to add qoutes around the name like:
[php]
$array['name']
$array["name"]
[/php]
Second, I dont think you can reference arrays directly in "" unlike normal variables (correct me if I'm wrong). Thirdly, you should sanitize your input.
[php]
$sql=mysqli_real_escape_string($con,"INSERT INTO articles (Num, Name, Content) VALUES ('".$_POST['Num']".
,'".$_POST['Name']."','".$_POST['Content']."')");
[/php]
You can use brackets, like
[code]$sql="INSERT INTO articles (Num, Name, Content) VALUES ('{$_POST['Num']}','$_POST[Name]','{$_POST['Content']}')";[/code]
[QUOTE=Moofy;44419869]If looking for a grid system, just for the grid. What would you guys recommend?
I see lots liking skeleton, though isn't that quite old by now?
Or are we in the "make your own personal grid system" time now? :v:[/QUOTE]
The best grid systems to use at the minute are ones which you can use with preprocessors. E.g. [url=http://neat.bourbon.io/]Bourbon Neat[/url].
Rather than adding grid classes to elements (which isn't semantic, i.e. you're mixing presentation with markup), you extend the grid class on a selector.
[QUOTE=rieda1589;44427986]The best grid systems to use at the minute are ones which you can use with preprocessors. E.g. [url=http://neat.bourbon.io/]Bourbon Neat[/url].
Rather than adding grid classes to elements (which isn't semantic, i.e. you're mixing presentation with markup), you extend the grid class on a selector.[/QUOTE]
Yea I noticed, though not using SASS myself. Been experimenting with LESS and just kinda sticked to it. I guess I'll try and search for something for LESS though
[QUOTE=Gerkin;44424408]Quick 2 questions:
1) I know PHP, but between RoR, Python, and Node.js, which do you think add more value to your resume? Which are currently more in-demand for jobs?
2) My knowledge in PHP is decent. But I'm wondering would it be better to just focus on PHP and try and master it as much as possible, or is it better to be more well-rounded with more languages (jack of all trades, master of none)?[/QUOTE]
Go check out craigslist or something similar and find out what is the demand in your area (in most cases is PHP), then try messing around with other languages and stick with the demand and your favorite.
[QUOTE=pdkm931;44425063]Thirdly, you should sanitize your input.
[php]
$sql=mysqli_real_escape_string($con,"INSERT INTO articles (Num, Name, Content) VALUES ('".$_POST['Num']".
,'".$_POST['Name']."','".$_POST['Content']."')");
[/php][/QUOTE]
That doesn't do anything senseful at all because you're escaping [i]the entire SQL query[/i], not just the stuff that's meant to be escaped, so this won't work.
[QUOTE=supersnail11;44426343]You can use brackets, like
[code]$sql="INSERT INTO articles (Num, Name, Content) VALUES ('{$_POST['Num']}','$_POST[Name]','{$_POST['Content']}')";[/code][/QUOTE]
That's vulnerable to SQL injection, if it even works.
How about doing it the right way with parameterized queries?
[cpp]
<?php
$db = new mysqli("host", "username", "password", "database");
if ($mysql->connect_errno) {
die("Failed to connect to the database: " . $db->connect_error);
}
$stmt = $db->prepare("INSERT INTO articles (Num, Name, Content) VALUES (?, ?, ?)");
$stmt->bind_param("s", $_POST["Num"]);
$stmt->bind_param("s", $_POST["Name"]);
$stmt->bind_param("s", $_POST["Content"]);
$success = $stmt->execute();
$stmt->close();
if($success) {
echo "1 record added.";
} else {
echo "Things broke: " . $db->error;
}
?>
[/cpp]
It's untested and I'm far from a PHP expert, so your mileage may vary.
[QUOTE=Alternative Account;44434310]That's vulnerable to SQL injection, if it even works.[/QUOTE]
I was just explaining how to use arrays in strings, people had mentioned SQL injection before.
[QUOTE=Alternative Account;44434310]That doesn't do anything senseful at all because you're escaping [i]the entire SQL query[/i], not just the stuff that's meant to be escaped, so this won't work.
That's vulnerable to SQL injection, if it even works.
How about doing it the right way with parameterized queries?
[cpp]
<?php
$db = new mysqli("host", "username", "password", "database");
if ($mysql->connect_errno) {
die("Failed to connect to the database: " . $db->connect_error);
}
$stmt = $db->prepare("INSERT INTO articles (Num, Name, Content) VALUES (?, ?, ?)");
$stmt->bind_param("s", $_POST["Num"]);
$stmt->bind_param("s", $_POST["Name"]);
$stmt->bind_param("s", $_POST["Content"]);
$success = $stmt->execute();
$stmt->close();
if($success) {
echo "1 record added.";
} else {
echo "Things broke: " . $db->error;
}
?>
[/cpp]
It's untested and I'm far from a PHP expert, so your mileage may vary.[/QUOTE]
[cpp]
$stmt->bind_param("sss", $_POST["Num"], $_POST["Name"], $_POST["Content"]);
[/cpp]
Why not just this?
[editline]3rd April 2014[/editline]
Although I assume Num is a int in which case you can do
[cpp]
$stmt->bind_param("iss", $_POST["Num"], $_POST["Name"], $_POST["Content"]);
[/cpp]
Better to use PDO for the named parameters.
[url]http://facepunch.com/showthread.php?t=1134070#post44111825[/url]
Been spending some more time on customizing my Sublime Text a bit more recently. So basically line padding, font sizes, colors, themes and much more. The one thing I can't get down is the font.
I see a lot liking Monaco, I even got it myself and every screenshot I see looks good. But then when I try it, it looks so thin. Putting on bold makes it too thick, it's really weird because the screenshots makes it look really good.
Is there any font you can recommend/use? Right now really just using the default one because every font so far failed me.
Also, read a lot of blog posts with "Best programming fonts" - But the images always promised more than what I got.
[QUOTE=Moofy;44439398]Is there any font you can recommend/use? Right now really just using the default one because every font so far failed me.[/QUOTE]
What's wrong with the default one?
i only like how monaco looks with gdipp, have you tried that?
[QUOTE=TrinityX;44439564]What's wrong with the default one?[/QUOTE]
This might sound strange, but nothing. Honestly I just like customizing every single bit as possible.
[QUOTE=Kwaq;44439566]i only like how monaco looks with gdipp, have you tried that?[/QUOTE]
Nope, isn't that some sort of text rendering? I think I heard about it before.
TO THE GOOGLES!
[editline]3rd April 2014[/editline]
so trying gdipp, this is the result: (monaco font)
[t]http://i.imgur.com/fcVzNMb.png[/t]
(minimum font size of 12 though, otherwise it looks weird.)
Also everything looks so different right now, it's like a whole new experience :v:
[QUOTE=CBastard;44438734]Better to use PDO for the named parameters.
[url]http://facepunch.com/showthread.php?t=1134070#post44111825[/url][/QUOTE]
Looking at that example, yeah. That looks [i]way[/i] nicer.
[QUOTE=Moofy;44439398]
Also, read a lot of blog posts with "Best programming fonts" - But the images always promised more than what I got.
[/QUOTE]
My favorite is [url=http://www.tobias-jung.de/seekingprofont/]ProFont[/url] with a size 12. Easily readable even at smaller sizes, and I prefer smaller sizes so I can fit more code on my screen rather than having to scroll a lot.
[QUOTE=Moofy;44439398]
Is there any font you can recommend/use? Right now really just using the default one because every font so far failed me.
[/QUOTE]
Have you seen this one? [url]http://hivelogic.com/articles/top-10-programming-fonts[/url] Although in the pictures I think they took the pictures on a Mac where as I'm on Windows so it doesn't look EXACTLY like the pictures.
[QUOTE=Moofy;44439398]
Also, read a lot of blog posts with "Best programming fonts" - But the images always promised more than what I got.[/QUOTE]
The quality of the font rendering also depends on the operating system and its configuration. As you seem to be on Windows, you might want to have a try at configuring ClearType to what you prefer.
[QUOTE=Gerkin;44440376]
Have you seen this one? [url]http://hivelogic.com/articles/top-10-programming-fonts[/url] Although in the pictures I think they took the pictures on a Mac where as I'm on Windows so it doesn't look EXACTLY like the pictures.[/QUOTE]
As I said, I checked most of those. I also said I was aware of the screenshots.
gdipp solved the rendering making it look smooth, however just some bugs in some programs unfortunately.
[editline]3rd April 2014[/editline]
[QUOTE=Alternative Account;44440398]The quality of the font rendering also depends on the operating system and its configuration. As you seem to be on Windows, you might want to have a try at configuring ClearType to what you prefer.[/QUOTE]
ClearType is also some text-rendering like gdipp?
ClearType is a built in tool for Windows that let's you change the text rendering slightly.
[QUOTE=alexanderk;44440557]ClearType is a built in tool for Windows that let's you change the text rendering slightly.[/QUOTE]
Not any big change with it, very very VERY minor.
[QUOTE=Moofy;44440405]
ClearType is also some text-rendering like gdipp?[/QUOTE]
It's Microsoft's implementation of subpixel rendering for fonts, which is what makes the characters nice and anti-aliased. [url=http://windows.microsoft.com/en-us/windows/make-text-easier-read-cleartype#1TC=windows-7]Here[/url] is how you can change this setting. It also does hinting.
It seems like there's also a [url=https://www.typotheque.com/articles/hinting]not too subtle difference[/url] between how fonts are hinted on Windows and Mac OS X, leading to different text appearance.
Hinting is a necessary step for high-quality font rendering, as fonts in the TrueType format are not bitmap fonts - the glyph outlines are represented as Bézier curves, which allow infinite precision and scaling. This is neat for when you're able to show the glyphs at a nice and high dot/pixel density, like in print. According to what I've read, the pixel density for line art (which includes text) tends to range from 300 dpi to 1200 dpi in magazines. But on desktops, glyphs are displayed at a comparatively tiny pixel density, typically 96 ppi. This means that there's only a teensy amount of pixels available to display each glyph. On Facepunch, each line of text in the forum posts gets a mere 16 pixels of vertical space for the glyphs, and characters like "e" or "r" are only 7 pixels tall.
The tiny vertical and horizontal resolution of each glyph [url=http://courses.engr.illinois.edu/ece390/archive/archive-f2000/mp/mp4/solidfill.png]doesn't play well together[/url] with the infinitely precise curves. Hinting allows the font's curves to be automatically modified so the font is more legible, as you can see in [url=http://www.paratype.com/pictures/services/hinting3.gif]this image[/url]. Both designers, font creation software as well as the font rendering systems can influence this process.
The difference between Windows and Mac OS X seems to lie in how they process hinting data in the font files, as well as how they lay out the font on the pixel grid, so that's why [url=http://www.metaltoad.com/sites/default/files/font-face-comparison.png]things look different[/url]. Western fonts are more subtly affected by hinting, by the way - if you're dealing with Japanese, Chinese or Korean text, font rendering can differ [url=http://i.stack.imgur.com/0eWv9.jpg]quite dramatically[/url].
[QUOTE=Alternative Account;44441013]-text-[/QUOTE]
Yea I can see the differences, I've been using gdipp now. It annoys me however there's some bugs in certain programs like skype. I really like a nice anti aliased font, but ClearType doesn't really cut it. Perhaps I should just remove gdipp and stick to the default font of Sublime Text or look for something that renders good on Windows.
[QUOTE=Moofy;44439398]Been spending some more time on customizing my Sublime Text a bit more recently. So basically line padding, font sizes, colors, themes and much more. The one thing I can't get down is the font.
I see a lot liking Monaco, I even got it myself and every screenshot I see looks good. But then when I try it, it looks so thin. Putting on bold makes it too thick, it's really weird because the screenshots makes it look really good.
Is there any font you can recommend/use? Right now really just using the default one because every font so far failed me.
Also, read a lot of blog posts with "Best programming fonts" - But the images always promised more than what I got.[/QUOTE]
I still haven't been able to find anything that I like more than Inconsolata and I've used a LOT of different fonts in sublime.
[QUOTE=KmartSqrl;44441314]I still haven't been able to find anything that I like more than Inconsolata and I've used a LOT of different fonts in sublime.[/QUOTE]
Haha I tried that, still shitty text render on Windows ;)
[t]http://i.imgur.com/nqKPh1n.png[/t]
[QUOTE=Moofy;44441495]Haha I tried that, still shitty text render on Windows ;)[/QUOTE]
Have you actually tried adjusting ClearType?
There's some program you can download to get a nicer text render as well, I don't remember the name of it
[QUOTE=TrinityX;44442365]Have you actually tried adjusting ClearType?[/QUOTE]
Yep.
[QUOTE=djjkxbox360;44443302]There's some program you can download to get a nicer text render as well, I don't remember the name of it[/QUOTE]
You mean [B]gdipp[/B] which was mentioned in a previous reply?
he is most likely talking about mactype; which is really similar!
you can also set mactype to run on only specific applications, which is nice if you don't want to ruin windows font rendering on everything.
you should just switch to linux for development if this stuff is heating you up this much :v:
[QUOTE=Kwaq;44448410]he is most likely talking about mactype; which is really similar!
you can also set mactype to run on only specific applications, which is nice if you don't want to ruin windows font rendering on everything.
you should just switch to linux for development if this stuff is heating you up this much :v:[/QUOTE]
I used to use Linux on my laptop, until I poured water on it :suicide:
It's not heating up much, just thought I wanted a cleaner font and then Windows does this bullshit.
gdipp also has the feature of applying to specific programs too
Deep-Web websites ussally look like shit, mostly because they serve a shady-purpose rather than a reliable service, lack of javascript makes this worse.
CSS3 Animations as well as animated.gif's etc I can hack a site into looking good with smoke and mirrors without javascript.
If I accept bitcoin as payment. Do you guys think there is a market for this?
Especially since THAT torrent site is looking to make a p2p browser (the bundled one is getting more attention), there might be more interest in this as well.
I can imagine there are a few sites that MIGHT just be interested in looking better than frontpage tier shit.
Should I try this out or is it a fruitless/foolish venture?
I don't think there are any web developers looking to fill this market.
Sorry, you need to Log In to post a reply to this thread.