Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP white screen of death every time. What am I doing wrong?
    primarykey
    data
    text
    <p>I'm a complete noob to PHP and working with mysql so you know I do however have a great deal of experience with HMTL and CSS. All I need is for a form on my site to upload the information in the form to my database. The problem is that clicking the "submit" button just opens up a blank tab with the address of my .php file in it and displays a blank white screen. The .php is below. </p> <pre><code>&lt;?php $hostname = "myHostName"; $username = "PreRegCustomers"; $dbname = "PreRegCustomers"; $password = "myPassword"; $usertable = "CustomerInfo"; mysql_connect($hostname, $username, $password) OR DIE ("Unable to connect to database! Please try again later."); mysql_select_db($dbname); $sql = "INSERT INTO $usertable (firstName, lastName, streetAddress, city, state, zip, country, email, phone, badgeName) VALUES ('$firstName', '$lastName', '$streetAddress', '$city', '$state', '$zip', '$country', '$email', '$phone', '$badgeName')"; $sql="INSERT INTO $usertable (firstName, lastName, streetAddress, city, state, zip, country, email, phone, badgeName) VALUES ('".$_POST[firstName]."', '".$_POST[lastName]."', '".$_POST[streetAddress]."', '".$_POST[city]."', '".$_POST[state]."', '".$_POST[zip]."', '".$_POST[country]."', '".$_POST[email]."', '".$_POST[phone]."', '".$_POST[badgeName]."')"; ?&gt; </code></pre> <p>Now from what I've read this is usually caused by some kind of error in the code. This is difficult for me as I don't know PHP very well and almost everything in the page was taken from other peoples code. Most of it from the code helps from godaddy.com (where the site and database are hosted).</p> <p>I've tested to make sure that PHP is supported and enabled and it is. I have a form mailer that already functions just fine. I have setup a DNS, I have tried multiple different syntaxes, I have called tech support to see if it is something on their end, I've migrated my sites from windows to linux and every thing I change results in the exact same blank white screen. I have no doubt that after all this it's going to be something that's stupidly easy to fix or blatantly obvious but if anybody could take a look and see what I'm missing I would be very grateful. </p> <p><strong>My new code after taking in some of the answers posted. I'm still getting a NOTICE and it's still not inserting anything into my database.</strong></p> <pre><code>&lt;?php error_reporting(E_ALL); ini_set('display_errors', '1'); $hostname = "myHostName"; $username = "PreRegCustomers"; $dbname = "PreRegCustomers"; $password = "myPassword"; $usertable = "CustomerInfo"; //connect to mysql $link_id = mysql_connect($hostname, $username, $password); if (!$link_id) { die("Unable to connect to database! Please try again later. error:".mysql_errno()); } //make sure your DB exists if (!mysql_select_db($dbname)) die ("Connected to mysql but could not connect to the DB. error:".mysql_errno()); //avoid sql_injection $firstName = mysql_real_escape_string($_POST['firstName']); $lastName = mysql_real_escape_string($_POST['lastName']); $streetAddress = mysql_real_escape_string($_POST['streetAddress']); $city = mysql_real_escape_string($_POST['city']); $state = mysql_real_escape_string($_POST['state']); $zip = mysql_real_escape_string($_POST['zip']); $country = mysql_real_escape_string($_POST['country']); $email = mysql_real_escape_string($_POST['email']); $phone = mysql_real_escape_string($_POST['phone']); $badgeName = mysql_real_escape_string($_POST['badgeName']); //write the query $sql = "INSERT INTO $usertable (firstName, lastName, streetAddress, city, state, zip, country, email, phone, badgeName) VALUES ('$firstName', '$lastName', '$streetAddress', '$city', '$state', '$zip', '$country', '$email', '$phone', '$badgeName')"; //then you'll need to execute the query :) mysql_query($sql); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload