Jump to content

INSERT INTO trouble


ajetrumpet

Recommended Posts

could someone help me with this.  here is what I have:

 

<?php require_once('dbinfo.php'); ?>

<?php

mysql_connect($dbaddress,$username,$password);
mysql_select_db($db) or die("Cannot find database!");

/*
$query = "SELECT * FROM contacts";
$result = mysql_query($query);
$numRows = mysql_numrows($result);
$i = 0;

while ($i < $numRows) {
	echo mysql_result($result, $i, "first") . " " . mysql_result($result, $i, "last");
		$i++;
					  }

*/

$fname = 'WrdScramble()';
$ftype = 'DAO';
$fdesc = 'Randomly rearranges the characters in a string or word.';
$fcode = '';

$query = "INSERT INTO functions VALUES ('','$fname','$fcode','$ftype','$fdesc')";
mysql_query($query);
print($query);

//$query = "SELECT fcode FROM contacts WHERE first = 'code'";
//$result = mysql_query($query);
//$numRows = mysql_numrows($result);
//$fcode = mysql_result($result, 0, "fcode");

?>


<?

//close connection
mysql_close();

?>

 

It is not inserting the data into the database, and if I use:

 

mysql_error()

 

and print it out, I get nothing with that either.  I am not sure where to go!  I also have used this:

 

(fid, fname, fcode, ftype, fdesc)

 

preceeding the 'VALUES' word in the statement just to see if it would take.  No luck!  Do I not see the obvious?  Any help appreciated!  thanks!  (I have checked my field types and max length in PHPmyadmin and they are not an issue.)

Link to comment
Share on other sites

yes I have.  the first one I put in was successful and it was the first and only one I did.  the syntax I used was the same too.

 

this is what I have inserted at the end of the page:

 

 

if (!$query) {echo(mysql_error());}

 

 

I am getting a blank page. NOTHING else.  which is what I am supposed to see really, unless there is an error.  thank you!

Link to comment
Share on other sites

How would anyone here be able to tell you if that query is correct or not. You are the only one here who knows what your table definition is.

 

And that's not a suggestion to post you table definition. It's a suggestion for you to troubleshoot what your code and query are doing on your server and with your database.

 

Fix your code that is using mysql_error() and it will tell you why the query is failing.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.