PHP - Creating New Html Page With Php Problem
this string:
Code: [Select] $str2="<html> <body> <h1>lol<h1/> <p>hahaha</p> </body> </html>" note: between the tags it's "\n". that a is creating new html page, but the code of the new page is looking like that: Code: [Select] <html><body><h5>lol<h5/><p>hahaha</p></body><html/>as a code and not as html should be display. the php code that creating the html page look like that: while($i<$p) { $pattern='/\n/'; if(preg_match($pattern,substr($str2,$i,1))) { echo "yes \$str3=".$str3."<br />"; $i++; $myFile = "files/testFile.html"; $fh = fopen($myFile, 'a') or die("can't open file"); fwrite($fh,$str3); fclose($fh); $str3=""; } else { $str3.=$str2[$i]; echo $str3."<br />\$i=".$i; $i++; } } the code is fine and he don't show any error or warring and working,but he won't create for me new html document as he should be why??? Similar TutorialsHello I've registered here last March and I'm just lurking around reading threads about php. Yesterday I've started to self studied php and today I've test some basic codes and I'm having difficulties on creating a table rows and columns. Here's my code. Code: [Select] <?php echo "<table width=\"100\" border=\"1\">"; $text = 'php'; $mac_var = 1; $mac_plus = 4; while ($mac_var < $mac_plus) { echo "<tr>"; { while ($mac_var < $mac_plus) { echo "<td>". $text . "</td>"; $mac_var++; } } echo "</tr>"; $mac_var++; } echo "</table>"; ?> what I want is, it should have 3 columns and 3 rows. But I'm getting only 3 columns and 1 row only. I wonder what is the problem? Sorry for my ignorance as I'm on the 1st basic phase of using php codes. TIA! I have set up a database using myPHPadmin, I have created the following code: Code: [Select] <?php session_start(); $username = $_POST['username']; $password = $_POST['password']; if ($username&&$password) { $connect = mysql_connect("127.0.0.1","root","password") or die("Couldnt connect to database"); mysql_select_db("login") or die ("Couldnt find database"); $query = mysql_query("SELECT * FROM users WHERE username ='$username'"); $numrows = mysql_num_rows ($query); if($rumrows != 0) { while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } if ($username==$dbusername&&$password==$dbpassword) { echo "Login successful. <a href='members.php'> Click here to enter memebers area </a>"; $_SESSION['username']=$dbusername; } else echo "Incorrect password"; } else die ("Username does not exist"); } else die ("Please enter a username and password"); ?> Even though the database is set up when i try and enter the username for the log in page and password, it says the username does not exist? I dont understand why when it is in the database? Please help! MOD EDIT: [code] . . . [/code] BBCode tags added. i have a mysql db, i have a form that i use to post data to db. i would like to have visitors to my site be able to post to db as well, but they would have to be registered and have their own profile. when logged in they could see and edit their own space and content that they posted to mysql. how would i go about creating something like this? can someone point me in the right direction ? thank you. I am using the code below for my webpage. When no or non existant querystring is passed the user is directed to the homepage. I want to change this so that if a user goes uses an invalid query string (?page=oldcontent) they are directed to a 'not found page'. Can this be done with the way I hae set this up? switch ($page) { case 'about': include 'about.php'; break; case 'contact': include 'contact.php'; break; default: include 'homepage.php'; } Hi Does anyone know any good tutorials for creating a registration page for a website? Thanks in advance. So, I'm designing a website (who isn't?) and I created the basic framework for a users page from a tutorial I found. Using some previous knowledge I managed to make it display a few custom fields that are defined by the user. Everything works fine as is, but now I want to do a few things to it that I have not the slightest clue how to even begin... Here is my user page code so far... and oh yes I'm using WordPress which is why I made it check manually for page status in my Page.php file. <?php if ( is_page('Users')) { echo "<ul id=\"UsersList\">"; /* First we set how we'll want to sort the user list. You could sort them by: ------------------------ * ID - User ID number. * user_login - User Login name. * user_nicename - User Nice name ( nice version of login name ). * user_email - User Email Address. * user_url - User Website URL. * user_registered - User Registration date. */ $szSort = "user_nicename"; /* Now we build the custom query to get the ID of the users. */ $aUsersID = $wpdb->get_col( $wpdb->prepare("SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC", $szSort )); /* Once we have the IDs we loop through them with a Foreach statement. */ foreach ( $aUsersID as $iUserID ) : /* We use get_userdata() function with each ID. */ $user = get_userdata( $iUserID ); /* Here we finally print the details wanted. Check the description of the database tables linked above to see all the fields you can retrieve. To echo a property simply call it with $user->name_of_the_column. */ if($user->user_login != "Unknown") // don't show the placeholder for [unknown] author { echo '<a href="">' . get_avatar( $iUserID, $size = '45', $border='0') . '</a>'; echo '<li>' . ucwords( strtolower( $user->user_login ) ) . '</li>'; if($user->favorite_player != "") { echo '<li>' . $user->favorite_player . '</li>'; } if($user->player_name != "") { echo '<li>' . $user->player_name . '</li>'; } } /* The strtolower and ucwords part is to be sure the full names will all be capitalized. */ endforeach; // end the users loop. echo "</ul>"; }; ?> Problem one: This does NOT sort my name, despite the tutorial's insistence that it will. I have not even a guess as to why this is. Problem two: I would like to either sort this list into two columns or paginate it or both but I am not sure how to do either. Problem three: I want to insert some static text between the echo '<li>' and the . $user->player_name . '</li>'; so that it reads: o Player Name: USER'S VARIABLE ' PLAYER NAME' HERE Yes that 'o' is supposed to be the list item dot. I know how strings work, I just can't get my attempts to work out syntax-wise. Any help would be greatly appreciated! Tutorials, answers, suggestions, examples, anything. The extent of my previous coding knowledge is several years of UnrealScript, so you can see why this simple thing is baffling me. Frankly I'm surprised this much of it works. I want to create a master-detail page using PHP. Rather than getting data from a MYSQL database, I want to get the data from an associative array. Is this possible? Please someone show me the way forward. Please help. Hello: Seeking some input, please. I use single-pages in my admin panel to update and maintain each corresponding page on the front end. Code: [Select] ADMIN = FRONT END a_Home.php = Home.php a_About.php = About.php Etc... The code is the same for each page, except I have to rename the TABLE everytime I make a new page: Code: [Select] <?php include('../include/myConn.php'); //contains your mysql connection and table selection include('../include/myCodeLib.php'); include('include/myCheckLogin.php'); include('include/myAdminNav.php'); include('ckfinder/ckfinder.php'); include('ckeditor/ckeditor.php'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $myTitle = mysql_real_escape_string($_POST['myTitle']); $myDesc = mysql_real_escape_string($_POST['myDesc']); $myHeader = mysql_real_escape_string($_POST['myHeader']); $mySubHeader = mysql_real_escape_string($_POST['mySubHeader']); $myPageData = mysql_real_escape_string($_POST['myPageData']); $sql = " UPDATE myTestimonials SET myTitle = '$myTitle', myDesc = '$myDesc', myHeader = '$myHeader', mySubHeader = '$mySubHeader', myPageData = '$myPageData' "; mysql_query($sql) && mysql_affected_rows() ?> <script language="JavaScript"> alert("This page was updated!"); location.href = "a_Testimonials.php"; </script> <?php } $query=mysql_query("SELECT * FROM myTestimonials") or die("Could not get data from db: ".mysql_error()); while($result=mysql_fetch_array($query)) { $myTitle=$result['myTitle']; $myDesc=$result['myDesc']; $myHeader=$result['myHeader']; $mySubHeader=$result['mySubHeader']; $myPageData=$result['myPageData']; } ?> <!DOCTYPE HTML> <html> <head> <meta name="author" content="MontyTheWebmaster.com" /> <meta charset="ISO-8859-1" /> <title>Admin Area</title> <?php echo spAdminLinks(); ?> </head> <body> <div id="siteContainer"> <div id="topContainer"> <?php echo spAdminTopMenu(); ?> </div> <div id="topMenuContainer"> <div id="topMenu"> <?php echo spAdminMenu(); ?> </div> </div> <div id="contentContainer"> <div id="mainContent"> <h1>Editing: Testimonials</h1> <p> <form method="post" action="<?php echo $PHP_SELF;?>"> <input type="hidden" name="POSTBACK" value="EDIT"> <div style="float: left; width: 120px; margin-right: 30px;"> Page Title: </div> <div style="float: left; width: 550px;"> <textarea cols="80" rows="1" name="myTitle"><?php echo $myTitle; ?></textarea> </div> <div style="clear: both;"><br /></div> <div style="float: left; width: 120px; margin-right: 30px;"> Page Description: </div> <div style="float: left; width: 550px;"> <textarea cols="80" rows="1" name="myDesc"><?php echo $myDesc; ?></textarea> </div> <div style="clear: both;"><br /></div> <div style="float: left; width: 120px; margin-right: 30px;"> Page Header: </div> <div style="float: left; width: 550px;"> <textarea cols="80" rows="1" name="myHeader"><?php echo $myHeader; ?></textarea> </div> <div style="clear: both;"><br /></div> <div style="float: left; width: 120px; margin-right: 30px;"> Page SubHeader: </div> <div style="float: left; width: 550px;"> <textarea cols="80" rows="1" name="mySubHeader"><?php echo $mySubHeader; ?></textarea> </div> <div style="clear: both;"><br /></div> Page Content:<br /> <textarea cols="80" id="myPageData" name="myPageData"><?php echo $myPageData; ?></textarea> <script type="text/javascript"> CKEDITOR.replace( 'myPageData', { filebrowserBrowseUrl : 'ckfinder/ckfinder.html', filebrowserImageBrowseUrl : 'ckfinder/ckfinder.html?Type=Images', filebrowserFlashBrowseUrl : 'ckfinder/ckfinder.html?Type=Flash', filebrowserUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files', filebrowserImageUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images', filebrowserFlashUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash' } ); </script> <br /> <input type="submit" value="Submit" /> </form> </p> </div> <div style="clear: both;"></div> </div> <div id="footerContainer"> <?php echo spAdminFooter(); ?> </div> </div> </body> </html> What I am curious about is how can I take this page and make it so I can add a new page, delete a page, etc. all from just one page like above? And on the frontend, what would be the best way to display the data in a search engine friendly way (i.e. without QueryStrings like MyPage.php?id=2 OK, here it is. I have been trying to do this myself, but it has been driving me insane and I turn to professionals here for help.
I am a basic web developer for a company that I work for in other capacities. I have a reasonable understanding of HTML and that is about where my expertise ends. I am not typically a programmer, just a simple (extremely) part time designer that uses Muse and Dreamweaver when necessary.
However, recently my company has asked me to accomplish a task for their website. In plain English, they want a large database that exists currently as a CVS file made into a searchable web page. It is 21 columns by approximately 6,700 rows.
To explain what I need a little more technically, here are my ideas and where I have gotten to so far:
1. The company uses godaddy, into which I *believe* I have successfully imported the spreadsheet. I believe it is successful because through godaddy's SQL Control Panel (phpMyAdmin console), I can do the EXACT searches that the company needs, and it spits out the EXACT results that I need.
2. The end result needs to be a .php that I can upload to the website's root folder that can be then inserted into premade pages using:
<iframe src="SMQ.php" scrolling="yes" width="950" height="800"></iframe>3. On the .php page, I need to have a way to log in to the SQL server and a simple search box built in that will allow the user to input a very simple search string consisting of no more than 4 numbers and 3 letters at a time. No buttons, no check boxes, just a search box. 3. This query then needs to be output as a nice data table, similar to this: This in fact is a screenshot of a search I performed out of my SQL database, in phpMyAdmin using the column "Scott" for the search, and the number 226 as the search term. All column names are visible with the exception of the first column, entitled LINEID, made to be the key, and the output should not include the key but have everything else as above. 4. I can see what the simple line of php is that performed this task: SELECT * FROM `SMQSQL` WHERE `Scott` = '226' ORDER BY `LINEID` ASCbut I can't figure out how the hell to get this incorporated to a .php search. To sum it up, I need a .php page written that can connect to a SQL database, perform a data based search, and spit out a clean table when it is done. I had accomplished this in the past using an import into google docs and using it to perform a search and result display via the following code built into a php called SMQ.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Example of Google Spreadsheet Data Visualisation</title> </head> <body> <form id="form1" method="post" action ="<?php echo $_SERVER['PHP_SELF']; ?>"> <label> <input id="search" name="search" type="text" /> </label> <label> <input id="Scott #" name="Scott #" type="submit" value="Scott #" /> </label> <img src="loading.gif" width="16" height="11" /> </form> <p> <?php $search= $_REQUEST['search']; if ($search > ''){ $search = $search;} else { $search = '';} ?> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load('visualization', '1', {packages: ['table']}); </script> <script type="text/javascript"> var visualization; function drawVisualization() { var query = new google.visualization.Query( 'https://docs.google.com/spreadsheet/ccc?key=0AronCwm9QPefdGpIUllscGgtLUJod2pOazc0bjU0cUE&usp=sharing'); query.setQuery('SELECT A, B, C, D, E, F, G, H, I, J, K, L, M, N, O ,P ,Q ,R ,S ,T WHERE (A) LIKE ("<?php echo $search; ?>") order by A asc label A "Scott #", B "Den", C "Color", D "Cond", E "40", F "60", G "70", H "70J", I "75", J "75J", K "80", L "80J", M "85", N "85J", O "90", P "90J", Q "95", R "95J", S "98", T "98J"'); query.send(handleQueryResponse); } function handleQueryResponse(response) { if (response.isError()) { alert('Error in query: ' + response.getMessage() + '' + response.getDetailedMessage()); return; } var data = response.getDataTable(); visualization = new google.visualization.Table(document.getElementById('table')); visualization.draw(data, { page: 'enable', page: 16, pageSize: 16, legend: 'bottom'}); } google.setOnLoadCallback(drawVisualization); </script> <div id="table"></div> </div> </body> </html>But as you can see, this may not be the most secure thing in the world, plus we want to be able to expand it in the future and not be so simplistic, hence the need to switch to SQL. Please let me know right away by contacting me at disead@gmail.com if this is something YOU might be able to help with. I'm sure for an experienced programmer, once you have the details from me that you need, it would take maybe 10 minutes to write. I don't have much, but I can pay a little bit for this one time job. If it ends up working out, I may be able to pay more down the line for more advanced options such as being able to do drop-down searches based on the column titled "ISSUE", as well as more things down the line as it grows. Thank you so much, I hope to hear from someone soon!!! Hi all New here. I have a basic email form that takes name phone email etc, also has 3 file upload boxes for photos. I have taken most of the code from free examples off the net and patched it together. It had an error message if something went wrong. I wanted to put an html page instead of just the txt. So read that I could end tag the php then do html then begin tag the php again. Problem is some of the error message was from a different part of the php code. How can i get this displayed on the html. Code: [Select] <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "email@email.com"; $email_subject = "JoinUs Model Form"; function died($error) { // your error code can go here ?> <title>title</title> <style type="text/css"> body { background-color: #000; text-align: center; } body,td,th { color: #FFF; font-family: Arial, Helvetica, sans-serif; font-size: 24px; } </style> </head> <body link="#FFFFFF" onload="setTimeout('history.back()',10000)"> <p><img src="../images/logo.png" width="326" height="144" alt="sdadfsd" longdesc="http://www.dgfsfdg.com" /><br /> </p> <br /> <p>We are very sorry, but there were error(s) found with the form you submitted.</p> <p>These errors appear below.</p> ####### this is where i want the below errors to appear in same format as html ######### <p>Click back to fix your error(s) or you will be taken back to the form automatically in 10 seconds...</p> <h6> </h6> <h6>© asafdsodf 2012</h6> </body> </html> <?php die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['form2']['photo1']); $target_path = $target_path . basename( $_FILES['form2']['photo2']); $target_path = $target_path . basename( $_FILES['form2']['photo3']); $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required $age = $_POST['age']; $city = $_POST['city']; $state = $_POST['state']; $height_feet = $_POST['height_feet']; $height_inches = $_POST['height_inches']; $photo1 = $_FILES['form2']['photo1']; $photo2 = $_FILES['form2']['photo2']; $photo3 = $_FILES['form2']['photo3']; $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Age: ".clean_string($age)."\n"; $email_message .= "Height: ".clean_string($height_feet) .clean_string($height_inches)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "State: ".clean_string($state)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; $email_message .= "".clean_string($comments)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>asdf </title> <style type="text/css"> body { background-color: #000; text-align: center; } body,td,th { color: #FFF; font-family: Arial, Helvetica, sans-serif; font-size: 24px; } </style> </head> <body link="#FFFFFF"> <p><img src="./images/logo.png" width="326" height="144" alt="asdfahjdsfka" longdesc="http://www.kasdfhdskaha.com" /><br /> </p> <p>Thank your for applying to adskfha asdfasd. We will be in touch with you very soon.</p> <p>You will be redirected back to the site in 3 seconds...</p> <h6> </h6> <h6>© 2012</h6> </body> </html> <?php } ?> Thanks Wolfsta I've started a to-do app, and everything works fine. Every user has his own unique to-do items that he can add. The only issue is that when I log-in with a user, ALL the items of all users are displayed when I'm redirect to my main page. I want to make it as so every user has his own page where only the to-do items he has created are visible, not every item from every user. I'm a total beginner with PHP so I'm sorry if this is a stupid question. This is my todomain.php code <?php require 'db_conn.php'; require 'config.php'; session_start(); // If the session variable is empty, this // means the user is yet to login // User will be sent to 'login.php' page // to allow the user to login if (!isset($_SESSION['id'])) { $_SESSION['msg'] = "You have to log in first"; header('location: login.php'); } // Logout button will destroy the session, and // will unset the session variables // User will be headed to 'login.php' // after loggin out if (isset($_GET['logout'])) { session_destroy(); unset($_SESSION['id']); header("location: login.php"); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset= "UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <link rel="stylesheet" href="css/bootstrap-grid.min.css"> <link rel="stylesheet" href="css/bootstrap.min.css"> <link rel="stylesheet" href="style.css"> <a href="index.php?logout='1'" style="color: black;"> Click here to Logout </a> <?php if (isset($_SESSION['success'])) : ?> <div class="error success" > <h3> <?php echo $_SESSION['success']; unset($_SESSION['success']); echo $_SESSION["username"] ?> </h3> </div> <?php endif ?> <title>TODO App</title> <script src="https://kit.fontawesome.com/d72928d9b9.js" crossorigin="anonymous"></script> </head> <body> <div class="container m-5 p-2 rounded mx-auto bg-light shadow"> <!-- App title section --> <div class="row m-1 p-4"> <div class="col"> <div class="p-1 h1 text-primary text-center mx-auto display-inline-block"> <i class="fa fa-check bg-primary text-white rounded p-2"></i> <u>My Todo-s</u> </div> </div> </div> <!-- Create todo section --> <form action="app/add.php" method="POST" autocomplete="off"> <div class="row m-1 p-3"> <div class="col col-11 mx-auto"> <div class="row bg-white rounded shadow-sm p-2 add-todo-wrapper align-items-center justify-content-center"> <div class="col"> <input class="form-control form-control-lg border-0 add-todo-input bg-transparent rounded" type="text" name="title" placeholder="Add new .."> </div> <div class="col-auto m-0 px-2 d-flex align-items-center"> <label class="text-secondary my-2 p-0 px-1 view-opt-label due-date-label d-none">Due date not set</label> <i class="fa fa-calendar my-2 px-1 text-primary btn due-date-button" data-toggle="tooltip" data-placement="bottom" title="Set a Due date"></i> <i class="fa fa-calendar-times-o my-2 px-1 text-danger btn clear-due-date-button d-none" data-toggle="tooltip" data-placement="bottom" title="Clear Due date"></i> </div> <div class="col-auto px-0 mx-0 mr-2"> <button type="submit" class="btn btn-primary">Add</button> </div> </div> </div> </div> </form> <?php $todos=$conn->query("SELECT * FROM todos ORDER BY id ASC"); ?> <div class="row mx-1 px-5 pb-3 w-80"> <div class="col mx-auto"> <?php while($todo=$todos->fetch(PDO::FETCH_ASSOC)){ ?> <!-- Todo Item 1 --> <div class="row px-3 align-items-center todo-item rounded"> <?php if($todo['checked']){ ?> <input type="checkbox" class="check-box" data-todo-id="<?php echo $todo['id'];?>" checked /> <h2 class="checked"><?php echo $todo['title'] ?> </h2> <div class="col-auto m-1 p-0 todo-actions"> <div class="row d-flex align-items-center justify-content-end"> </div> </div> <?php } else{ ?> <input type="checkbox" class="check-box" data-todo-id="<?php echo $todo['id'];?>"/> <h2><?php echo $todo['title'] ?></h2> <?php } ?> <div class="col-auto m-1 p-0 d-flex align-items-center"> <h2 class="m-0 p-0"> <i class="fa fa-square-o text-primary btn m-0 p-0 d-none" data-toggle="tooltip" data-placement="bottom" title="Mark as complete"></i> </h2> </div> <div class="col-auto m-1 p-0 todo-actions"> <div class="row d-flex align-items-center justify-content-end"> <h5 class="m-0 p-0 px-2"> <i class="fa fa-pencil text-info btn m-0 p-0" data-toggle="tooltip" data-placement="bottom" title="Edit todo"></i> </h5> <h5 class="m-0 p-0 px-2"> <i class="remove-to-do fa fa-trash-o text-danger btn m-0 p-0" data-toggle="tooltip" data-placement="bottom" title="Delete todo" id="<?php echo $todo['id']; ?>"></i> </h5> </div> <div class="row todo-created-info"> <div class="col-auto d-flex align-items-center pr-2"> <i class="fa fa-info-circle my-2 px-2 text-black-50 btn" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Created date"></i> <label class="date-label my-2 text-black-50"><?php echo $todo['date_time'] ?></label> </div> </div> </div> </div> <?php } ?> </div> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script> <script src="js/bootstrap.bundle.min.js"></script> <script src="js/myjs.js" ></script> <script src="js/jquery-3.3.1.min.js"></script> <script> $(document).ready(function(){ $(".remove-to-do").click(function(e){ const id = $(this).attr('id'); $.post('app/remove.php', { id: id }, (data) => { if(data){ $(this).parent().parent().parent().parent().hide(300); } } ); }); $(".check-box").click(function(e){ const id = $(this).attr('data-todo-id'); $.post('app/checking.php', { id: id }, (data) => { if(data!='error'){ const h2= $(this).next(); if(data === '1'){ h2.removeClass('checked'); }else{ h2.addclass('checked'); } } } ); }); }); </script> </body> </html>
This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=357949.0 When there is a duplicate entry in my database, I would like it to go to the another page that indicates the error, rather than the "Error: Duplicate entry 'username' for key 1". It happens if someone is going to join and there is a duplicate entry. I would rather it show one of my customized php pages rather than a black page stating the error. I've tried to catch the entry with some php code but it bypasses it and continues with the duplicate error. I would appreciate any direction with this. Thanks! Hi all, Hope to find you all good. I have the following, which creates a php file. This works fine and without error. However, once created, the content of the page, which is got from the Database, is not showing. <?php include_once('includes/header.php'); if(isset($_POST['new']) && $_POST['new']==1){ if(isset($_POST['submit'])){ $trn_date = mysqli_real_escape_string($con, date("Y-m-d H:i:s")); $name = mysqli_real_escape_string($con, $_POST['name']); $description = mysqli_real_escape_string($con, $_POST['description']); $body = mysqli_real_escape_string($con, $_POST['body']); $submittedby = mysqli_real_escape_string($con, $_SESSION["username"]); $sql = "SELECT * FROM pages WHERE name='$name'"; $res = mysqli_query($con, $sql); if (mysqli_num_rows($res) > 0) { $message = '<i class="fa fa-times text-danger"> - A Page already exists with that name!</i>'; }else{ $ins_query="insert into pages (`trn_date`,`name`,`description`, `body`, `submittedby`)values ('$trn_date','$name','$description', '$body', '$submittedby')"; mysqli_query($con,$ins_query) or die(mysqli_error($con)); if(mysqli_affected_rows($con)== 1 ){ // Name of the template file. $template_file = 'template.php'; // Root folder if working in subdirectory. Name is up to you ut must match with server's folder. $base_path = '/protour/'; // Path to the directory where you store the "template.php" file. $template_path = 'includes/'; // Path to the directory where php will store the auto-generated couple's pages. $page_path = '../'; // Posted data. $row['name'] = str_replace(' ', '', $_POST['name']); $row['description'] = str_replace(' ', '', $_POST['description']); $row['body'] = $_POST['body']; // Data array (Should match with data above's order). $placeholders = array('{name}', '{description}', '{body}'); // Get the template.php as a string. $template = file_get_contents($template_path.$template_file); // Fills the template. $new_file = str_replace($placeholders, $row, $template); // Generates couple's URL and makes it frendly and lowercase. $page_url = str_replace(' ', '', strtolower($row['name'].'.php')); // Save file into page directory. $fp = fopen($page_path.$page_url, 'w'); fwrite($fp, $new_file); fclose($fp); // Set the variables to pass them to success page. $_SESSION['page_url'] = $page_url; // If working in root directory. $_SESSION['page_path'] = str_replace('.', '', $page_path); // If working in a sub directory. $_SESSION['page_path'] = substr_replace($base_path, '', -1).str_replace('.', '',$page_path); $message = '<i class="fa fa-check"></i> - Page Created Successfully'; } } } } ?> <!-- Header--> <div class="breadcrumbs"> <div class="col-sm-4"> <div class="page-header float-left"> <div class="page-title"> <h1>Pages</h1> </div> </div> </div> <div class="col-sm-8"> </div> </div> <div class="content mt-3"> <div class="animated fadeIn"> <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-header"><strong>Add </strong><small>Page <?php if($message = isset($message) ? $message : ''){ printf($message); } ?></small></div> <div class="card-body card-block"> <form role="form" method="post" action""> <input type="hidden" name="new" value="1" /> <div class="modal-body"> <div class="form-group"><label for="name" class=" form-control-label">Page Name</label><input type="text" id="name" name="name" placeholder="name" class="form-control"> </div> <div class="form-group"><label for="description" class=" form-control-label">Description</label><input maxlength="100" type="text" id="description" name="description" placeholder="descriptioon" class="form-control"></div> <div class="form-group"><label for="body" class=" form-control-label">Body</label> <textarea class="form-control" id="body" name="body" placeholder="body"></textarea> </div> <div class="modal-footer"> <button type="submit" name="submit" id="submit" class="btn btn-primary">Confirm</button> </div> </form> </div> </div> </div><!-- .animated --> </div><!-- .content --> </div><!-- /#right-panel --> <!-- Right Panel --> <script src="assets/js/vendor/jquery-2.1.4.min.js"></script> <script src="assets/js/popper.min.js"></script> <script src="assets/js/plugins.js"></script> <script src="assets/js/main.js"></script> <script src="assets/js/bing.js"></script> <script src="assets/js/lib/data-table/datatables.min.js"></script> <script src="assets/js/lib/data-table/dataTables.bootstrap.min.js"></script> <script src="assets/js/lib/data-table/dataTables.buttons.min.js"></script> <script src="assets/js/lib/data-table/buttons.bootstrap.min.js"></script> <script src="assets/js/lib/data-table/jszip.min.js"></script> <script src="assets/js/lib/data-table/pdfmake.min.js"></script> <script src="assets/js/lib/data-table/vfs_fonts.js"></script> <script src="assets/js/lib/data-table/buttons.html5.min.js"></script> <script src="assets/js/lib/data-table/buttons.print.min.js"></script> <script src="assets/js/lib/data-table/buttons.colVis.min.js"></script> <script src="assets/js/lib/data-table/datatables-init.js"></script> <script src="https://cdn.tiny.cloud/1/sw6bkvhzd3ev4xl3u9yx3tzrux4nthssiwgsog74altv1o65/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script> <script> tinymce.init({ selector: 'textarea', plugins: 'advlist autolink lists link image charmap print preview hr anchor pagebreak', toolbar_mode: 'floating', }); </script> <script type="text/javascript"> $(document).ready(function() { $('#customer-table').DataTable(); } ); </script> </body> </html> My guess is the placeholder section is not working. // Posted data. $row['name'] = str_replace(' ', '', $_POST['name']); $row['description'] = str_replace(' ', '', $_POST['description']); $row['body'] = $_POST['body']; // Data array (Should match with data above's order). $placeholders = array('{name}', '{description}', '{body}'); Here is template.php <?php include_once('includes/header.php'); require_once('admin/includes/config.php'); if(isset($_POST['new']) && $_POST['new']==1){ $trn_date = mysqli_real_escape_string($con, date("Y-m-d H:i:s")); $name = mysqli_real_escape_string($con, $_POST['name']); $email = mysqli_real_escape_string($con, $_POST['email']); $pickup = mysqli_real_escape_string($con, $_POST['pickup']); $dropoff = mysqli_real_escape_string($con, $_POST['dropoff']); $dep_date = mysqli_real_escape_string($con, $_POST['dep_date']); $ret_date = mysqli_real_escape_string($con, $_POST['ret_date']); $dep_time = mysqli_real_escape_string($con, $_POST['dep_time']); $pax_numbers = mysqli_real_escape_string($con, $_POST['pax_numbers']); $ins_query="insert into quotes (`trn_date`,`name`,`email`, `pickup`, `dropoff`, `dep_date`, `ret_date`, `dep_time`, `pax_numbers`) values ('$trn_date','$name','$email', '$pickup', '$dropoff', '$dep_date', '$ret_date', '$dep_time', '$pax_numbers')"; mysqli_query($con,$ins_query) or die(mysqli_error($con)); if(mysqli_affected_rows($con)== 1 ){ $message = "Thank you. We will be in touch soon."; } } $sql = "SELECT * FROM slide"; $result = $con->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { ?> <div class="hero-wrap" style='background-image: url("admin/uploads/<?php echo $row['image']; ?>")' data-stellar-background-ratio="0.5"> <div class="overlay"></div> <div class="container"> <div class="row no-gutters slider-text justify-content-start align-items-center"> <div class="col-lg-6 col-md-6 ftco-animate d-flex align-items-end"> <div class="text"> <p style="font-size: 18px;"><?php echo $row['slide_text']; ?></p> <a href="<?php echo $row['youtube']; ?>" class="icon-wrap popup-vimeo d-flex align-items-center mt-4"> <div class="icon d-flex align-items-center justify-content-center"> <span class="ion-ios-play"></span> </div> <div class="heading-title ml-5"> <span>Play Our Short Video</span> </div> </a> </div> </div> <div class="col-lg-2 col"></div> <div class="col-lg-4 col-md-6 mt-0 mt-md-5 d-flex"> <form method="post" action="" role="form" class="request-form ftco-animate"> <input type="hidden" name="new" value="1" /> <h2>Get A Quote</h2> <div class="d-flex"> <div class="form-group mr-2"> <label for="name" class="label">Name</label> <input class="form-control" type="text" id="name" name="name" placeholder="Your Name" /> </div> <div class="form-group ml-2"> <label for="email" class="label">Email</label> <input class="form-control" type="email" id="email" name="email" placeholder="Your Email" /> </div> </div> <div class="form-group"> <label for="searchBox" class="label">Pick-Up Location</label> <input class="form-control" type="text" id="searchBox" name="pickup" placeholder="Start Typing..." /> </div> <div class="form-group"> <label for="searchBoxAlt" class="label">Drop-Off Location</label> <input type="text" class="form-control" id="searchBoxAlt" name="dropoff" placeholder="Start Typing..." /> </div> <div class="d-flex"> <div class="form-group mr-2"> <label for="" class="label">Departure Date</label> <input type="text" class="form-control" id="book_pick_date" name="dep_date" placeholder="Date"> </div> <div class="form-group ml-2"> <label for="" class="label">Return Date</label> <input type="text" class="form-control" id="book_off_date" name="ret_date" placeholder="Date"> </div> </div> <div class="d-flex"> <div class="form-group mr-2"> <label for="" class="label">Pick-Up Time</label> <input type="text" class="form-control" id="time_pick" name="dep_time" placeholder="Time"> </div> <div class="form-group ml-2"> <label for"" class="label">Passenger Numbers</label> <input type="number" class="form-control" id="pax_numbers" name="pax_numbers" placeholder="Amount" /> </div> </div> <div class="form-group"> <button type="submit" class="btn btn-primary py-3 px-4">Request Quote</button> <p><?php if($message = isset($message) ? $message : ''){ printf($message); } ?></p> </div> </form> </div> </div> </div> </div> <?php } } ?> <script type="text/javascript" src="https://www.bing.com/api/maps/mapcontrol?key=AqIY0ivSCCdBIe3-EKGuox9cwBFw2wWRWIErZi1iy57EfD67PoiSra9wl_wu48de&callback=bingMapsReady" async defer></script> <?php if(isset($_GET['id'])){ $id = mysqli_real_escape_string($con, $_GET['id'] ?? DEFAULT_ID); $sql = "SELECT * FROM pages WHERE id = $id"; $result = $con->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_array()) { ?> <!-- HOW IT WORKS --> <section class="ftco-section ftco-no-pt ftco-no-pb"> <div class="container"> <div class="row no-gutters"> <div class="col-md-12 wrap-about py-md-5 ftco-animate"> <div class="heading-section mb-5 pl-md-5"> <span class="subheading"><?php echo $row['description']; ?> </span> <h2 class="heading"><?php echo $row['name']; ?></h2> <?php echo $row['body']; ?> </div> </div> </div> </div> </section> <?php } } } ?> <!-- FOOTER --> <?php include_once('includes/footer.php'); ?> Please note that this is just a project and will not be going live. It's for learning purposes and I am aware there are some vulnerabilities within parts of the code. Any assistance with the above issues though would really be appreciated. Thanks and have a ripper evening. Hi, So i have HTML table which i'm attempting to turn into executable SQL code which i can then insert into a SQL database table. I'm wondering if anyone has any good ideas for the best way to get this done? I need to extract the data from each of the <tr bgcolor="#EEEEEE">, scrape the text within each <td></td> and then format it in sql. so far i have removed the html not required and created an array by exploding "<tr bgcolor="#EEEEEE">", however, its creating an empty element in the first array index [0], to fix this i have tried $players = array_shift($players); however it removed everything from the array. next i was thinking i would need to remove all html within each array element and add a comma to the end, then i would need to compress it all back together again? would this be the best way to do this? source html <html> <head> <title><br/></title> <style type ="text/css"> body,td,th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; } th { padding: 5px; text-align: left; } td { padding: 2px; border-style: solid; border-width: 1px } </style> </head> <body> <center><B><br/> </center></B> <p> <table bordercolor="#000000" width="90%" align="center"> <tr bgcolor="#EEEEEE"> <th>UID</th> <th>Name</th> <th>Nat</th> <th>Position</th> <th>Best Pos</th> <th>Age</th> <th>DoB</th> <th>Height</th> <th>Weight</th> <th>Expires</th> <th>Wage</th> <th>Value</th> <th>Aer</th> <th>Cmd</th> <th>Com</th> <th>Ecc</th> <th>Han</th> <th>Kic</th> <th>1v1</th> <th>Pun</th> <th>Ref</th> <th>TRO</th> <th>Thr</th> <th>Cor</th> <th>Cro</th> <th>Dri</th> <th>Fin</th> <th>Fir</th> <th>Fre</th> <th>Hea</th> <th>Lon</th> <th>L Th</th> <th>Mar</th> <th>Pas</th> <th>Pen</th> <th>Tck</th> <th>Tec</th> <th>Agg</th> <th>Ant</th> <th>Bra</th> <th>Cmp</th> <th>Cnt</th> <th>Dec</th> <th>Det</th> <th>Fla</th> <th>Ldr</th> <th>OtB</th> <th>Pos</th> <th>Tea</th> <th>Vis</th> <th>Wor</th> <th>Acc</th> <th>Agi</th> <th>Bal</th> <th>Jum</th> <th>Nat</th> <th>Pac</th> <th>Sta</th> <th>Str</th> </tr> <tr bgcolor="#EEEEEE"> <td>859596</td> <td>Tim Krul</td> <td>NED</td> <td>GK</td> <td>GK</td> <td>31</td> <td>3/4/1988 (31 years old)</td> <td>194 cm</td> <td>83 kg</td> <td>30/6/2022</td> <td>£25,000 p/w</td> <td>£12.75M</td> <td>15</td> <td>13</td> <td>14</td> <td>8</td> <td>13</td> <td>13</td> <td>15</td> <td>12</td> <td>16</td> <td>15</td> <td>12</td> <td>1</td> <td>2</td> <td>1</td> <td>3</td> <td>8</td> <td>4</td> <td>5</td> <td>3</td> <td>2</td> <td>2</td> <td>9</td> <td>4</td> <td>3</td> <td>8</td> <td>11</td> <td>12</td> <td>14</td> <td>13</td> <td>13</td> <td>12</td> <td>14</td> <td>2</td> <td>14</td> <td>2</td> <td>15</td> <td>10</td> <td>5</td> <td>13</td> <td>11</td> <td>13</td> <td>14</td> <td>17</td> <td>13</td> <td>8</td> <td>14</td> <td>10</td> </tr> <tr bgcolor="#EEEEEE"> <td>5204730</td> <td>Michael McGovern</td> <td>NIR</td> <td>GK</td> <td>GK</td> <td>34</td> <td>12/7/1984 (34 years old)</td> <td>188 cm</td> <td>86 kg</td> <td>30/6/2021</td> <td>£8,000 p/w</td> <td>£875K</td> <td>12</td> <td>11</td> <td>10</td> <td>2</td> <td>12</td> <td>12</td> <td>12</td> <td>11</td> <td>13</td> <td>8</td> <td>10</td> <td>5</td> <td>2</td> <td>1</td> <td>3</td> <td>9</td> <td>7</td> <td>6</td> <td>3</td> <td>3</td> <td>2</td> <td>7</td> <td>1</td> <td>2</td> <td>5</td> <td>7</td> <td>12</td> <td>14</td> <td>13</td> <td>13</td> <td>11</td> <td>17</td> <td>1</td> <td>12</td> <td>7</td> <td>12</td> <td>15</td> <td>10</td> <td>15</td> <td>10</td> <td>13</td> <td>12</td> <td>12</td> <td>12</td> <td>8</td> <td>15</td> <td>14</td> </tr> </table> <p> <p align="center"> </body> </html>
code i've created so far: <?php // Defining the basic scraping function function scrape_between($data, $start, $end) { $data = stristr($data, $start); // Stripping all data from before $start $data = substr($data, strlen($start)); // Stripping $start $stop = stripos($data, $end); // Getting the position of the $end of the data to scrape $data = substr($data, 0, $stop); // Stripping all data from after and including the $end of the data to scrape return $data; // Returning the scraped data from the function } $myfile = fopen("source.html", "r") or die("Unable to open file!"); $page = fread($myfile,filesize("source.html")); $page = scrape_between($page, '</tr>', '</table>'); $players = explode('<tr bgcolor="#EEEEEE">', $page); echo '<pre>'; print_r($players); echo '</pre>'; fclose($myfile); ?> Edited December 14, 2019 by seany1234 I'm very fresh to php coding, and embedding it in html, so I'm a bit lost here. I have made a script for doing backups of mysql on the QNAP box, I want to make a page to set the variables in it, so the users don't have to change directly in the script like they do now. First the page should read in the current config, and display that in the form, and then users can change the values, and press save, quite simple I'm sure for the experienced php coder :-) I'm not sure if it's a HTML or PHP question, so here goes, if it's in the wrong forum, maybe the moderator will forgive me, and move the topic to the right one. THe page I've currently created looks like this: Code: [Select] <html><body> <h1>Mysql Backup Script</h1> <?php $config=parse_ini_file("config.txt"); ?> <form action="writeconfig.php" method="post"> <p>Days to save config: <input type="text" name="configdays" value="<?php echo $config('configdays'); ?>"/> <br> <p>Name of Backup location (share): <input type="text" name="share" value="<?php echo $config('share'); ?>"/> <br> <p>MySQL Backup User: <input type="text" name="user" value=<?php echo $config('user'); ?>"/> <p>Errorlevel (0=off, 1=error, 2=error+warn, 3=error+warn+info: <select name="error"> <option>0</option> <option>1</option> <option>2</option> <option>3</option> </select> <br> <p><input type="submit" value="Save" /> </form> </body></html> The problem is that it doesn't show the variables in the value fields, but rather the php code And the writeconfig.php looks like this: Code: [Select] <?php $configdays = $_POST['configdays']; $share = $_POST['share']; $user = $_POST['user']; $error = $_POST['error']; $int_options = array("options"=>array("min_range"=>1, "max_range"=>100)); if (!filter_var($configdays, FILTER_VALIDATE_INT, $int_options)) die("Value for number of config days is incorrect allowed value is 1-100"); $fp = fopen("config.txt", "w"); fwrite($fp, "configdays=" . $configdays . "\r\n" . "share=". $share . "\r\n" . "user=". $user . "\r\n" . "error=". $error . "\r\n"); fclose($fp); echo "Config file successfully written" ?> It's all still very raw, but the write part works ok, still needs a lot of input validation of course. As you can see, I'm still in the beginning part of this, so if I'm doing something wrong, or there's another way to do it properly, let me know! PHP code: Code: [Select] <? //login variable $username = $_POST ['username']; $password = $_POST ['password']; $database = $_POST ['database']; //table variable $table = $_POST ['table']; //stats variables $name = $_POST ['name']; $force = $_POST ['force']; $armor = $_POST ['armor']; $strength = $_POST ['strength']; $value = $_POST ['value']; mysql_connect ("localhost","$username","$password"); @mysql_select_db ($database) or die ("no database name"); $query = "INSERT INTO `$database`.`$table` ('name', 'force', 'armor', 'strength', 'value') VALUES ('$name', '$force', '$armor', '$strength', '$value')"; mysql_query ($query); if (mysql_query($query)) { die('Error: ' . mysql_error()); } echo "1 record added<br>"; echo "<br>variable $name test"; echo "<br>variable $force test"; echo "<br>variable $armor test"; echo "<br>variable $strength test"; echo "<br>variable $value test"; mysql_close(); ?> HTML files code: Code: [Select] <form action = "datainput.php" method = "post"> <div align="center">Item Submission Form</div><br><br> <br> <div align="center"><input type="text" name="table" value="head neck back or chest" size="32" maxlength="32"></div> <br> <br> <div align="center"><input type="text" name="name" value="Type Name Here" size="32" maxlength="32"></div> <br> <br> <div align="center"><input type="text" name="force" value="Type force number" size="32" maxlength="32"></div> <br> <br> <div align="center"><input type="text" name="armor" value="Type armor value" size="32" maxlength="32"></div> <br> <br> <div align="center"><input type="text" name="strength" value="Type strength value" size="32" maxlength="32"></div> <br> <br> <div align="center"><input type="text" name="value" value="Type cost Here" size="32" maxlength="32"></div> <br> <br> <br> <div align="center"><input type="text" name="username" value="username here" size="32" maxlength="32"></div> <br> <div align="center"><input type="text" name="password" value="password here" size="32" maxlength="32"></div> <br> <div align="center"><input type="text" name="database" value="database Here" size="32" maxlength="32"></div> <br> <div align="center"><input type="submit" name="Submit_button" value="Submit"></div> </form> What is funky is the page seems to work, it says it writes a record but the record never appears in the database. I did verify MIME types were correct for HTML to be allowed to write as php if needed, any idea why it wouldn't create a record? Hi guys, i cannot figure out what is wrong with this and I hope you could help figure it out? This is the code I am using - Code: [Select] $create_cart_table = "CREATE TABLE `". $string ."` (cart_id int NOT NULL AUTO_INCREMENT, PRIMARY KEY(cart_id), item_name VARCHAR(1000) NOT NULL, item_id VARCHAR(30) NOT NULL, price VARCHAR(30) NOT NULL, date_time TIMESTAMP(100) NOT NULL CURRENT_TIMESTAMP, quantity VARCHAR(100) NOT NULL)"; $set_cart_table = mysql_query($create_cart_table); $string is defined above and there are no database connection warnings etc coming up and I am lost as to how the heck this isn't working? It was working for about an hour when I first made the script but now it is not. Please help? I am working on a register script for my site that will give errors when needed. I am trying to make it so that if the submitted username doesn't equal [A-Za-z0-9-\s]{3,25} then it'll make $error1 = 1. if(preg_match('/[A-Za-z0-9-\s]{3,25}/i', $_POST['username'], $matches) && strlen($matches[0]) === strlen($_POST['username'])){ $error1 = 1; } I've tried putting a ! where the three equal signs are, replaced them, and everything. I am using this sql to filter records : $query = "select * from mobileprices where range='5000'"() but i am getting this error message : mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/dracra/public_html/a.com/range.php range field contains product prices range and filled with 5000, 10000, 15000, 20000 etc. I tried the following code to update the range values from numeric to text in phpmyadmin sql area : Code: [Select] UPDATE mobileprices SET range='five' WHERE range='5000' but i am getting this error message : #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'range='five' WHERE range='5000'' at line 2 I am confused as there are thousands of records and manually updating it one by one will take so much time. Anyone could help me out as how i can change numeric with text in range. or there is any way by that sql could accept this : $query = "select * from mobileprices where range='5000'"() I need a solution, so please help me !! |