Jump to content

kiwisi

New Members
  • Posts

    7
  • Joined

  • Last visited

kiwisi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Beauty - thanks mate. Thats cleared it up.
  2. as a total noob - I'm having trouble inserting dates using php and myswl. Basically, I want to have the current date and time auto inserted when a new record is added to my table. I've formatted the date field (articledate) to TIMESTAMP (or should it be datetime...) The following code is retrieved from another table so am just wondering how to alter the insert for the date... $query = "insert into gadgets set articletitle = '".$mysqli->real_escape_string($_POST['articletitle'])."', articledescription = '".$mysqli->real_escape_string($_POST['articledescription'])."', articledate = '".$mysqli->real_escape_string($_POST['articledate'])."', myimages = '".$mysqli->real_escape_string($_POST['myimages'])."'"; Clear as mud?
  3. Cheers muddy So - without sounding like a broken record....(cd to you younger peeps) how then, do such seemingly simple sites get a record name fro mysql (like in my instance, bizname) into the title when parsing from another page? Like, "click here for this cafe", then the cafe name is in the page title.. I keep thinking I'm missing a trick here somewhere...
  4. Is that how most pages do it - or am I making it hard for myself? Bearing in mind - I do have all the appropriate html tags before the php script i listed....
  5. So I have this code working fine and it shows almost everything I need. But I want the "bizname" to show in the title tag. I tired echoing the bizname in the title tag but it doesn't do anything. Everything else I look for is about making separate header pages but maybe I'm not searching for the right term? <?php $dbc = mysqli_connect('localhost','','','') or die ('Error connecting to the database'); $RID = $_GET['bizid']; $query="SELECT * FROM business WHERE `bizid` = '$RID'"; $data=mysqli_query($dbc,$query); if($data->num_rows == 0){ echo 'Sorry, there are no matches'; } else { echo '<table>'; while ($row = mysqli_fetch_array($data)){ echo '<tr border="1"> <td class="td1"><h1>' .$row['bizname'] . '</h1></td>'; echo '</tr>'; echo '<tr> <td class="td3">' .$row['bizhours'] . '</td>'; echo '</tr>'; echo '<tr><td class="td2">' .$row['bizdescription'] .'</td>'; echo '</tr>'; echo '<tr> <td class="td2">' .$row['bizaddress'] . '</td>'; echo '</tr>'; echo '<tr> <td class="td2">Phone: ' .$row['bizphone'] . '</td>'; echo '</tr>'; echo '<tr> <td class="td2">Fax: ' .$row['bizfax'] . '</td>'; echo '</tr>'; echo '<tr> <td class="td2">Email: ' .$row['bizemail'] . '</td>'; echo '</tr>'; echo '<tr><td></td>'; echo '</tr>'; } echo '</table>'; } mysqli_close($dbc); ?>
  6. God what a nump.... Doddsey -the S wasn't meant to be there! And the comma was the killer - presumably because it precedes the 'where'? DaveyK - cheers. knew the error reporting had to be in the somewhere, just wasn't sure where to put it. Thanks for your help guys.
  7. This is doing my head in. I have another page on a different table (same database) where this works fine. Yet now when I try to update the record, the eventbody (text area) just echos the data with formatting and it says "unable to update record" - which is defined error. All I did was change the field names on this page... Hope you can help <?php error_reporting(E_ALL); ini_set("display_errors", 1); //include database connection include 'db_connect.php'; //check any user action $action = isset( $_POST['action'] ) ? $_POST['action'] : ""; if($action == "update"){ //if the user hit the submit button //write our update query //$mysqli->real_escape_string() function helps us prevent attacks such as SQL injection $query = "update eventguide set eventtitle = '".$mysqli->real_escape_string($_POST['eventtitle'])."', eventbody = '".$mysqli->real_escape_string($_POST['eventbody'])."', eventdate = '".$mysqli->real_escape_string($_POST['eventdate'])."', where eventid = S'".$mysqli->real_escape_string($_REQUEST['eventid'])."'"; //execute the query if( $mysqli->query($query) ) { //if updating the record was successful echo "<h1><strong>User was updated.</strong></h1>"; }else{ //if unable to update new record echo "Database Error: Unable to update record."; } } //select the specific database record to update $query = "select eventid, eventtitle, eventbody, eventdate from eventguide where eventid = '".$mysqli->real_escape_string($_REQUEST['eventid'])."' limit 0,1"; //execute the query $result = $mysqli->query( $query ); //get the result $row = $result->fetch_assoc(); //assign the result to certain variable so our html form will be filled up with values $eventid = $row['eventid']; $eventtitle = $row['eventtitle']; $eventbody = $row['eventbody']; $eventdate = $row['eventdate']; ?>
×
×
  • 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.