I'm trying to take some links and store them in a MySQL table. Its not storing the data but I am getting an error message(the one that says "idk man, it didnt get in there"). I'm just not sure what I'm doing wrong. Here's what I have so far:
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
else
{
echo "<font color='#00FF00'>CONNECTED TO DATABASE SUCCESSFULLY</font><br>";
}
//find open link record and insert
foreach ($result as $wtf)
{
//now show me
mysqli_query ($conn,"INSERT INTO carads (adlink) VALUES ('$wtf')");
echo "<font color='#FFFFFF'>INSERTING LINK INTO DATABASE: $wtf</font><br>";
}
$sql="SELECT 'adlink' FROM 'carads'";
$sqlresult = mysqli_query($conn,$sql );
//if its messed up tell me now
if
( !$sqlresult)
{
echo mysqli_error($conn);
die("<font size='20' color='#FF0000'>idk man, there was an error and the dataset didnt get in there</font><br>") ;
}
if ($sqlresult = mysqli_query($conn,$sql))
{
// Return the number of rows in result set
$rowcount=mysqli_num_rows($sqlresult);
print_r ("<font size='18' color='#00FF00'>Car ads Database has %d ADLINKS from current city.\n</font><br>",$rowcount);
// Free result set
mysqli_free_result($result);
}
//close the connection
mysqli_close($conn);
Once again, Im all turned around here and needing a little help from smart people. Why is it not storing the links in the database?
mysqli_error($conn);give thiserrornot the one you giving us at the moment