Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

MySQL Insert with PHP

Name: Anonymous 2010-12-17 11:05

I can't figure this out. Something is wrong with my SQL insert statement, and I have no idea what it is. (I also tried setting the variables for all of the values to be input, ie $city = "test" but that didn't work either...halp!)


<form method="POST" action="hw8b.php">
    Name:<br />
    <input type="text" name="name1" /><br /><br />
    City:<br />
    <input type="text" name="city" /><br /><br />
    Email:<br />
    <input type="text" name="email" /><br /><br />
    <input type="submit" value="Insert">
    </form>



<?php

$DBConnect = mysql_connect("localhost", "howard", "");

if (! $DBConnect)
{
  echo "<P>Database not available";
}

$_POST["howard"];
$_POST["password"];

$name1 = $_POST["name1"];
$city = $_POST["city"];;
$email = $_POST["email"];

mysql_select_db("myDB");

$SQLstring = "SELECT MAX(ID) FROM FANS";
$QueryResult = mysql_query($SQLstring);
$Row = mysql_fetch_row($QueryResult);
$fanID = $Row[0] + 1;

$SQLstring = "INSERT INTO FANS VALUES(" . $fanID . ",'" . $name1 . "','" . $city . "','" . $email . "');";

$QueryResult = mysql_query($SQLstring);

Name: Anonymous 2010-12-17 11:11

Name: Anonymous 2010-12-17 11:11

Name: Anonymous 2010-12-17 11:20

>>3

Yep, I see no way to delete an old post, and I find it counter-productive to reply to a thread so convoluted with bullshit replies.

Name: Anonymous 2010-12-17 11:21

>>4
Well, you still have the same problems.

Name: Anonymous 2010-12-17 11:27

I know, problem is I can't for the life of me figure them out.

I looked up the proper syntax for inserts with php into a mysql table, and I have:

$SQLstring = "INSERT INTO FANS (FANID, NAME, CITY, EMAIL) VALUES ('5','Richard','Place','R@P.com');";


This doesn't do shit either.

Name: Anonymous 2010-12-17 11:43

Why did you make a new thread.

Name: Anonymous 2010-12-17 11:45

Hello, Howard.

Name: Anonymous 2010-12-17 16:08


<?php

$DBConnect = mysql_connect("localhost", "howard", "");

if (! $DBConnect)
{
  echo "<P>Database not available";
}

$userID = $_POST["howard"];
$password = $_POST["password"];

$name1 = $_POST["name1"];
$city = $_POST["city"];;
$email = $_POST["email"];

mysql_select_db("myDB") or die(mysql_error());

$SQLstring = "SELECT MAX(FANID) FROM FANS" or die(mysql_error());
$QueryResult = mysql_query($SQLstring);
$Row = mysql_fetch_row($QueryResult);
$newID = $Row[0] + 1;

$SQLstring = "INSERT INTO FANS (FANID, NAME, CITY, EMAIL) VALUES ($newID,$name1,$city,$email);" or die(mysql_error());
$QueryResult = mysql_query($SQLstring);

mysql_close($DBConnect);

?>


The PHP page loads, doesn't output any errors...but it doesn't fucking INSERT THE GOD DAMN FORM DATA.
WHYYYYYYYYYYYYYYYYYYYYYYYYYYY

Name: Anonymous 2010-12-17 16:10

>>9
add some fucking quotes or follow the links in your other thread goddamn stop being retarded

Name: Anonymous 2010-12-17 16:14

>>10

Dude I've added over 9000 quotes, removed quotes, tried different quotes, done a bunch of random shit...

if I put shit to select * from fans; and output it for each row incremented... it PRINTS the table. I know 100% that it's loading the table. I can't get it to FUCKING INSERT NO MATTER WHAT I FUCKING TRY TO PUT.

I've followed the goddamned links and tried a bunch of shit, none of which WORKS. I don't get why the insert doesn't work. I've tried fucking everything.

Name: Anonymous 2010-12-17 16:17

It's the motherfucking variables.

I added or die("name"); after the $name = $_POST["name1"];

and it printed "name"


HOW THE FUCK IS THE FORM DATA NOT BEING RECEIVED?

Name: Anonymous 2010-12-17 16:19

>>11
Does the user have the right permissions?

Name: Anonymous 2010-12-17 16:20

>>13

It should...I mean I can connect to the database in the PHP file, then print the contents of the table.

I assume I would also be able to insert data to the table...but it's not working.

Name: Anonymous 2010-12-17 16:41

http://php.net/mysql_error

Also, do your own homework.

Name: Anonymous 2010-12-17 16:43

Nigger nigger nigger nigger fuck fuck.

It was the single quotes I think. FINALLY figured this gay shit out.

Working final code:

<?php

$DBConnect = mysql_connect("localhost", "howard", "");

if (! $DBConnect)
{
  echo "<P>Database not available";
}

$userID = $_POST["howard"];
$password = $_POST["password"];

$name1 = $_POST["name1"];
$city = $_POST["city"];
$email = $_POST["email"];

mysql_select_db("myDB") or die(mysql_error());

$SQLstring = "SELECT MAX(FANID) FROM FANS" or die(mysql_error());
$QueryResult = mysql_query($SQLstring);
$Row = mysql_fetch_row($QueryResult);
$newID = $Row[0] + 1;

$SQLstring = "INSERT INTO FANS (FANID, NAME, CITY, EMAIL) VALUES ('$newID','$name1','$city','$email');" or die(mysql_error());
$QueryResult = mysql_query($SQLstring);

mysql_close($DBConnect);

?>

Name: Anonymous 2010-12-17 16:59

You're completely right, using correct syntax is totally gay.
That being said the real question is, why are you using a piece of shit wannabe database like MySQL, when you can get a perfectly fine Oracle database license for just $560?

Name: Anonymous 2010-12-17 17:04

Your code is still incorrect, or should I say insecure. Please do not pursue a career in programming.

Name: Anonymous 2010-12-17 17:14

>>18
Maybe it should see a counsellor.

Name: Anonymous 2010-12-17 17:30

>>17
You can download Oracle for free.

Name: Anonymous 2010-12-17 18:37

>>18
Typical smug PHP hater. "Oh, PHP is so insecure, Java is much faster."
Well fuck you, not everyone wants to learn Java, and PHP scales fine even facebook and youtube use it.

Name: Anonymous 2010-12-17 19:00

>>21
Pray explain what scaling and execution speed have to do with security.

Name: Anonymous 2010-12-17 19:47

>>21
*YOU* are full of bullshit.
Facebook uses a PHP→C++ compiler since they're too retarded to write anything but PHP. Youtube uses Python mostly, so I believe.
I have bitch tits.

Name: Anonymous 2010-12-17 20:47

>>23
Youtube uses both Python and PHP, and a heck of a lot of Javascript too. There's a handful of C extensions involved too, so I hear.

Name: Anonymous 2010-12-17 21:03

Quit talking to yourself.

Name: replica porsche watches 2011-06-01 22:29

As long as portray is a http://www.replica-watches-site.com , It is the http://www.replicawatcheshot.com  of the Moon. a http://www.replicawatcheshot.com  of rather basic purpose, It has admirers http://www.replicawatcheshot.com . since the watchmaking production realized wIth the purpose of http://www.replicawatcheshot.com/  on hand a http://www.replicawatcheshot.com/  opening, It hasn gone down wearing concerning make happy http://www.replica-watches-site.com . revive how on the practice on the road about make http://www.replicawatcheshot.com ? lost in aimed of a way to facilitate contents http://www.replicawatcheshot.com , one watchmakers even thought to it http://www.replicawatcheshot.com/  to dent the http://www.swisswatchesnet.com  to the dimension of a terminated http://www.swisswatchesnet.com  . added to though it http://www.replica-watches-site.com  , it was not glaring.

Name: fghfgh 2012-03-22 23:05

http://www.canuckshockeyshop.com/23-maxim-lapierre-jersey           Maxim Lapierre Jersey
http://www.canuckshockeyshop.com/27-ryan-johnson-jersey           Ryan Johnson Jersey
http://www.canuckshockeyshop.com/15-dan-hamhuis-jersey           Dan Hamhuis Jersey
http://www.canuckshockeyshop.com/21-manny-malhotra-jersey           Manny Malhotra Jersey
http://www.canuckshockeyshop.com/10-alexander-edler-jersey           Alexander Edler Jersey
http://www.canuckshockeyshop.com/14-christian-ehrhoff-jersey           Christian Ehrhoff Jersey
http://www.canuckshockeyshop.com/           Vancouver Canucks Jersey
http://www.canuckshockeyshop.com/           Canucks Jerseys
http://www.canuckshockeyshop.com/28-ryan-kesler-jersey           Ryan Kesler Jersey
http://www.canuckshockeyshop.com/26-roberto-luongo-jersey           Roberto Luongo Jersey
http://www.canuckshockeyshop.com/17-henrik-sedin-jersey           Henrik Sedin Jersey
http://www.canuckshockeyshop.com/29-trevor-linden-jersey           Trevor Linden Jersey
http://www.canuckshockeyshop.com/16-daniel-sedin-jersey           Daniel Sedin Jersey
http://www.canuckshockeyshop.com/25-rick-rypien-jersey           Rick Rypien Jersey
http://www.canuckshockeyshop.com/12-alexandre-burrows-jersey           Alexandre Burrows Jersey
http://www.canuckshockeyshop.com/24-pavel-bure-jersey           Pavel Bure Jersey
http://www.canuckshockeyshop.com/19-kevin-bieksa-jersey           Kevin Bieksa Jersey
http://www.canuckshockeyshop.com/22-mats-sundin-jersey           Mats Sundin Jersey
http://www.canuckshockeyshop.com/20-kirk-mclean-jersey-           Kirk Mclean Jersey
http://www.canuckshockeyshop.com/11-alexander-mogilny-jersey           Alexander Mogilny Jersey
http://www.canuckshockeyshop.com/18-jeff-tambellini-jersey           Jeff Tambellini Jersey

Name: Anonymous 2012-03-25 21:43

>>1
Fucking nice post! Badabababa I'm lovin' it!

Name: Anonymous 2012-03-26 7:10

INSERT INTO ANUS

Don't change these.
Name: Email:
Entire Thread Thread List