|
Posted by Krustov on 10/30/09 11:33
<comp.lang.php , John Oliver , joliver@john-oliver.net>
<slrndovhp6.94a.joliver@ns.sdsitehosting.net>
<02 Dec 2005 04:01:51 GMT>
> I know absolutely nothing about this. I've been banging around various
> tutorials. Most just sort of skip over this. The closest I came is:
>
> http://www.freewebmasterhelp.com/tutorials/phpmysql/4
>
> However, their example:
>
> $query = "INSERT INTO contacts VALUES
> ('','$first','$last','$phone','$mobile','$fax','$email','$web')";
>
> doesn't work, and got me a "Learn how to use SQL Injection" comment.
>
> I need a tutorial that explains this stuff. I don't have the vaguest
> clue what I'm doing, and when the tutorial assumes any pre-existing
> knowledge, I get left behind pretty quickly.
>
I'd say you need to learn how to walk first before trying to run .
Would you give somebody a full auto AK47 as their first learning how to
shoot lesson ? .
Start by learning how to put a single item into the database - and once
thats done you can try changing it to add 2 items etc .
Or if that doesnt work then you could try the following I took from a
old website I had sitting on the hard disk .
uzi.php
<?php
$host="localhost";
$login="ganthc_jobbyzx";
$pass="gan_poo";
$base="ganthc_potw";
?>
This file holds your database connection details , Its from a old
account and I havent changed anything & they are just what I called them
when I set up the mysql database in the web host control panel .
This has the advantage you dont need to type them in every time you want
to connect to your database .
<?php include ("uzi.php"); ?>
This line should be at the top of every webpage that uses or connects to
your database .
<?php
$temp="demo";
$qaz = $_SERVER['REMOTE_ADDR'];
$wsx = date("l dS of F Y h:I:s A");
$rfv = $_SERVER['HTTP_REFERER'];
$edc = substr("$rfv",0,50);
?>
<?php
$db = mysql_connect($host,$login,$pass); mysql_select_db($base,$db);
$query = mysql_query("SELECT iipp FROM cwin WHERE hold='$temp';",$db);
$myrow = mysql_fetch_array($query);
$grab=$myrow["iipp"];
mysql_close($db);
?>
<?php
$db = mysql_connect($host,$login,$pass); mysql_select_db($base,$db);
$result = mysql_query("UPDATE cwin SET count=count+1 WHERE
hold='$temp'");
$result = mysql_query("UPDATE cwin SET iipp='$qaz' WHERE hold='$temp'");
$result = mysql_query("UPDATE cwin SET deta='$wsx' WHERE hold='$temp'");
$result = mysql_query("UPDATE cwin SET reff='$edc' WHERE hold='$temp'");
mysql_close($db);
?>
- iipp
- cwin
- etc
Are the actual field names in the mysql database and obviously I dont
know what you do or dont use on your own database .
Needless to say you will need to create suitable matching tables in your
own mysql database if you dont want to edit anything in the above .
Trial and error is the only real way to learn .
BTW: all the above is newbie stuff and probably not the best way to do
it in the fact I cant really remember what each line does - so i'm
unable to help you any further than I already have .
Navigation:
[Reply to this message]
|