cdc5205
-
Posts
5 -
Joined
-
Last visited
Never
Posts posted by cdc5205
-
-
no you shouldn't have to, id o it all the time, did you remove the $conn var from the mysql_query and you are selecting a database in connect.php? mysql_select_db("mydb");
-
are you getting an error at the die() statement? try not making $result a var.
[code]<?php
session_start();
if(isset($_SESSION['random'])) {
//do nothing
}
else
{
$newid = rand(1,9999999);
$_SESSION['random'] = $newid;
include("../connect.php");
$sql = "INSERT INTO answers (id) VALUES ('$newid')";
mysql_query($sql) or die("An error has occured - Please contavt admin stating error @ point A1" . mysql_error());
}
?>[/code] -
show all the code you have, you are making a connection to the db right at $conn?
-
[code]$sql = "INSERT INTO answers (id) VALUES ('$newid')";[/code]
INSERT command shortcut
in PHP Coding Help
Posted
mysql_connect("localhost","un","pw");
mysql_select_db("dbname");
$bob="Bob";
mysql_query("INSERT INTO users(username) VALUE ('$bob')") or die("query" .mysql_error());
echo "done";
?>[/code]
i just typed this and tested it and it works