Jump to content

ProSpartan

Members
  • Posts

    40
  • Joined

  • Last visited

About ProSpartan

  • Birthday November 4

Profile Information

  • Location
    Rocket City USA
  • Interests
    Programming, Computers, Building, Creating, Networking, Fun.

ProSpartan's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Yes, i have seen that page already. It did work, if I remember correctly when I used it, but the program needs to find a specific char, "@", and replace it with the addin field { SEQ }.
  2. Okay, I've searched and searched and am hoping someone here can help me out. I've been trying to get a VBScript program to open a word document, search for a specific char and replace it with a Addin field (i.e. { SEQ @ } ) Here's what I have thus far: Const wdReplaceAll = 2 Set objWord = CreateObject("Word.Application")objWord.Visible = TrueSet ObjDoc = objWord.Documents.Open("C:\path\to\.doc")Set objSelection = objWord.Selection With objSelectionobjSelection.Find.Text = "@"objSelection.Find.Forward = TrueobjSelection.MatchWholeWord = TrueobjSelection.Find.Replace.Text = "replacement text"objSelection.Find.Execute ,,,,,,,,,,wdReplaceAll .Fields.Add .Range, -1, "SEQ @", True End With objDoc.SaveobjWord.Quit This code works for "Find/Replace" but does not work for fields.Much help would be awesome! Thanks! Edit, 27 Fed 13 (10:21 CST): In red/strikthrough is removed, plain red is added.
  3. ProSpartan

    PHP Database

    Okay, thanks. It worked.
  4. ProSpartan

    PHP Database

    I'm back with a new problem, haha. When i enter text into the textarea of my html page to submit it to the list, but what it does not like is when i use an apostrophe. the error i get is: Error: You have an error in your SQL syntax; check tge manual that corresponds to your MySQL server version for the right syntax to use near ' some text about the input ) ' at line 1. Any thoughts of what could be done?
  5. ProSpartan

    PHP Database

    Thanks. That's all the question i have for now. Thanks everyone who helped me on this project. Couldn't have done it without all y'all!
  6. ProSpartan

    PHP Database

    Okay, but then if the table is empty, i don't really want to be adding task 57 of 1 task. Okay, i'll keep this in mind for when i make a database with users. But over time, the database will get bigger, taking up more space, so deleting the entry will help with disk space management. So back to my three question that i asked,1. which was answered.2. Resetting AUTO_INCREMENT3. From tasks x, how do i decrease the numbers up from there, tasks x, up.eg for 3. I delete tasks x. I want tasks x+1, x+2, x+3, x+4 to be decreased down to x, x+1, x+2, x+3. how? As for this, do i assign it to a variable, '$num = "SELECT COUNT(*) AS num FROM table" ', or is 'num' the variable created that contains the count, and called via '$num'?
  7. ProSpartan

    PHP Database

    Okay... After much work on this and help from everyone, i've gotten the insert and viewTasks completed. Now, i need help with another problem that has risen. I created a delete.php for deleting tasks in the list. i've gotten to where it will delete the task from the list via and AUTO_INCREMENT number. 1. How do I check to see if the table has nothing in it (empty)?2. How do I reset the AUTO_INCREMENT?3. In thinking of future, how do I delete a task from w number, and decrease the AUTO_INCREMENT number from there Number 3 example: I have 10 tasks. I delete number 4 from the table. How do i decrement the numbers from 5 to 10? delete.php so far <html><body> <?php$con = mysql_connect("localhost", "root", "");if(!$con){die('Could not connect: ' . mysql_error());}$tasknumber=$_POST['number'];mysql_select_db("tasks", $con);$delete = "DELETE FROM tasks.taskstable WHERE taskNumber=$tasknumber";if(!mysql_query($delete, $con)){die('Error: ' . mysql_error());}mysql_query("UPDATE tasks.taskstable SET taskNumber=taskNumber - 1"); //Reset AUTO_INCREMENT$result = mysql_query("SELECT * FROM tasks.taskstable"); $row = mysql_fetch_array($result);if(isset($row['tasknumber'])){mysql_query("ALTER TABLE tasks.taskstable AUTO_INCREMENT = 1");echo "No tasks left";}mysql_close($con);?> <form method="link" action="index.html"><input type="Submit" value="Return" /></form> </body></html>
  8. ProSpartan

    PHP Database

    Okay, i got them to show up. phpMyAdmin does not work. No idea why. It is now that i fixed the while loop.
  9. ProSpartan

    PHP Database

    index.html <html><head><title>Tasks to Complete</title></head><body><table border="1" width="100%" height="100%"><tr width="100%" height="10%"> <td colspan="2" height="10%"> <h2 align="center">Welcome to the Task List</h2> </td></tr><tr width="100%" height="90%"> <td width="50%" height="100%"> <form action="insert.php" method="post"> <fieldset> <legend>Insert Tasks Here:</legend> <textarea rows="15" cols="50" name="task"></textarea> </br> </br> <input type="radio" name="importance" id="highly important" value="Highly Important">Highly Important</input> </br> <input type="radio" name="importance" id="important" value="Important">Important</input> </br> <input type="radio" name="importance" id="can wait" value="Can Wait">Can Wait</input> </br> <p>Date Assigned <input type="text" name="date" id="date" /></p> <p>Time Assigned <input type="text" name="time" id="time" /></p> <input type="submit" id="submit task" value="Submit Task" /> </fieldset> </form> </td> <td width="50%" height="100%"> <iframe width="100%" height="100%" src="viewTasks.php"> </iframe> </td></tr></table></body></html> insert.php <html><body><?php$con = mysql_connect('localhost', 'root', '');if(!$con){die('Could not connect: ' . mysql_error());}mysql_select_db('tasks', $con);$sql = "INSERT INTO tasks.taskstable (task, importance, dateAssigned, timeAssigned) VALUES ('$_POST[task]', '$_POST[importance]', '$_POST[date]', '$_POST[time]')";if(!mysql_query($sql, $con)){die('Error: ' . mysql_error());}echo "1 record added";mysql_close($con);?><form method="link" action="index.html"><input type="Submit" value="Return" /></form></body></html> viewTasks.php <html><body><?php$con = mysql_connect("localhost", "root", "");if(!$con){die('Could not connectL ' . mysql_error());}mysql_select_db("tasks", $con);$result = mysql_query("SELECT * FROM tasks.taskstable");if(!$result){die('Invalid query: ' . mysql_error());}echo "<table border='1' width='100%'><tr><th width='40%'>Task</th><th width='20%'>Importance</th><th width='20%'>Date Assigned</th><th width='20%'>Time Assigned</th></tr>";while($row = mysql_fetch_array($result));{echo "<tr>";echo "<td>" . $row['task'] . "</td>";echo "<td>" . $row['importance'] . "</td>";echo "<td>" . $row['dateAssigned'] . "</td>";echo "<td>" . $row['timeAssigned'] . "</td>";echo "</tr>";}mysql_close($con);?></body></html> connect.php (first time use) <html><body><?php$conn=mysql_connect('localhost','root','');if(!$conn){die('Could not connect: ' . mysql_error());}if(mysql_query("CREATE DATABASE tasks", $conn)){echo "Database Created";}else{echo "Error creating database: " . mysql_error();}mysql_select_db("tasks", $conn);$sql = "CREATE TABLE tasksTable(taskNumber int NOT NULL AUTO_INCREMENT,PRIMARY KEY(taskNumber),task Text,importance Text,dateAssigned Text,timeAssigned Text)";mysql_query($sql, $conn);mysql_close($conn);?><script language="javascript">function redirect () { setTimeout("go_now()",10000);}function go_no() { window.location.href = "index.html"}</script></body></html>
  10. ProSpartan

    PHP Database

    Yeah, the error handeling is still there, but i get no errors. I added a return button to return back to index.html which is where an iframe pulls the viewTasks.php via src. <iframe width="100%" height="100%" src="viewTasks.php"> </iframe> Could it be that?
  11. ProSpartan

    PHP Database

    I've followed the examples step by step. insert.php mysql_select_db('tasks', $con);$sql = "INSERT INTO tasks.taskstable (task, importance, dateAssigned, timeAssigned) VALUES ('$_POST[task]', '$_POST[importance]', '$_POST[date]', '$_POST[time]')"; viewTasks.php mysql_select_db("tasks", $con);$result = mysql_query("SELECT * FROM tasks.taskstable");while($row = mysql_fetch_array($result));{ echo "<tr>"; echo "<td>" . $row['task'] . "</td>"; echo "<td>" . $row['importance'] . "</td>"; echo "<td>" . $row['dateAssigned'] . "</td>"; echo "<td>" . $row['timeAssigned'] . "</td>"; echo "</tr>";} But the viewTasks does not work. it is empty still.
  12. ProSpartan

    PHP Database

    $con = mysql_connect("localhost", "root", ""); Yeah, i noticed that as well, so i fixed it. It is tasksTable. will $result = mysql_query("SELECT * FROM tasks.db.tasksTable"); work?
  13. ProSpartan

    PHP Database

    Okay, it was the username/password. So the database is created db.opt and the table, taskstable.frm. I got one record added, but the taskView.php does not show the records.
  14. ProSpartan

    PHP Database

    Okay, what do i do? Just take the .mdb off? I think my error was in that my html was not opening/calling the connect.php, which would make it to where the database is not created. But now i am getting an error where i cannot create the database. Error creating database: Access denied for user ''@'localhost' to database 'tasks' Do i need to be the admin of the computer?
  15. ProSpartan

    PHP Database

    As far as i know, i've done everything correctly. Nothing looks wrong. The code for connecting/creating the database. (connect.php) <html><body><?php$conn=mysql_connect('localhost','','');if(!$conn){die('Could not connect: ' . mysql_error());}if(mysql_query("CREATE DATABASE tasks", $conn)){echo "Database Created";}else{echo "Error creating database: " . mysql_error();}mysql_select_db("tasks.mdb", $conn);$sql = "CREATE TABLE tasksTable(taskNumber int NOT NULL AOUT_INCREMENT,PRIMARY KEY(taskNumber),task Text,importance Text,dateAssigned Text,timeAssigned Text)";mysql_query($sql, $conn);mysql_close($conn);?></body></html> Code for the insert (insert.php) <html><body><?php$con = mysql_connect('localhost', '', '');if(!$con){die('Could not connect: ' . mysql_error());}mysql_select_db('tasks.mdb', $con);$sql = "INSERT INTO taskTable (Task, Importance, DateAssigned, TimeAssigned) VALUES ('$_POST[task]', '$_POST[importance]', '$_POST[date]', '$_POST[time]')";if(!mysql_query($sql, $con)){die('Error: ' . mysql_error());}echo "1 record added";mysql_close($con);?></body></html> Code for viewing the database (viewTasks.php) <html><body><?php$con = mysql_connect("localhost", "", "");if(!$con){die('Could not connectL ' . mysql_error());}mysql_select_db("tasks.mdb", $con);$result = mysql_query("SELECT * FROM tasksTable");echo "<table border='1' width='100%'><tr><th width='40%'>Task</th><th width='20%'>Importance</th><th width='20%'>Date Assigned</th><th width='20%'>Time Assigned</th></tr>";while($row = mysql_fetch_array($result));{echo "<tr>";echo "<td>" . $row['Task'] . "</td>";echo "<td>" . $row['Importance'] . "</td>";echo "<td>" . $row['DateAssigned'] . "</td>";echo "<td>" . $row['TimeAssigned'] . "</td>";echo "</tr>";}mysql_close($con);?></body></html> If there is something wrong with the code, then i can not see where it is at. line 29 should work, but as I read from the topic you posted, the $result will return a boolean of false when it does not connect, which can cause the boolean error.
×
×
  • Create New...