Jump to content

atticus

Members
  • Posts

    176
  • Joined

  • Last visited

About atticus

  • Birthday 04/19/1980

Contact Methods

  • Website URL
    http://www.mywebtronics.com

Profile Information

  • Gender
    Male
  • Location
    Atlanta

atticus's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. I get an undeclared object error if I simply include the config.php file in either the parent page or the functions.php page. This is the config.php script: $mysqli = new mysqli("***"); /* check connection */ if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } This is the functions page: include 'config.php'; function calls($duplicates) { if ($duplicates == 0) { if ($result = $mysqli->query("SELECT * FROM calls WHERE duration >= 30")) { printf("Select returned %d rows.\n", $result->num_rows); } else {printf ("Errormessage: %s\n", $mysqli->error); } $result->close(); } else { } } So, I have to move the config.php file into the function in order to execute the query. I know this is a noob question, but I am just learning object oriented. Thanks in advance.
  2. I don't know, but does MySQL need an additional " at the end of line 1?
  3. I know this must be a syntax error. This is the error: Errormessage: Unknown column 'thisiserror' in 'field list' Whatever variable I use in the URL for referrermedium is listed as the unknown column: call.php?duration=127&callsource=callsource&datetime=datetime&trackingnum=123&callernum=3433&destinationnum=destinationnum&recording=recording&callername=callername&keywords=keywords&referrer=referrer&referrermedium=thisiserror&landingpage=landingpage Code: <?php $callsource = $_GET['callsource']; $duration = $_GET['duration']; $datetime = $_GET['datetime']; $trackingnum = $_GET['trackingnum']; $callernum = $_GET['callernum']; $destinationnum = $_GET['destinationnum']; $recording = $_GET['recording']; $callername = $_GET['callername']; $keywords = $_GET['keywords']; $referrer = $_GET['referrer']; $referrermedium = $_GET['referrermedium']; $landingpage = $_GET['landingpage']; if ($mysqli->query("INSERT INTO calls (`callsource`, `duration`, `datetime`, `trackingnum`, `callernum`, `destinationnum`, `recording`, `callername`, `keywords`, `referrer`, `referrermedium`, `landingpage`) VALUES ($callsource, $duration, $datetime, $trackingnum, $callernum, $destinationnum, $recording, $callername, $keywords, $referrer, $referrermedium, $landingpage);") === TRUE) { printf("Item inserted\n"); } else {printf ("Errormessage: %s\n", $mysqli->error); } ?>
  4. You are right Pikachu2000, I wasn't inserting anything into the id column so I needed to list fields explicitly. Thanks man!
  5. The following query outputs rows: if ($result = $mysqli->query("SELECT option_name FROM wp_options LIMIT 10")) { printf("Select returned %d rows.\n", $result->num_rows); } This must be the troubled code: if ($mysqli->query("INSERT INTO leads_main VALUES('$service','$form','$confirmation','$special','$function')") === TRUE) { printf("data inserted.\n"); }
  6. I checked the connection with mysqli ping and it says its ok: /* check if server is alive */ if ($mysqli->ping()) { printf ("Our connection is ok!\n"); } else { printf ("Error: %s\n", $mysqli->error); }
  7. This code is not presenting error messages and is not inserting the data as expected. Anything I'm missing? ///DB Connection $mysqli = new mysqli("localhost", "***", "***", "***"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } ////Hidden Form Information $service = $_GET['service']; $form = $_GET['form']; $confirmation = $_GET['confirmation']; $special = $_GET['special']; $function = $_GET['function']; ////Insert into DB and confirm if ($mysqli->query("INSERT INTO leads_main VALUES('$service','$form','$confirmation','$special','$function'") === TRUE) { printf("Table myCity successfully created.\n"); }
  8. I know that I am missing something simple, probably in my syntax. But I am getting a 500 server error instead of a PHP error. Not sure why Here is the total associative array query: $query = "SELECT address, zip, square_footage FROM person WHERE person_id = $id"; if ($result = $mysqli->query($query)) { /* fetch associative array */ while ($row = $result->fetch_assoc()) { $message .= '\n <strong>Square Footage: </strong>' .$row["square_footage"]; $message .= '\n <strong>Address </strong>' .$row["address"]; $message .= '\n <strong>Zip </strong>' .$row["zip"]); } /* free result set */ $result->free(); } If I remove the following three lines, I no longer get an error: $message .= '\n <strong>Square Footage: </strong>' .$row["square_footage"]; $message .= '\n <strong>Address </strong>' .$row["address"]; $message .= '\n <strong>Zip </strong>' .$row["zip"]);
  9. Okay, I feel like an idiot...should be using UPDATE instead of INSERT
  10. Should I be using a different error reporting method with mysqlli instead of "or die"?
  11. Name is Name on form. Echo $name confirms $_POST is working.
  12. I have verified all connection and table data is connect. I typically do not use mysqlli. What am I doing wrong: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $id = $_POST['id']; $name = $_POST['Name']; $email = $_POST['Email']; $phone = $_POST['Phone']; $city = $_POST['City']; echo $name; ////// Connect to DB $mysqli = new mysqli("db", "user", "pass", "db"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "INSERT INTO person(name,email,phone,city) VALUES ('$name','$email','$phone','$city') WHERE person_id = $id" or die('Could not connect: ' . mysql_error()); $mysqli->query($query); ?>
×
×
  • 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.