Jump to content

Why no workee?


badgerchap

Recommended Posts

This is a pretty simple bit of code, taken from a template on w3schools.com. For some reason though, it doesn't clear my table. I've tried exactly the same but with TRUNCATE TABLE. It's not the $ipaddress as the table name, as a) that works fine with other commands elsewhere in my site and b) I've tried the same commands with a simpler table name. I've messed around with this now and I'm out of ideas! No error is being returned, and to all intents and purposes it seems as if the command has gone through, but the table remains resolutely full of data :/ Any help please? Thanks in advance.

 

<?php

$con=mysqli_connect("*********","*****","*****","*********");

// Check connection

if (mysqli_connect_errno())

  {

  echo "Failed to connect to MySQL: " . mysqli_connect_error();

  }

$ipaddress=$_SERVER["REMOTE_ADDR"];

 

mysql_query($con,"DELETE FROM `".$ipaddress"` WHERE Quantity!=='0'");

mysqli_close($con);

?>

 

Link to comment
https://forums.phpfreaks.com/topic/281125-why-no-workee/
Share on other sites

you are making a mysqli connection (with an i), but trying to use a mysql_query() (no i).

 

all your database functions must be of the same type, you cannot mix calls to the different database libraries. if you had php's error reporting set to E_ALL and display_errors set to on so that php would help you by reporting and displaying the errors it detects, you would have been getting a error pointing to the problem ($con isn't a mysql_ connection.)

 

also, i'm pretty sure !== isn't a valid mysql database comparison operator and is probably causing a query error.

Link to comment
https://forums.phpfreaks.com/topic/281125-why-no-workee/#findComment-1444769
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.