Jump to content

EmperorJazzy

Members
  • Posts

    72
  • Joined

  • Last visited

    Never

Everything posted by EmperorJazzy

  1. My suggestion is stripping the $price variable of any . or , or $ The presence of the . in the price of $29.000.00 could be causing an issue.
  2. Howdy, I'm utilising a random number as an ID for each new object created. At the creation stage (input to database tables), I'm wishing to check that the new random number doesn't already exist. Here is my code; Field 'ListID' is a varchar field while ($listid='') { $listtest = rand(1000000000,9999999999); $query = "SELECT ListID FROM tblUserList WHERE ListID='" . $listtest . "'"; $result = mysqli_query($dbc, $query) or die('Error checking ListID - ' . $query); $row_cnt = mysqli_num_rows($result) If ($row_cnt=0) { $listid=$listtest; } } The code is not executing; essentially, there are no error returns and the page continues to sit idly waiting for something to return. Is this loop ot logical?
  3. Thanks for viewing. Solution found via a post in the forum at the same time as myself. Cheers all.
  4. Afternoon all, Quick query; On the index.php page I have a hyperlink entitled LOGOUT. This allows the users to log out of their current session. The hyperlink directs to a logout.php page with the following contents: <?php session_end(); ?> <html> <head></head> <body> <?php header('Location: index.php'); ?> </body> </html> Essentially; the code should end the session and redirect the browser back to the main page. Currently, the hyperlink does redirect to the logout.php page, but; - it doesn't return to the index.php page - if I click the back button, the session is still alive Can anyone assist? Is there a better way of doing this? This isn't something that hasn't been done before, but finding the topic in the forums has been difficult. Thanks in advance.
  5. Please close thread. Thank you all for your help. mysqli_real_escape_string requires two variables; the connection variable, and the string variable. Once corrected; the strings are parsed escaped.
  6. foreach ($timeslotstarts as $timelotstart) { $timeslot_start=$timelotstart->timeslot_start; $dropDownList .= "<option value=" . mysql_real_escape_string($timeslot_start) . ">".$timeslot_start."</option>"; } Try this...
  7. Your user database would contain unique identifiers for each user correct? As you build the output to the screen, set the value of the text box to the unique identifier for that user line. ....value="' . echo $query['unique'] . '"
  8. Alternatively you could hold a session integer variable and count +1 for a wrong answer. If the answer is correct; reset the counter to 0. When the counter = 4 abort the quiz. It's a possible solution, obviously not code.
  9. Still no satisfaction; further ideas?
  10. ^^^ Then why aren't you using mysqli_real_escape_string() (after you connect to the database server.) You should be developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that php will report and display all the errors it finds. You will save a TON of time. Just switched it on. Thanks PFMaBiSmAd
  11. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If no connection is found or established, an E_WARNING level error is generated. So, by no arguments that means that it attempts a connect with no username, password, etc. which will most likely fail. OK; here is the revised code with the connection string the first line. $dbc = mysqli_connect('localhost','dbuser','dbpassword','dbname') or die('Error connecting to dbGeneral'); $Username = mysql_real_escape_string($_POST['username']); $PWord = mysql_real_escape_string($_POST['pword']); $Email = mysql_real_escape_string($_POST['email']); $Fullname = mysql_real_escape_string($_POST['fullname']); $Address_1 = mysql_real_escape_string($_POST['address_1']); $Address_2 = mysql_real_escape_string($_POST['address_2']); $City = mysql_real_escape_string($_POST['city']); $Zip = mysql_real_escape_string($_POST['zip']); $Country = mysql_real_escape_string($_POST['country']); $query = "INSERT INTO tableUserNames(User_Name, Full_Name, Email, Address_1, Address_2, City, Zip, Country, PWord)" . "VALUES ('$Username','$Fullname','$Email','$Address_1','$Address_2','$City','$Zip','$Country','$PWord')"; mysqli_query($dbc, $query) or die('Error executing INSERT statement - ' . $query); I'm not getting an error on the connection string; however, even in this scenario I'm getting empty values. PHP Errors; Sorry only just threw this code in. Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 14 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 14 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 15 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 15 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 16 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 16 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 17 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 17 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 18 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 18 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 19 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 19 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 20 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 20 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 21 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 21 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 22 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /var/www/vhosts/einterfaces.com.au/httpdocs/ListSite/useradd.php on line 22
  12. No, I'm setting the variables first with this code snippet and then opening the connection. Should this be done before using mysql commands? Others: Have reverted and the code works fine, inserts the new user without issue. Thoughts? P.S I'm using mysqli_connect as the connection string command btw.
  13. I thought as much..... I retried the entry page again and got the same output. Will revert to original without the mysql_real_escape_string and retest. Shouldn't have been a coding change but you never know...
  14. Morning All, Should be a quick one for the seasoned veterans! I'm learning the in's and out's of sanitizing my variables for input into my database (mysql). The following is my code; $Username = mysql_real_escape_string($_POST['username']); $PWord = mysql_real_escape_string($_POST['pword']); $Email = mysql_real_escape_string($_POST['email']); $Fullname = mysql_real_escape_string($_POST['fullname']); $Address_1 = mysql_real_escape_string($_POST['address_1']); $Address_2 = mysql_real_escape_string($_POST['address_2']); $City = mysql_real_escape_string($_POST['city']); $Zip = mysql_real_escape_string($_POST['zip']); $Country = mysql_real_escape_string($_POST['country']); The following is my output; Error executing INSERT statement - INSERT INTO tblUser(User_Name, Full_Name, Email, Address_1, Address_2, City, Zip, Country, PWord)VALUES ('','','','','','','','','') Any ideas? Also; is mysql_real_escape_string valid for use on all types of input from the input box?
  15. I never knew how in control of my web hosting I am until I start asking questions. Amazing! I'll work through the manual. Thanks Pik.
  16. I recently read a forum posting regarding detecting the browser being used by the user. The following is a quote from that post; How is this applied in code to 'echo' the browser, and is this the best execution of browser detection?
  17. Now we're cooking!! I added the error variables and we're getting feedback. RE: FName and Full_Name, I just abbreviated for the purposes of pasting code. I finally got a return of errors and now I'm progressing to debug. So I looked over the database and found that the field name is Full_Name not Full_name...... I forgot about case-sensitivity. I am now getting output returned. Thank you very much for your persistence and help with this.
  18. - Not sure about the system configuration with regard to errors. I'll enquire through my web-hosting. - What's the best application for mysqli_num_rows(); is it simply echo mysqli_num_rows(); ?
  19. So now my 'view source' looks like this; <html> <head> <title>The List Site</title> </head> <body> </body> </html>
  20. I'm using the application TEXTEDIT on the Mac. Have just reviewed the other php files that work and noticed the PLAIN TEXT ENCODING was different on this file. I've altered it to MAC OS Roman from a UNICODE format. Now the 'VIEW SOURCE' doesn't show the PHP, but the PHP still isn't returning any output. I'm constantly working on the server with PHP installed on my web-hosting. I don't work off PHP files on my local machine.
  21. <html> <head> <title>The List Site</title> </head> <body> <?php $dbc = mysqli_connect('localhost','username','password','db') or die('Error connecting to db'); $query = "SELECT * FROM tblUser"; $result = mysqli_query($dbc, $query) or die('Error executing SELECT * statement'); while ($row = mysqli_fetch_array($result)) { echo $row['Fname']; } mysqli_close($dbc); ?> </body> </html> View source - Apologies. The viewsource shows the same code above (and I realise the <?php.....?> should not be showing in viewsource window. FYI - There are 3 rows in the table, and I just tested another page that has PHP coding to add records to the table and it processed without issue.
  22. I don't care , the only reason to use SELECT * is because you can't be bothered typing in the field names. Now, does the page source show anything where the php should be? I've reduced the page source to just the php code.... <html> <head> <title>The List Site</title> </head> <body> <?php $dbc = mysqli_connect('localhost','username','password','db') or die('Error connecting to db'); $query = "SELECT * FROM tblUser"; $result = mysqli_query($dbc, $query) or die('Error executing SELECT * statement'); while ($row = mysqli_fetch_array($result)) { echo $row['Fname']; } mysqli_close($dbc); ?> </body> </html> The page now displays blank, not even error returns.
  23. Thanks for the feedback thus far. 1 - I had <?php but it wasn't working so I dropped the PHP, have put it back in. No go. Anything more? 2 - Laziness(?) it's not for a simple field, I am utilising all the fields being returned. However, when debugging, I reduced the output to one field. Though that doesn't help my problem of the code not working, the SELECT * is an SQL statement that will work.
  24. Morning All, A simple query; I've written a small piece of code to read all the records in my DB table and 'echo' them to the screen. When running, the other bits of the page (HTML only) is showing fine. The space where the code should display is blank (not even blank lines are output from my code). Any assistance would be helpful. I fear it may be something simple that I've overlooked. Thanks in advance. <p> Reading the users from the databaseā€¦tblUser<br><br> <? $dbc = mysqli_connect('localhost','username','password','dbGeneral') or die('Error connecting to dbGeneral'); $query = "SELECT * FROM tblUser"; $result = mysqli_query($dbc, $query) or die('Error executing SELECT * statement'); while ($row = mysqli_fetch_array($result)) { echo $row['Full_name']; } mysqli_close($dbc); ?> </p>
×
×
  • 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.